OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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_SIGNIN_USER_MANAGER_SCREEN_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_SIGNIN_USER_MANAGER_SCREEN_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_SIGNIN_USER_MANAGER_SCREEN_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_SIGNIN_USER_MANAGER_SCREEN_HANDLER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" |
| 15 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/profiles/profile_metrics.h" | 16 #include "chrome/browser/profiles/profile_metrics.h" |
15 #include "chrome/browser/signin/screenlock_bridge.h" | 17 #include "chrome/browser/signin/screenlock_bridge.h" |
16 #include "chrome/browser/ui/host_desktop.h" | 18 #include "chrome/browser/ui/host_desktop.h" |
| 19 #include "content/public/browser/notification_observer.h" |
| 20 #include "content/public/browser/notification_registrar.h" |
17 #include "content/public/browser/web_ui_message_handler.h" | 21 #include "content/public/browser/web_ui_message_handler.h" |
18 #include "google_apis/gaia/gaia_auth_consumer.h" | 22 #include "google_apis/gaia/gaia_auth_consumer.h" |
19 | 23 |
20 class GaiaAuthFetcher; | 24 class GaiaAuthFetcher; |
21 | 25 |
22 namespace base { | 26 namespace base { |
23 class DictionaryValue; | 27 class DictionaryValue; |
24 class FilePath; | 28 class FilePath; |
25 class ListValue; | 29 class ListValue; |
26 } | 30 } |
27 | 31 |
28 class UserManagerScreenHandler : public content::WebUIMessageHandler, | 32 class UserManagerScreenHandler : public content::WebUIMessageHandler, |
29 public ScreenlockBridge::LockHandler, | 33 public ScreenlockBridge::LockHandler, |
30 public GaiaAuthConsumer { | 34 public GaiaAuthConsumer, |
| 35 public content::NotificationObserver { |
31 public: | 36 public: |
32 UserManagerScreenHandler(); | 37 UserManagerScreenHandler(); |
33 virtual ~UserManagerScreenHandler(); | 38 virtual ~UserManagerScreenHandler(); |
34 | 39 |
35 // WebUIMessageHandler implementation. | 40 // WebUIMessageHandler implementation. |
36 virtual void RegisterMessages() OVERRIDE; | 41 virtual void RegisterMessages() OVERRIDE; |
37 | 42 |
38 void GetLocalizedValues(base::DictionaryValue* localized_strings); | 43 void GetLocalizedValues(base::DictionaryValue* localized_strings); |
39 | 44 |
| 45 // content::NotificationObserver implementation: |
| 46 virtual void Observe(int type, |
| 47 const content::NotificationSource& source, |
| 48 const content::NotificationDetails& details) OVERRIDE; |
| 49 |
40 // ScreenlockBridge::LockHandler implementation. | 50 // ScreenlockBridge::LockHandler implementation. |
41 virtual void ShowBannerMessage(const base::string16& message) OVERRIDE; | 51 virtual void ShowBannerMessage(const base::string16& message) OVERRIDE; |
42 virtual void ShowUserPodCustomIcon( | 52 virtual void ShowUserPodCustomIcon( |
43 const std::string& user_email, | 53 const std::string& user_email, |
44 const ScreenlockBridge::UserPodCustomIconOptions& icon_options) OVERRIDE; | 54 const ScreenlockBridge::UserPodCustomIconOptions& icon_options) OVERRIDE; |
45 virtual void HideUserPodCustomIcon(const std::string& user_email) OVERRIDE; | 55 virtual void HideUserPodCustomIcon(const std::string& user_email) OVERRIDE; |
46 virtual void EnableInput() OVERRIDE; | 56 virtual void EnableInput() OVERRIDE; |
47 virtual void SetAuthType(const std::string& user_email, | 57 virtual void SetAuthType(const std::string& user_email, |
48 ScreenlockBridge::LockHandler::AuthType auth_type, | 58 ScreenlockBridge::LockHandler::AuthType auth_type, |
49 const base::string16& auth_value) OVERRIDE; | 59 const base::string16& auth_value) OVERRIDE; |
(...skipping 13 matching lines...) Expand all Loading... |
63 void HandleLaunchUser(const base::ListValue* args); | 73 void HandleLaunchUser(const base::ListValue* args); |
64 void HandleRemoveUser(const base::ListValue* args); | 74 void HandleRemoveUser(const base::ListValue* args); |
65 void HandleAttemptUnlock(const base::ListValue* args); | 75 void HandleAttemptUnlock(const base::ListValue* args); |
66 void HandleHardlockUserPod(const base::ListValue* args); | 76 void HandleHardlockUserPod(const base::ListValue* args); |
67 | 77 |
68 // Handle GAIA auth results. | 78 // Handle GAIA auth results. |
69 virtual void OnClientLoginSuccess(const ClientLoginResult& result) OVERRIDE; | 79 virtual void OnClientLoginSuccess(const ClientLoginResult& result) OVERRIDE; |
70 virtual void OnClientLoginFailure(const GoogleServiceAuthError& error) | 80 virtual void OnClientLoginFailure(const GoogleServiceAuthError& error) |
71 OVERRIDE; | 81 OVERRIDE; |
72 | 82 |
| 83 // Handle when Notified of a NOTIFICATION_BROWSER_WINDOW_READY event. |
| 84 void OnBrowserWindowReady(Browser* browser); |
| 85 |
73 // Sends user list to account chooser. | 86 // Sends user list to account chooser. |
74 void SendUserList(); | 87 void SendUserList(); |
75 | 88 |
76 // Pass success/failure information back to the web page. | 89 // Pass success/failure information back to the web page. |
77 void ReportAuthenticationResult(bool success, | 90 void ReportAuthenticationResult(bool success, |
78 ProfileMetrics::ProfileAuth metric); | 91 ProfileMetrics::ProfileAuth metric); |
79 | 92 |
| 93 // Perform cleanup once the profile and browser are open. |
| 94 void OnSwitchToProfileComplete(Profile* profile, |
| 95 Profile::CreateStatus profile_create_status); |
| 96 |
80 // Observes the ProfileInfoCache and gets notified when a profile has been | 97 // Observes the ProfileInfoCache and gets notified when a profile has been |
81 // modified, so that the displayed user pods can be updated. | 98 // modified, so that the displayed user pods can be updated. |
82 scoped_ptr<ProfileUpdateObserver> profileInfoCacheObserver_; | 99 scoped_ptr<ProfileUpdateObserver> profileInfoCacheObserver_; |
83 | 100 |
84 // The host desktop type this user manager belongs to. | 101 // The host desktop type this user manager belongs to. |
85 chrome::HostDesktopType desktop_type_; | 102 chrome::HostDesktopType desktop_type_; |
86 | 103 |
87 // Authenticator used when local-auth fails. | 104 // Authenticator used when local-auth fails. |
88 scoped_ptr<GaiaAuthFetcher> client_login_; | 105 scoped_ptr<GaiaAuthFetcher> client_login_; |
89 | 106 |
90 // The index of the profile currently being authenticated. | 107 // The index of the profile currently being authenticated. |
91 size_t authenticating_profile_index_; | 108 size_t authenticating_profile_index_; |
92 | 109 |
93 // Login password, held during on-line auth for saving later if correct. | 110 // Login password, held during on-line auth for saving later if correct. |
94 std::string password_attempt_; | 111 std::string password_attempt_; |
95 | 112 |
| 113 // URL hash, used to key post-profile actions if present. |
| 114 std::string url_hash_; |
| 115 |
96 typedef std::map<std::string, ScreenlockBridge::LockHandler::AuthType> | 116 typedef std::map<std::string, ScreenlockBridge::LockHandler::AuthType> |
97 UserAuthTypeMap; | 117 UserAuthTypeMap; |
98 UserAuthTypeMap user_auth_type_map_; | 118 UserAuthTypeMap user_auth_type_map_; |
99 | 119 |
| 120 base::WeakPtrFactory<UserManagerScreenHandler> weak_ptr_factory_; |
| 121 |
| 122 content::NotificationRegistrar registrar_; |
| 123 |
100 DISALLOW_COPY_AND_ASSIGN(UserManagerScreenHandler); | 124 DISALLOW_COPY_AND_ASSIGN(UserManagerScreenHandler); |
101 }; | 125 }; |
102 | 126 |
103 #endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_USER_MANAGER_SCREEN_HANDLER_H_ | 127 #endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_USER_MANAGER_SCREEN_HANDLER_H_ |
OLD | NEW |