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_
11 #include "base/callback.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "chrome/browser/profiles/profile_metrics.h"
15 #include "chrome/browser/signin/screenlock_bridge.h"
16 #include "chrome/browser/ui/host_desktop.h"
17 #include "content/public/browser/web_ui_message_handler.h"
18 #include "google_apis/gaia/gaia_auth_consumer.h"
20 class GaiaAuthFetcher;
23 class DictionaryValue;
28 class UserManagerScreenHandler : public content::WebUIMessageHandler,
29 public ScreenlockBridge::LockHandler,
30 public GaiaAuthConsumer {
32 UserManagerScreenHandler();
33 virtual ~UserManagerScreenHandler();
35 // WebUIMessageHandler implementation.
36 virtual void RegisterMessages() OVERRIDE;
38 void GetLocalizedValues(base::DictionaryValue* localized_strings);
40 // ScreenlockBridge::LockHandler implementation.
41 virtual void ShowBannerMessage(const base::string16& message) OVERRIDE;
42 virtual void ShowUserPodCustomIcon(
43 const std::string& user_email,
44 const ScreenlockBridge::UserPodCustomIconOptions& icon_options) OVERRIDE;
45 virtual void HideUserPodCustomIcon(const std::string& user_email) OVERRIDE;
46 virtual void EnableInput() OVERRIDE;
47 virtual void SetAuthType(const std::string& user_email,
48 ScreenlockBridge::LockHandler::AuthType auth_type,
49 const base::string16& auth_value) OVERRIDE;
50 virtual ScreenlockBridge::LockHandler::AuthType GetAuthType(
51 const std::string& user_email) const OVERRIDE;
52 virtual void Unlock(const std::string& user_email) OVERRIDE;
55 // An observer for any changes to Profiles in the ProfileInfoCache so that
56 // all the visible user manager screens can be updated.
57 class ProfileUpdateObserver;
59 void HandleInitialize(const base::ListValue* args);
60 void HandleAddUser(const base::ListValue* args);
61 void HandleAuthenticatedLaunchUser(const base::ListValue* args);
62 void HandleLaunchGuest(const base::ListValue* args);
63 void HandleLaunchUser(const base::ListValue* args);
64 void HandleRemoveUser(const base::ListValue* args);
65 void HandleAttemptUnlock(const base::ListValue* args);
67 // Handle GAIA auth results.
68 virtual void OnClientLoginSuccess(const ClientLoginResult& result) OVERRIDE;
69 virtual void OnClientLoginFailure(const GoogleServiceAuthError& error)
72 // Sends user list to account chooser.
75 // Pass success/failure information back to the web page.
76 void ReportAuthenticationResult(bool success,
77 ProfileMetrics::ProfileAuth metric);
79 // Observes the ProfileInfoCache and gets notified when a profile has been
80 // modified, so that the displayed user pods can be updated.
81 scoped_ptr<ProfileUpdateObserver> profileInfoCacheObserver_;
83 // The host desktop type this user manager belongs to.
84 chrome::HostDesktopType desktop_type_;
86 // Authenticator used when local-auth fails.
87 scoped_ptr<GaiaAuthFetcher> client_login_;
89 // The index of the profile currently being authenticated.
90 size_t authenticating_profile_index_;
92 // Login password, held during on-line auth for saving later if correct.
93 std::string password_attempt_;
95 typedef std::map<std::string, ScreenlockBridge::LockHandler::AuthType>
97 UserAuthTypeMap user_auth_type_map_;
99 DISALLOW_COPY_AND_ASSIGN(UserManagerScreenHandler);
102 #endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_USER_MANAGER_SCREEN_HANDLER_H_