OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_UI_WEBUI_CHROMEOS_LOGIN_SIGNIN_SCREEN_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SIGNIN_SCREEN_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SIGNIN_SCREEN_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SIGNIN_SCREEN_HANDLER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/containers/hash_tables.h" | 15 #include "base/containers/hash_tables.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "chrome/browser/chromeos/login/screens/error_screen_actor.h" | 19 #include "chrome/browser/chromeos/login/screens/network_error_model.h" |
20 #include "chrome/browser/chromeos/login/signin_specifics.h" | 20 #include "chrome/browser/chromeos/login/signin_specifics.h" |
21 #include "chrome/browser/chromeos/login/ui/login_display.h" | 21 #include "chrome/browser/chromeos/login/ui/login_display.h" |
22 #include "chrome/browser/chromeos/settings/cros_settings.h" | 22 #include "chrome/browser/chromeos/settings/cros_settings.h" |
23 #include "chrome/browser/signin/screenlock_bridge.h" | 23 #include "chrome/browser/signin/screenlock_bridge.h" |
24 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h" | 24 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h" |
25 #include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h" | |
26 #include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h" | 25 #include "chrome/browser/ui/webui/chromeos/login/network_state_informer.h" |
27 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | 26 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
28 #include "chrome/browser/ui/webui/chromeos/touch_view_controller_delegate.h" | 27 #include "chrome/browser/ui/webui/chromeos/touch_view_controller_delegate.h" |
29 #include "chromeos/network/portal_detector/network_portal_detector.h" | 28 #include "chromeos/network/portal_detector/network_portal_detector.h" |
30 #include "components/user_manager/user_manager.h" | 29 #include "components/user_manager/user_manager.h" |
31 #include "content/public/browser/notification_observer.h" | 30 #include "content/public/browser/notification_observer.h" |
32 #include "content/public/browser/notification_registrar.h" | 31 #include "content/public/browser/notification_registrar.h" |
33 #include "content/public/browser/web_ui.h" | 32 #include "content/public/browser/web_ui.h" |
34 #include "net/base/net_errors.h" | 33 #include "net/base/net_errors.h" |
35 #include "ui/base/ime/chromeos/ime_keyboard.h" | 34 #include "ui/base/ime/chromeos/ime_keyboard.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 : public BaseScreenHandler, | 198 : public BaseScreenHandler, |
200 public LoginDisplayWebUIHandler, | 199 public LoginDisplayWebUIHandler, |
201 public content::NotificationObserver, | 200 public content::NotificationObserver, |
202 public NetworkStateInformer::NetworkStateInformerObserver, | 201 public NetworkStateInformer::NetworkStateInformerObserver, |
203 public input_method::ImeKeyboard::Observer, | 202 public input_method::ImeKeyboard::Observer, |
204 public TouchViewControllerDelegate::Observer, | 203 public TouchViewControllerDelegate::Observer, |
205 public OobeUI::Observer { | 204 public OobeUI::Observer { |
206 public: | 205 public: |
207 SigninScreenHandler( | 206 SigninScreenHandler( |
208 const scoped_refptr<NetworkStateInformer>& network_state_informer, | 207 const scoped_refptr<NetworkStateInformer>& network_state_informer, |
209 ErrorScreenActor* error_screen_actor, | 208 NetworkErrorModel* network_error_model, |
210 CoreOobeActor* core_oobe_actor, | 209 CoreOobeActor* core_oobe_actor, |
211 GaiaScreenHandler* gaia_screen_handler); | 210 GaiaScreenHandler* gaia_screen_handler); |
212 ~SigninScreenHandler() override; | 211 ~SigninScreenHandler() override; |
213 | 212 |
214 static std::string GetUserLRUInputMethod(const std::string& username); | 213 static std::string GetUserLRUInputMethod(const std::string& username); |
215 | 214 |
216 // Update current input method (namely keyboard layout) in the given IME state | 215 // Update current input method (namely keyboard layout) in the given IME state |
217 // to LRU by this user. | 216 // to LRU by this user. |
218 static void SetUserInputMethod( | 217 static void SetUserInputMethod( |
219 const std::string& username, | 218 const std::string& username, |
220 input_method::InputMethodManager::State* ime_state); | 219 input_method::InputMethodManager::State* ime_state); |
221 | 220 |
222 // Shows the sign in screen. | 221 // Shows the sign in screen. |
223 void Show(const LoginScreenContext& context); | 222 void Show(const LoginScreenContext& context); |
224 | 223 |
225 // Sets delegate to be used by the handler. It is guaranteed that valid | 224 // Sets delegate to be used by the handler. It is guaranteed that valid |
226 // delegate is set before Show() method will be called. | 225 // delegate is set before Show() method will be called. |
227 void SetDelegate(SigninScreenHandlerDelegate* delegate); | 226 void SetDelegate(SigninScreenHandlerDelegate* delegate); |
228 | 227 |
229 void SetNativeWindowDelegate(NativeWindowDelegate* native_window_delegate); | 228 void SetNativeWindowDelegate(NativeWindowDelegate* native_window_delegate); |
230 | 229 |
231 // NetworkStateInformer::NetworkStateInformerObserver implementation: | 230 // NetworkStateInformer::NetworkStateInformerObserver implementation: |
232 void OnNetworkReady() override; | 231 void OnNetworkReady() override; |
233 void UpdateState(ErrorScreenActor::ErrorReason reason) override; | 232 void UpdateState(NetworkError::ErrorReason reason) override; |
234 | 233 |
235 // Required Local State preferences. | 234 // Required Local State preferences. |
236 static void RegisterPrefs(PrefRegistrySimple* registry); | 235 static void RegisterPrefs(PrefRegistrySimple* registry); |
237 | 236 |
238 // OobeUI::Observer implemetation. | 237 // OobeUI::Observer implemetation. |
239 void OnCurrentScreenChanged(OobeUI::Screen current_screen, | 238 void OnCurrentScreenChanged(OobeUI::Screen current_screen, |
240 OobeUI::Screen new_screen) override; | 239 OobeUI::Screen new_screen) override; |
241 | 240 |
242 void SetFocusPODCallbackForTesting(base::Closure callback); | 241 void SetFocusPODCallbackForTesting(base::Closure callback); |
243 | 242 |
244 private: | 243 private: |
245 enum UIState { | 244 enum UIState { |
246 UI_STATE_UNKNOWN = 0, | 245 UI_STATE_UNKNOWN = 0, |
247 UI_STATE_GAIA_SIGNIN, | 246 UI_STATE_GAIA_SIGNIN, |
248 UI_STATE_ACCOUNT_PICKER, | 247 UI_STATE_ACCOUNT_PICKER, |
249 }; | 248 }; |
250 | 249 |
251 friend class GaiaScreenHandler; | 250 friend class GaiaScreenHandler; |
252 friend class ReportDnsCacheClearedOnUIThread; | 251 friend class ReportDnsCacheClearedOnUIThread; |
253 friend class SupervisedUserCreationScreenHandler; | 252 friend class SupervisedUserCreationScreenHandler; |
254 | 253 |
255 void ShowImpl(); | 254 void ShowImpl(); |
256 | 255 |
257 // Updates current UI of the signin screen according to |ui_state| | 256 // Updates current UI of the signin screen according to |ui_state| |
258 // argument. Optionally it can pass screen initialization data via | 257 // argument. Optionally it can pass screen initialization data via |
259 // |params| argument. | 258 // |params| argument. |
260 void UpdateUIState(UIState ui_state, base::DictionaryValue* params); | 259 void UpdateUIState(UIState ui_state, base::DictionaryValue* params); |
261 | 260 |
262 void UpdateStateInternal(ErrorScreenActor::ErrorReason reason, | 261 void UpdateStateInternal(NetworkError::ErrorReason reason, bool force_update); |
263 bool force_update); | |
264 void SetupAndShowOfflineMessage(NetworkStateInformer::State state, | 262 void SetupAndShowOfflineMessage(NetworkStateInformer::State state, |
265 ErrorScreenActor::ErrorReason reason); | 263 NetworkError::ErrorReason reason); |
266 void HideOfflineMessage(NetworkStateInformer::State state, | 264 void HideOfflineMessage(NetworkStateInformer::State state, |
267 ErrorScreenActor::ErrorReason reason); | 265 NetworkError::ErrorReason reason); |
268 void ReloadGaia(bool force_reload); | 266 void ReloadGaia(bool force_reload); |
269 | 267 |
270 // BaseScreenHandler implementation: | 268 // BaseScreenHandler implementation: |
271 void DeclareLocalizedValues( | 269 void DeclareLocalizedValues( |
272 ::login::LocalizedValuesBuilder* builder) override; | 270 ::login::LocalizedValuesBuilder* builder) override; |
273 void Initialize() override; | 271 void Initialize() override; |
274 gfx::NativeWindow GetNativeWindow() override; | 272 gfx::NativeWindow GetNativeWindow() override; |
275 | 273 |
276 // WebUIMessageHandler implementation: | 274 // WebUIMessageHandler implementation: |
277 void RegisterMessages() override; | 275 void RegisterMessages() override; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 bool IsGuestSigninAllowed() const; | 389 bool IsGuestSigninAllowed() const; |
392 | 390 |
393 // Returns true if offline login is allowed. | 391 // Returns true if offline login is allowed. |
394 bool IsOfflineLoginAllowed() const; | 392 bool IsOfflineLoginAllowed() const; |
395 | 393 |
396 bool ShouldLoadGaia() const; | 394 bool ShouldLoadGaia() const; |
397 | 395 |
398 // Shows signin. | 396 // Shows signin. |
399 void OnShowAddUser(); | 397 void OnShowAddUser(); |
400 | 398 |
401 GaiaScreenHandler::FrameState FrameState() const; | |
402 net::Error FrameError() const; | 399 net::Error FrameError() const; |
403 | 400 |
404 // input_method::ImeKeyboard::Observer implementation: | 401 // input_method::ImeKeyboard::Observer implementation: |
405 void OnCapsLockChanged(bool enabled) override; | 402 void OnCapsLockChanged(bool enabled) override; |
406 | 403 |
407 // Returns OobeUI object of NULL. | 404 // Returns OobeUI object of NULL. |
408 OobeUI* GetOobeUI() const; | 405 OobeUI* GetOobeUI() const; |
409 | 406 |
410 // Gets the easy unlock service associated with the user. Can return NULL if | 407 // Gets the easy unlock service associated with the user. Can return NULL if |
411 // user cannot be found, or there is not associated service. | 408 // user cannot be found, or there is not associated service. |
(...skipping 18 matching lines...) Expand all Loading... |
430 // Is account picker being shown for the first time. | 427 // Is account picker being shown for the first time. |
431 bool is_account_picker_showing_first_time_; | 428 bool is_account_picker_showing_first_time_; |
432 | 429 |
433 // Network state informer used to keep signin screen up. | 430 // Network state informer used to keep signin screen up. |
434 scoped_refptr<NetworkStateInformer> network_state_informer_; | 431 scoped_refptr<NetworkStateInformer> network_state_informer_; |
435 | 432 |
436 // Set to true once |LOGIN_WEBUI_VISIBLE| notification is observed. | 433 // Set to true once |LOGIN_WEBUI_VISIBLE| notification is observed. |
437 bool webui_visible_; | 434 bool webui_visible_; |
438 bool preferences_changed_delayed_; | 435 bool preferences_changed_delayed_; |
439 | 436 |
440 ErrorScreenActor* error_screen_actor_; | 437 NetworkErrorModel* network_error_model_; |
441 CoreOobeActor* core_oobe_actor_; | 438 CoreOobeActor* core_oobe_actor_; |
442 | 439 |
443 bool is_first_update_state_call_; | 440 bool is_first_update_state_call_; |
444 bool offline_login_active_; | 441 bool offline_login_active_; |
445 NetworkStateInformer::State last_network_state_; | 442 NetworkStateInformer::State last_network_state_; |
446 | 443 |
447 base::CancelableClosure update_state_closure_; | 444 base::CancelableClosure update_state_closure_; |
448 base::CancelableClosure connecting_closure_; | 445 base::CancelableClosure connecting_closure_; |
449 | 446 |
450 content::NotificationRegistrar registrar_; | 447 content::NotificationRegistrar registrar_; |
(...skipping 27 matching lines...) Expand all Loading... |
478 scoped_ptr<ErrorScreensHistogramHelper> histogram_helper_; | 475 scoped_ptr<ErrorScreensHistogramHelper> histogram_helper_; |
479 | 476 |
480 base::WeakPtrFactory<SigninScreenHandler> weak_factory_; | 477 base::WeakPtrFactory<SigninScreenHandler> weak_factory_; |
481 | 478 |
482 DISALLOW_COPY_AND_ASSIGN(SigninScreenHandler); | 479 DISALLOW_COPY_AND_ASSIGN(SigninScreenHandler); |
483 }; | 480 }; |
484 | 481 |
485 } // namespace chromeos | 482 } // namespace chromeos |
486 | 483 |
487 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SIGNIN_SCREEN_HANDLER_H_ | 484 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_SIGNIN_SCREEN_HANDLER_H_ |
OLD | NEW |