Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / ui / webui / signin / user_manager_screen_handler.h
blob6dd781757468c85569cb32eb988c2e30ad68629a
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_oauth_client.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 gaia::GaiaOAuthClient::Delegate,
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 OnGetTokenInfoResponse(
86 scoped_ptr<base::DictionaryValue> token_info) override;
87 void OnOAuthError() override;
88 void OnNetworkError(int response_code) override;
90 // Handle when Notified of a NOTIFICATION_BROWSER_WINDOW_READY event.
91 void OnBrowserWindowReady(Browser* browser);
93 // Sends user list to account chooser.
94 void SendUserList();
96 // Pass success/failure information back to the web page.
97 void ReportAuthenticationResult(bool success,
98 ProfileMetrics::ProfileAuth metric);
100 // Perform cleanup once the profile and browser are open.
101 void OnSwitchToProfileComplete(Profile* profile,
102 Profile::CreateStatus profile_create_status);
104 // Observes the ProfileInfoCache and gets notified when a profile has been
105 // modified, so that the displayed user pods can be updated.
106 scoped_ptr<ProfileUpdateObserver> profileInfoCacheObserver_;
108 // The host desktop type this user manager belongs to.
109 chrome::HostDesktopType desktop_type_;
111 // Authenticator used when local-auth fails.
112 scoped_ptr<gaia::GaiaOAuthClient> oauth_client_;
114 // The path of the profile currently being authenticated.
115 base::FilePath authenticating_profile_path_;
117 // Login email held during on-line auth for later use.
118 std::string email_address_;
120 // URL hash, used to key post-profile actions if present.
121 std::string url_hash_;
123 typedef std::map<std::string,
124 proximity_auth::ScreenlockBridge::LockHandler::AuthType>
125 UserAuthTypeMap;
126 UserAuthTypeMap user_auth_type_map_;
128 content::NotificationRegistrar registrar_;
130 base::WeakPtrFactory<UserManagerScreenHandler> weak_ptr_factory_;
132 DISALLOW_COPY_AND_ASSIGN(UserManagerScreenHandler);
135 #endif // CHROME_BROWSER_UI_WEBUI_SIGNIN_USER_MANAGER_SCREEN_HANDLER_H_