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_
10 #include "base/callback.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "chrome/browser/profiles/profile_metrics.h"
14 #include "chrome/browser/signin/screenlock_bridge.h"
15 #include "chrome/browser/ui/host_desktop.h"
16 #include "content/public/browser/web_ui_message_handler.h"
17 #include "google_apis/gaia/gaia_auth_consumer.h"
19 class GaiaAuthFetcher;
22 class DictionaryValue;
27 class UserManagerScreenHandler : public content::WebUIMessageHandler,
28 public ScreenlockBridge::LockHandler,
29 public GaiaAuthConsumer {
31 UserManagerScreenHandler();
32 virtual ~UserManagerScreenHandler();
34 // WebUIMessageHandler implementation.
35 virtual void RegisterMessages() OVERRIDE;
37 void GetLocalizedValues(base::DictionaryValue* localized_strings);
39 // ScreenlockBridge::LockHandler implementation.
40 virtual void ShowBannerMessage(const std::string& message) OVERRIDE;
41 virtual void ShowUserPodButton(const std::string& user_email,
42 const gfx::Image& icon,
43 const base::Closure& callback) OVERRIDE;
44 virtual void HideUserPodButton(const std::string& user_email) OVERRIDE;
45 virtual void EnableInput() OVERRIDE;
46 virtual void SetAuthType(const std::string& user_email,
47 ScreenlockBridge::LockHandler::AuthType auth_type,
48 const std::string& auth_value) OVERRIDE;
49 virtual ScreenlockBridge::LockHandler::AuthType GetAuthType(
50 const std::string& user_email) const OVERRIDE;
51 virtual void Unlock(const std::string& user_email) OVERRIDE;
54 // An observer for any changes to Profiles in the ProfileInfoCache so that
55 // all the visible user manager screens can be updated.
56 class ProfileUpdateObserver;
58 void HandleInitialize(const base::ListValue* args);
59 void HandleAddUser(const base::ListValue* args);
60 void HandleAuthenticatedLaunchUser(const base::ListValue* args);
61 void HandleLaunchGuest(const base::ListValue* args);
62 void HandleLaunchUser(const base::ListValue* args);
63 void HandleRemoveUser(const base::ListValue* args);
64 void HandleCustomButtonClicked(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_