OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_NEW_USER_VIEW_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_NEW_USER_VIEW_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_NEW_USER_VIEW_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_NEW_USER_VIEW_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
12 #include "base/ref_counted.h" | 12 #include "base/ref_counted.h" |
13 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
14 #include "chrome/browser/chromeos/login/language_switch_model.h" | 14 #include "chrome/browser/chromeos/login/language_switch_model.h" |
| 15 #include "chrome/browser/chromeos/login/login_html_dialog.h" |
15 #include "views/accelerator.h" | 16 #include "views/accelerator.h" |
16 #include "views/controls/button/button.h" | 17 #include "views/controls/button/button.h" |
17 #include "views/controls/button/menu_button.h" | 18 #include "views/controls/button/menu_button.h" |
18 #include "views/controls/link.h" | 19 #include "views/controls/link.h" |
19 #include "views/controls/textfield/textfield.h" | 20 #include "views/controls/textfield/textfield.h" |
20 #include "views/view.h" | 21 #include "views/view.h" |
21 | 22 |
22 namespace views { | 23 namespace views { |
23 class Label; | 24 class Label; |
24 class NativeButton; | 25 class NativeButton; |
25 class Throbber; | 26 class Throbber; |
26 } // namespace views | 27 } // namespace views |
27 | 28 |
28 namespace chromeos { | 29 namespace chromeos { |
29 | 30 |
30 // View that is used for new user login. It asks for username and password, | 31 // View that is used for new user login. It asks for username and password, |
31 // allows to specify language preferences or initiate new account creation. | 32 // allows to specify language preferences or initiate new account creation. |
32 class NewUserView : public views::View, | 33 class NewUserView : public views::View, |
33 public views::Textfield::Controller, | 34 public views::Textfield::Controller, |
34 public views::LinkController, | 35 public views::LinkController, |
35 public views::ButtonListener { | 36 public views::ButtonListener, |
| 37 public LoginHtmlDialog::Delegate { |
36 public: | 38 public: |
37 // Delegate class to get notifications from the view. | 39 // Delegate class to get notifications from the view. |
38 class Delegate { | 40 class Delegate { |
39 public: | 41 public: |
40 virtual ~Delegate() {} | 42 virtual ~Delegate() {} |
41 | 43 |
42 // User provided |username|, |password| and initiated login. | 44 // User provided |username|, |password| and initiated login. |
43 virtual void OnLogin(const std::string& username, | 45 virtual void OnLogin(const std::string& username, |
44 const std::string& password) = 0; | 46 const std::string& password) = 0; |
45 | 47 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 const string16& new_contents) {} | 97 const string16& new_contents) {} |
96 | 98 |
97 // Overridden from views::ButtonListener. | 99 // Overridden from views::ButtonListener. |
98 virtual void ButtonPressed(views::Button* sender, const views::Event& event); | 100 virtual void ButtonPressed(views::Button* sender, const views::Event& event); |
99 | 101 |
100 // Overridden from views::LinkController. | 102 // Overridden from views::LinkController. |
101 virtual void LinkActivated(views::Link* source, int event_flags); | 103 virtual void LinkActivated(views::Link* source, int event_flags); |
102 | 104 |
103 virtual bool AcceleratorPressed(const views::Accelerator& accelerator); | 105 virtual bool AcceleratorPressed(const views::Accelerator& accelerator); |
104 | 106 |
| 107 // LoginHtmlDialog::Delegate implementation. |
| 108 virtual void OnDialogClosed() {} |
| 109 |
105 protected: | 110 protected: |
106 // views::View overrides: | 111 // views::View overrides: |
107 virtual void ViewHierarchyChanged(bool is_add, views::View *parent, | 112 virtual void ViewHierarchyChanged(bool is_add, views::View *parent, |
108 views::View *child); | 113 views::View *child); |
109 | |
110 virtual void NativeViewHierarchyChanged(bool attached, | 114 virtual void NativeViewHierarchyChanged(bool attached, |
111 gfx::NativeView native_view, | 115 gfx::NativeView native_view, |
112 views::RootView* root_view); | 116 views::RootView* root_view); |
113 virtual void LocaleChanged(); | 117 virtual void LocaleChanged(); |
114 | 118 |
115 private: | 119 private: |
| 120 // Returns corresponding native window. |
| 121 gfx::NativeWindow GetNativeWindow() const; |
| 122 |
116 // Enables/disables input controls (textfields, buttons). | 123 // Enables/disables input controls (textfields, buttons). |
117 void EnableInputControls(bool enabled); | 124 void EnableInputControls(bool enabled); |
118 void FocusFirstField(); | 125 void FocusFirstField(); |
119 | 126 |
| 127 // Creates Link control and adds it as a child. |
| 128 void InitLink(views::Link** link); |
| 129 |
120 // Delete and recreate native controls that fail to update preferred size | 130 // Delete and recreate native controls that fail to update preferred size |
121 // after string update. | 131 // after string update. |
122 void RecreateNativeControls(); | 132 void RecreateNativeControls(); |
123 | 133 |
124 views::Textfield* username_field_; | 134 views::Textfield* username_field_; |
125 views::Textfield* password_field_; | 135 views::Textfield* password_field_; |
126 views::Label* title_label_; | 136 views::Label* title_label_; |
127 views::NativeButton* sign_in_button_; | 137 views::NativeButton* sign_in_button_; |
128 views::Link* create_account_link_; | 138 views::Link* create_account_link_; |
| 139 views::Link* cant_access_account_link_; |
129 views::Link* browse_without_signin_link_; | 140 views::Link* browse_without_signin_link_; |
130 views::MenuButton* languages_menubutton_; | 141 views::MenuButton* languages_menubutton_; |
131 views::Throbber* throbber_; | 142 views::Throbber* throbber_; |
132 | 143 |
133 views::Accelerator accel_focus_user_; | 144 views::Accelerator accel_focus_user_; |
134 views::Accelerator accel_focus_pass_; | 145 views::Accelerator accel_focus_pass_; |
135 | 146 |
136 // Notifications receiver. | 147 // Notifications receiver. |
137 Delegate* delegate_; | 148 Delegate* delegate_; |
138 | 149 |
139 ScopedRunnableMethodFactory<NewUserView> focus_grabber_factory_; | 150 ScopedRunnableMethodFactory<NewUserView> focus_grabber_factory_; |
140 | 151 |
141 LanguageSwitchModel language_switch_model_; | 152 LanguageSwitchModel language_switch_model_; |
142 | 153 |
| 154 // Dialog used to display help like "Can't access your account". |
| 155 scoped_ptr<LoginHtmlDialog> dialog_; |
| 156 |
143 // Indicates that this view was created when focus manager was unavailable | 157 // Indicates that this view was created when focus manager was unavailable |
144 // (on the hidden tab, for example). | 158 // (on the hidden tab, for example). |
145 bool focus_delayed_; | 159 bool focus_delayed_; |
146 | 160 |
147 // True when login is in process. | 161 // True when login is in process. |
148 bool login_in_process_; | 162 bool login_in_process_; |
149 | 163 |
150 // If true, this view needs RoundedRect border and background. | 164 // If true, this view needs RoundedRect border and background. |
151 bool need_border_; | 165 bool need_border_; |
152 | 166 |
153 FRIEND_TEST_ALL_PREFIXES(LoginScreenTest, IncognitoLogin); | 167 FRIEND_TEST_ALL_PREFIXES(LoginScreenTest, IncognitoLogin); |
154 friend class LoginScreenTest; | 168 friend class LoginScreenTest; |
155 | 169 |
156 DISALLOW_COPY_AND_ASSIGN(NewUserView); | 170 DISALLOW_COPY_AND_ASSIGN(NewUserView); |
157 }; | 171 }; |
158 | 172 |
159 } // namespace chromeos | 173 } // namespace chromeos |
160 | 174 |
161 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_NEW_USER_VIEW_H_ | 175 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_NEW_USER_VIEW_H_ |
OLD | NEW |