Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / webui / signin / user_manager_screen_handler.h
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.
4
5 #ifndef CHROME_BROWSER_UI_WEBUI_SIGNIN_USER_MANAGER_SCREEN_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_SIGNIN_USER_MANAGER_SCREEN_HANDLER_H_
7
8 #include <map>
9 #include <string>
10
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"
19
20 class GaiaAuthFetcher;
21
22 namespace base {
23 class DictionaryValue;
24 class FilePath;
25 class ListValue;
26 }
27
28 class UserManagerScreenHandler : public content::WebUIMessageHandler,
29                                  public ScreenlockBridge::LockHandler,
30                                  public GaiaAuthConsumer {
31  public:
32   UserManagerScreenHandler();
33   virtual ~UserManagerScreenHandler();
34
35   // WebUIMessageHandler implementation.
36   virtual void RegisterMessages() OVERRIDE;
37
38   void GetLocalizedValues(base::DictionaryValue* localized_strings);
39
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;
53
54  private:
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;
58
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);
66
67   // Handle GAIA auth results.
68   virtual void OnClientLoginSuccess(const ClientLoginResult& result) OVERRIDE;
69   virtual void OnClientLoginFailure(const GoogleServiceAuthError& error)
70       OVERRIDE;
71
72   // Sends user list to account chooser.
73   void SendUserList();
74
75   // Pass success/failure information back to the web page.
76   void ReportAuthenticationResult(bool success,
77                                   ProfileMetrics::ProfileAuth metric);
78
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_;
82
83   // The host desktop type this user manager belongs to.
84   chrome::HostDesktopType desktop_type_;
85
86   // Authenticator used when local-auth fails.
87   scoped_ptr<GaiaAuthFetcher> client_login_;
88
89   // The index of the profile currently being authenticated.
90   size_t authenticating_profile_index_;
91
92   // Login password, held during on-line auth for saving later if correct.
93   std::string password_attempt_;
94
95   typedef std::map<std::string, ScreenlockBridge::LockHandler::AuthType>
96       UserAuthTypeMap;
97   UserAuthTypeMap user_auth_type_map_;
98
99   DISALLOW_COPY_AND_ASSIGN(UserManagerScreenHandler);
100 };
101
102 #endif  // CHROME_BROWSER_UI_WEBUI_SIGNIN_USER_MANAGER_SCREEN_HANDLER_H_