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