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