login_view.h revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
1// Copyright (c) 2011 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_UI_VIEWS_LOGIN_VIEW_H_
6#define CHROME_BROWSER_UI_VIEWS_LOGIN_VIEW_H_
7
8#include "base/compiler_specific.h"
9#include "components/password_manager/core/browser/login_model.h"
10#include "ui/views/view.h"
11
12namespace views {
13class Label;
14class Textfield;
15}
16
17// This class is responsible for displaying the contents of a login window
18// for HTTP/FTP authentication.
19class LoginView : public views::View, public LoginModelObserver {
20 public:
21  // |model| is observed for the entire lifetime of the LoginView.
22  // Therefore |model| should not be destroyed before the LoginView object.
23  LoginView(const base::string16& explanation, LoginModel* model);
24  virtual ~LoginView();
25
26  // Access the data in the username/password text fields.
27  const base::string16& GetUsername() const;
28  const base::string16& GetPassword() const;
29
30  // LoginModelObserver implementation.
31  virtual void OnAutofillDataAvailable(const base::string16& username,
32                                       const base::string16& password) OVERRIDE;
33  virtual void OnLoginModelDestroying() OVERRIDE;
34
35  // Used by LoginHandlerWin to set the initial focus.
36  views::View* GetInitiallyFocusedView();
37
38 private:
39  // Non-owning refs to the input text fields.
40  views::Textfield* username_field_;
41  views::Textfield* password_field_;
42
43  // Button labels
44  views::Label* username_label_;
45  views::Label* password_label_;
46
47  // Authentication message.
48  views::Label* message_label_;
49
50  // If not null, points to a model we need to notify of our own destruction
51  // so it doesn't try and access this when its too late.
52  LoginModel* login_model_;
53
54  DISALLOW_COPY_AND_ASSIGN(LoginView);
55};
56
57#endif  // CHROME_BROWSER_UI_VIEWS_LOGIN_VIEW_H_
58