Upstream version 7.36.149.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
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"
18
19 class GaiaAuthFetcher;
20
21 namespace base {
22 class DictionaryValue;
23 class FilePath;
24 class ListValue;
25 }
26
27 class UserManagerScreenHandler : public content::WebUIMessageHandler,
28                                  public ScreenlockBridge::LockHandler,
29                                  public GaiaAuthConsumer {
30  public:
31   UserManagerScreenHandler();
32   virtual ~UserManagerScreenHandler();
33
34   // WebUIMessageHandler implementation.
35   virtual void RegisterMessages() OVERRIDE;
36
37   void GetLocalizedValues(base::DictionaryValue* localized_strings);
38
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;
52
53  private:
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;
57
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);
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_