36f8cf5a8f2e7178f75682d5b2eac0a7203a5cb1
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / webui / options / manage_profile_handler.h
1 // Copyright (c) 2012 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_OPTIONS_MANAGE_PROFILE_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_MANAGE_PROFILE_HANDLER_H_
7
8 #include <string>
9
10 #include "base/memory/weak_ptr.h"
11 #include "base/prefs/pref_change_registrar.h"
12 #include "chrome/browser/sync/profile_sync_service_observer.h"
13 #include "chrome/browser/ui/webui/options/options_ui.h"
14 #include "content/public/browser/notification_observer.h"
15
16 namespace base {
17 class StringValue;
18 }
19
20 namespace options {
21
22 // Chrome personal stuff profiles manage overlay UI handler.
23 class ManageProfileHandler : public OptionsPageUIHandler,
24                              public content::NotificationObserver,
25                              public ProfileSyncServiceObserver {
26  public:
27   ManageProfileHandler();
28   virtual ~ManageProfileHandler();
29
30   // OptionsPageUIHandler:
31   virtual void GetLocalizedValues(
32       base::DictionaryValue* localized_strings) OVERRIDE;
33   virtual void InitializeHandler() OVERRIDE;
34   virtual void InitializePage() OVERRIDE;
35   virtual void Uninitialize() OVERRIDE;
36
37   // WebUIMessageHandler:
38   virtual void RegisterMessages() OVERRIDE;
39
40   // content::NotificationObserver:
41   virtual void Observe(int type,
42                        const content::NotificationSource& source,
43                        const content::NotificationDetails& details) OVERRIDE;
44
45   // ProfileSyncServiceObserver:
46   virtual void OnStateChanged() OVERRIDE;
47
48  private:
49   // This function creates signed in user specific strings in loadTimeData.
50   void GenerateSignedinUserSpecificStrings(base::DictionaryValue* dictionary);
51
52   // Callback for the "requestDefaultProfileIcons" message.
53   // Sends the array of default profile icon URLs and profile names to WebUI.
54   // First item of |args| is the dialog mode, i.e. "create" or "manage".
55   void RequestDefaultProfileIcons(const base::ListValue* args);
56
57   // Callback for the "requestNewProfileDefaults" message.
58   // Sends an object to WebUI of the form:
59   //   { "name": profileName, "iconURL": iconURL }
60   void RequestNewProfileDefaults(const base::ListValue* args);
61
62   // Send all profile icons and their default names to the overlay.
63   // |mode| is the dialog mode, i.e. "create" or "manage".
64   void SendProfileIconsAndNames(const base::StringValue& mode);
65
66   // Sends an object to WebUI of the form:
67   //   profileNames = {
68   //     "Profile Name 1": true,
69   //     "Profile Name 2": true,
70   //     ...
71   //   };
72   // This is used to detect duplicate profile names.
73   void SendExistingProfileNames();
74
75   // Show disconnect managed profile dialog after generating domain and user
76   // specific strings.
77   void ShowDisconnectManagedProfileDialog(const base::ListValue* args);
78
79   // Callback for the "setProfileIconAndName" message. Sets the name and icon
80   // of a given profile.
81   // |args| is of the form: [
82   //   /*string*/ profileFilePath,
83   //   /*string*/ newProfileIconURL
84   //   /*string*/ newProfileName,
85   // ]
86   void SetProfileIconAndName(const base::ListValue* args);
87
88 #if defined(ENABLE_SETTINGS_APP)
89   // Callback for the "switchAppListProfile" message. Asks the
90   // app_list_controller to change the profile registered for the AppList.
91   // |args| is of the form: [ {string} profileFilePath ]
92   void SwitchAppListProfile(const base::ListValue* args);
93 #endif
94
95   // Callback for the 'profileIconSelectionChanged' message. Used to update the
96   // name in the manager profile dialog based on the selected icon.
97   void ProfileIconSelectionChanged(const base::ListValue* args);
98
99   // Callback for the "requestHasProfileShortcuts" message, which is called
100   // when editing an existing profile. Asks the profile shortcut manager whether
101   // the profile has shortcuts and gets the result in |OnHasProfileShortcuts()|.
102   // |args| is of the form: [ {string} profileFilePath ]
103   void RequestHasProfileShortcuts(const base::ListValue* args);
104
105   // Callback for the "RequestCreateProfileUpdate" message.
106   // Sends the email address of the signed-in user, or an empty string if the
107   // user is not signed in. Also sends information about whether supervised
108   // users may be created.
109   void RequestCreateProfileUpdate(const base::ListValue* args);
110
111   // When the pref allowing supervised-user creation changes, sends the new
112   // value to the UI.
113   void OnCreateSupervisedUserPrefChange();
114
115   // Callback invoked from the profile manager indicating whether the profile
116   // being edited has any desktop shortcuts.
117   void OnHasProfileShortcuts(bool has_shortcuts);
118
119   // Callback for the "addProfileShortcut" message, which is called when editing
120   // an existing profile and the user clicks the "Add desktop shortcut" button.
121   // Adds a desktop shortcut for the profile.
122   void AddProfileShortcut(const base::ListValue* args);
123
124   // Callback for the "removeProfileShortcut" message, which is called when
125   // editing an existing profile and the user clicks the "Remove desktop
126   // shortcut" button. Removes the desktop shortcut for the profile.
127   void RemoveProfileShortcut(const base::ListValue* args);
128
129   // Callback for the "refreshGaiaPicture" message, which is called when the
130   // user is editing an existing profile.
131   void RefreshGaiaPicture(const base::ListValue* args);
132
133   // URL for the current profile's GAIA picture.
134   std::string gaia_picture_url_;
135
136   // Used to observe the preference that allows creating supervised users, which
137   // can be changed by policy.
138   PrefChangeRegistrar pref_change_registrar_;
139
140   // For generating weak pointers to itself for callbacks.
141   base::WeakPtrFactory<ManageProfileHandler> weak_factory_;
142
143   DISALLOW_COPY_AND_ASSIGN(ManageProfileHandler);
144 };
145
146 }  // namespace options
147
148 #endif  // CHROME_BROWSER_UI_WEBUI_OPTIONS_MANAGE_PROFILE_HANDLER_H_