Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / chrome / browser / ui / webui / signin / user_manager_screen_handler.h
blob98bf442571a8dec57a6ffdbb170e1f2aa494a66e
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_WEBUI_SIGNIN_USER_MANAGER_SCREEN_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_SIGNIN_USER_MANAGER_SCREEN_HANDLER_H_
8 #include <map>
9 #include <string>
11 #include "base/callback.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h"
15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/profiles/profile_metrics.h"
17 #include "chrome/browser/ui/host_desktop.h"
18 #include "components/proximity_auth/screenlock_bridge.h"
19 #include "content/public/browser/notification_observer.h"
20 #include "content/public/browser/notification_registrar.h"
21 #include "content/public/browser/web_ui_message_handler.h"
22 #include "google_apis/gaia/gaia_auth_consumer.h"
24 class GaiaAuthFetcher;
26 namespace base {
27 class DictionaryValue;
28 class FilePath;
29 class ListValue;
32 class UserManagerScreenHandler
33 : public content::WebUIMessageHandler,
34 public proximity_auth::ScreenlockBridge::LockHandler,
35 public GaiaAuthConsumer,
36 public content::NotificationObserver {
37 public:
38 UserManagerScreenHandler();
39 ~UserManagerScreenHandler() override;
41 // WebUIMessageHandler implementation.
42 void RegisterMessages() override;
44 void GetLocalizedValues(base::DictionaryValue* localized_strings);
46 // content::NotificationObserver implementation:
47 void Observe(int type,
48 const content::NotificationSource& source,
49 const content::NotificationDetails& details) override;
51 // proximity_auth::ScreenlockBridge::LockHandler implementation.
52 void ShowBannerMessage(const base::string16& message) override;
53 void ShowUserPodCustomIcon(
54 const std::string& user_email,
55 const proximity_auth::ScreenlockBridge::UserPodCustomIconOptions&
56 icon_options) override;
57 void HideUserPodCustomIcon(const std::string& user_email) override;
58 void EnableInput() override;
59 void SetAuthType(
60 const std::string& user_email,
61 proximity_auth::ScreenlockBridge::LockHandler::AuthType auth_type,
62 const base::string16& auth_value) override;
63 AuthType GetAuthType(const std::string& user_email) const override;
64 ScreenType GetScreenType() const override;
65 void Unlock(const std::string& user_email) override;
66 void AttemptEasySignin(const std::string& user_email,
67 const std::string& secret,
68 const std::string& key_label) override;
70 private:
71 // An observer for any changes to Profiles in the ProfileInfoCache so that
72 // all the visible user manager screens can be updated.
73 class ProfileUpdateObserver;
75 void HandleInitialize(const base::ListValue* args);
76 void HandleAddUser(const base::ListValue* args);
77 void HandleAuthenticatedLaunchUser(const base::ListValue* args);
78 void HandleLaunchGuest(const base::ListValue* args);
79 void HandleLaunchUser(const base::ListValue* args);
80 void HandleRemoveUser(const base::ListValue* args);
81 void HandleAttemptUnlock(const base::ListValue* args);
82 void HandleHardlockUserPod(const base::ListValue* args);
84 // Handle GAIA auth results.
85 void OnClientLoginSuccess(const ClientLoginResult& result) override;
86 void OnClientLoginFailure(const GoogleServiceAuthError& error) override;
88 // Handle when Notified of a NOTIFICATION_BROWSER_WINDOW_READY event.
89 void OnBrowserWindowReady(Browser* browser);
91 // Sends user list to account chooser.
92 void SendUserList();
94 // Pass success/failure information back to the web page.
95 void ReportAuthenticationResult(bool success,
96 ProfileMetrics::ProfileAuth metric);
98 // Perform cleanup once the profile and browser are open.
99 void OnSwitchToProfileComplete(Profile* profile,
100 Profile::CreateStatus profile_create_status);
102 // Observes the ProfileInfoCache and gets notified when a profile has been
103 // modified, so that the displayed user pods can be updated.
104 scoped_ptr<ProfileUpdateObserver> profileInfoCacheObserver_;
106 // The host desktop type this user manager belongs to.
107 chrome::HostDesktopType desktop_type_;
109 // Authenticator used when local-auth fails.
110 scoped_ptr<GaiaAuthFetcher> client_login_;
112 // The index of the profile currently being authenticated.
113 size_t authenticating_profile_index_;
115 // Login password, held during on-line auth for saving later if correct.
116 std::string password_attempt_;
118 // URL hash, used to key post-profile actions if present.
119 std::string url_hash_;
121 typedef std::map<std::string,
122 proximity_auth::ScreenlockBridge::LockHandler::AuthType>
123 UserAuthTypeMap;
124 UserAuthTypeMap user_auth_type_map_;
126 content::NotificationRegistrar registrar_;
128 base::WeakPtrFactory<UserManagerScreenHandler> weak_ptr_factory_;
130 DISALLOW_COPY_AND_ASSIGN(UserManagerScreenHandler);
133 #endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_USER_MANAGER_SCREEN_HANDLER_H_