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.
5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_MANAGE_PROFILE_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_MANAGE_PROFILE_HANDLER_H_
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"
22 // Chrome personal stuff profiles manage overlay UI handler.
23 class ManageProfileHandler : public OptionsPageUIHandler,
24 public content::NotificationObserver,
25 public ProfileSyncServiceObserver {
27 ManageProfileHandler();
28 virtual ~ManageProfileHandler();
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;
37 // WebUIMessageHandler:
38 virtual void RegisterMessages() OVERRIDE;
40 // content::NotificationObserver:
41 virtual void Observe(int type,
42 const content::NotificationSource& source,
43 const content::NotificationDetails& details) OVERRIDE;
45 // ProfileSyncServiceObserver:
46 virtual void OnStateChanged() OVERRIDE;
49 // This function creates signed in user specific strings in loadTimeData.
50 void GenerateSignedinUserSpecificStrings(base::DictionaryValue* dictionary);
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);
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);
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);
66 // Sends an object to WebUI of the form:
68 // "Profile Name 1": true,
69 // "Profile Name 2": true,
72 // This is used to detect duplicate profile names.
73 void SendExistingProfileNames();
75 // Show disconnect managed profile dialog after generating domain and user
77 void ShowDisconnectManagedProfileDialog(const base::ListValue* args);
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,
86 void SetProfileIconAndName(const base::ListValue* args);
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);
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);
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);
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);
111 // When the pref allowing supervised-user creation changes, sends the new
113 void OnCreateSupervisedUserPrefChange();
115 // Callback invoked from the profile manager indicating whether the profile
116 // being edited has any desktop shortcuts.
117 void OnHasProfileShortcuts(bool has_shortcuts);
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);
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);
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);
133 // URL for the current profile's GAIA picture.
134 std::string gaia_picture_url_;
136 // Used to observe the preference that allows creating supervised users, which
137 // can be changed by policy.
138 PrefChangeRegistrar pref_change_registrar_;
140 // For generating weak pointers to itself for callbacks.
141 base::WeakPtrFactory<ManageProfileHandler> weak_factory_;
143 DISALLOW_COPY_AND_ASSIGN(ManageProfileHandler);
146 } // namespace options
148 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_MANAGE_PROFILE_HANDLER_H_