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"
21 // Chrome personal stuff profiles manage overlay UI handler.
22 class ManageProfileHandler
: public OptionsPageUIHandler
,
23 public ProfileSyncServiceObserver
{
25 ManageProfileHandler();
26 virtual ~ManageProfileHandler();
28 // OptionsPageUIHandler:
29 virtual void GetLocalizedValues(
30 base::DictionaryValue
* localized_strings
) OVERRIDE
;
31 virtual void InitializeHandler() OVERRIDE
;
32 virtual void InitializePage() OVERRIDE
;
33 virtual void Uninitialize() OVERRIDE
;
35 // WebUIMessageHandler:
36 virtual void RegisterMessages() OVERRIDE
;
38 // content::NotificationObserver:
39 virtual void Observe(int type
,
40 const content::NotificationSource
& source
,
41 const content::NotificationDetails
& details
) OVERRIDE
;
43 // ProfileSyncServiceObserver:
44 virtual void OnStateChanged() OVERRIDE
;
47 // Callback for the "requestDefaultProfileIcons" message.
48 // Sends the array of default profile icon URLs to WebUI.
49 // |args| is of the form: [ {string} iconURL ]
50 void RequestDefaultProfileIcons(const base::ListValue
* args
);
52 // Callback for the "requestNewProfileDefaults" message.
53 // Sends an object to WebUI of the form:
54 // { "name": profileName, "iconURL": iconURL }
55 void RequestNewProfileDefaults(const base::ListValue
* args
);
57 // Send all profile icons to the overlay.
58 // |iconGrid| is the name of the grid to populate with icons (i.e.
59 // "create-profile-icon-grid" or "manage-profile-icon-grid").
60 void SendProfileIcons(const base::StringValue
& icon_grid
);
62 // Sends an object to WebUI of the form:
64 // "Profile Name 1": true,
65 // "Profile Name 2": true,
68 // This is used to detect duplicate profile names.
69 void SendProfileNames();
71 // Callback for the "setProfileIconAndName" message. Sets the name and icon
72 // of a given profile.
73 // |args| is of the form: [
74 // /*string*/ profileFilePath,
75 // /*string*/ newProfileIconURL
76 // /*string*/ newProfileName,
78 void SetProfileIconAndName(const base::ListValue
* args
);
80 #if defined(ENABLE_SETTINGS_APP)
81 // Callback for the "switchAppListProfile" message. Asks the
82 // app_list_controller to change the profile registered for the AppList.
83 // |args| is of the form: [ {string} profileFilePath ]
84 void SwitchAppListProfile(const base::ListValue
* args
);
87 // Callback for the 'profileIconSelectionChanged' message. Used to update the
88 // name in the manager profile dialog based on the selected icon.
89 void ProfileIconSelectionChanged(const base::ListValue
* args
);
91 // Callback for the "requestHasProfileShortcuts" message, which is called
92 // when editing an existing profile. Asks the profile shortcut manager whether
93 // the profile has shortcuts and gets the result in |OnHasProfileShortcuts()|.
94 // |args| is of the form: [ {string} profileFilePath ]
95 void RequestHasProfileShortcuts(const base::ListValue
* args
);
97 // Callback for the "RequestCreateProfileUpdate" message.
98 // Sends the email address of the signed-in user, or an empty string if the
99 // user is not signed in. Also sends information about whether managed users
101 void RequestCreateProfileUpdate(const base::ListValue
* args
);
103 // When the pref allowing managed-user creation changes, sends the new value
105 void OnCreateManagedUserPrefChange();
107 // Callback invoked from the profile manager indicating whether the profile
108 // being edited has any desktop shortcuts.
109 void OnHasProfileShortcuts(bool has_shortcuts
);
111 // Callback for the "addProfileShortcut" message, which is called when editing
112 // an existing profile and the user clicks the "Add desktop shortcut" button.
113 // Adds a desktop shortcut for the profile.
114 void AddProfileShortcut(const base::ListValue
* args
);
116 // Callback for the "removeProfileShortcut" message, which is called when
117 // editing an existing profile and the user clicks the "Remove desktop
118 // shortcut" button. Removes the desktop shortcut for the profile.
119 void RemoveProfileShortcut(const base::ListValue
* args
);
121 // URL for the current profile's GAIA picture.
122 std::string gaia_picture_url_
;
124 // Used to observe the preference that allows creating managed users, which
125 // can be changed by policy.
126 PrefChangeRegistrar pref_change_registrar_
;
128 // For generating weak pointers to itself for callbacks.
129 base::WeakPtrFactory
<ManageProfileHandler
> weak_factory_
;
131 DISALLOW_COPY_AND_ASSIGN(ManageProfileHandler
);
134 } // namespace options
136 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_MANAGE_PROFILE_HANDLER_H_