NaCl: Update revision in DEPS, r12770 -> r12773
[chromium-blink-merge.git] / chrome / browser / ui / webui / options / manage_profile_handler.h
blobd4286e34b24865ddcb3dc7b28a2b8f50688ef318
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_
8 #include <string>
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"
16 namespace base {
17 class StringValue;
20 namespace options {
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();
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;
48 private:
49 // Callback for the "requestDefaultProfileIcons" message.
50 // Sends the array of default profile icon URLs to WebUI.
51 // |args| is of the form: [ {string} iconURL ]
52 void RequestDefaultProfileIcons(const base::ListValue* args);
54 // Callback for the "requestNewProfileDefaults" message.
55 // Sends an object to WebUI of the form:
56 // { "name": profileName, "iconURL": iconURL }
57 void RequestNewProfileDefaults(const base::ListValue* args);
59 // Send all profile icons to the overlay.
60 // |iconGrid| is the name of the grid to populate with icons (i.e.
61 // "create-profile-icon-grid" or "manage-profile-icon-grid").
62 void SendProfileIcons(const base::StringValue& icon_grid);
64 // Sends an object to WebUI of the form:
65 // profileNames = {
66 // "Profile Name 1": true,
67 // "Profile Name 2": true,
68 // ...
69 // };
70 // This is used to detect duplicate profile names.
71 void SendProfileNames();
73 // Callback for the "setProfileIconAndName" message. Sets the name and icon
74 // of a given profile.
75 // |args| is of the form: [
76 // /*string*/ profileFilePath,
77 // /*string*/ newProfileIconURL
78 // /*string*/ newProfileName,
79 // ]
80 void SetProfileIconAndName(const base::ListValue* args);
82 #if defined(ENABLE_SETTINGS_APP)
83 // Callback for the "switchAppListProfile" message. Asks the
84 // app_list_controller to change the profile registered for the AppList.
85 // |args| is of the form: [ {string} profileFilePath ]
86 void SwitchAppListProfile(const base::ListValue* args);
87 #endif
89 // Callback for the 'profileIconSelectionChanged' message. Used to update the
90 // name in the manager profile dialog based on the selected icon.
91 void ProfileIconSelectionChanged(const base::ListValue* args);
93 // Callback for the "requestHasProfileShortcuts" message, which is called
94 // when editing an existing profile. Asks the profile shortcut manager whether
95 // the profile has shortcuts and gets the result in |OnHasProfileShortcuts()|.
96 // |args| is of the form: [ {string} profileFilePath ]
97 void RequestHasProfileShortcuts(const base::ListValue* args);
99 // Callback for the "RequestCreateProfileUpdate" message.
100 // Sends the email address of the signed-in user, or an empty string if the
101 // user is not signed in. Also sends information about whether managed users
102 // may be created.
103 void RequestCreateProfileUpdate(const base::ListValue* args);
105 // When the pref allowing managed-user creation changes, sends the new value
106 // to the UI.
107 void OnCreateManagedUserPrefChange();
109 // Callback invoked from the profile manager indicating whether the profile
110 // being edited has any desktop shortcuts.
111 void OnHasProfileShortcuts(bool has_shortcuts);
113 // Callback for the "addProfileShortcut" message, which is called when editing
114 // an existing profile and the user clicks the "Add desktop shortcut" button.
115 // Adds a desktop shortcut for the profile.
116 void AddProfileShortcut(const base::ListValue* args);
118 // Callback for the "removeProfileShortcut" message, which is called when
119 // editing an existing profile and the user clicks the "Remove desktop
120 // shortcut" button. Removes the desktop shortcut for the profile.
121 void RemoveProfileShortcut(const base::ListValue* args);
123 // URL for the current profile's GAIA picture.
124 std::string gaia_picture_url_;
126 // Used to observe the preference that allows creating managed users, which
127 // can be changed by policy.
128 PrefChangeRegistrar pref_change_registrar_;
130 // For generating weak pointers to itself for callbacks.
131 base::WeakPtrFactory<ManageProfileHandler> weak_factory_;
133 DISALLOW_COPY_AND_ASSIGN(ManageProfileHandler);
136 } // namespace options
138 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_MANAGE_PROFILE_HANDLER_H_