Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: chrome/browser/ui/webui/settings/settings_manage_profile_handler.h

Issue 1536593004: Settings People Revamp: Implement Chrome Profile name/icon selection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_MANAGE_PROFILE_HANDLER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_MANAGE_PROFILE_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_MANAGE_PROFILE_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_MANAGE_PROFILE_HANDLER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/weak_ptr.h" 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" 11 #include "chrome/browser/profiles/profile_info_cache_observer.h"
13 #include "chrome/browser/ui/webui/options/options_ui.h" 12 #include "chrome/browser/ui/webui/settings/md_settings_ui.h"
14 #include "components/sync_driver/sync_service_observer.h"
15 13
16 namespace base { 14 namespace base {
17 class StringValue; 15 class StringValue;
18 } 16 }
19 17
20 namespace options { 18 class Profile;
19
20 namespace settings {
21 21
22 // Chrome personal stuff profiles manage overlay UI handler. 22 // Chrome personal stuff profiles manage overlay UI handler.
23 class ManageProfileHandler : public OptionsPageUIHandler, 23 class ManageProfileHandler : public settings::SettingsPageUIHandler,
24 public ProfileInfoCacheObserver, 24 public ProfileInfoCacheObserver {
25 public sync_driver::SyncServiceObserver {
26 public: 25 public:
27 ManageProfileHandler(); 26 explicit ManageProfileHandler(Profile* profile);
28 ~ManageProfileHandler() override; 27 ~ManageProfileHandler() override;
29 28
30 // OptionsPageUIHandler: 29 // settings::SettingsPageUIHandler:
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; 30 void RegisterMessages() override;
38 31
39 // ProfileInfoCacheObserver: 32 // 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, 33 void OnProfileNameChanged(const base::FilePath& profile_path,
44 const base::string16& old_profile_name) override; 34 const base::string16& old_profile_name) override;
45 void OnProfileAvatarChanged(const base::FilePath& profile_path) override; 35 void OnProfileAvatarChanged(const base::FilePath& profile_path) override;
46 36
47 // sync_driver::SyncServiceObserver:
48 void OnStateChanged() override;
49
50 private: 37 private:
51 // This function creates signed in user specific strings in loadTimeData.
52 void GenerateSignedinUserSpecificStrings(base::DictionaryValue* dictionary);
53
54 // Callback for the "requestDefaultProfileIcons" message. 38 // Callback for the "requestDefaultProfileIcons" message.
55 // Sends the array of default profile icon URLs and profile names to WebUI. 39 // 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". 40 // First item of |args| is the dialog mode, i.e. "create" or "manage".
57 void RequestDefaultProfileIcons(const base::ListValue* args); 41 void RequestDefaultProfileIcons(const base::ListValue* args);
58 42
59 // Callback for the "requestNewProfileDefaults" message. 43 // Send all the available profile icons to choose from.
60 // Sends an object to WebUI of the form: 44 void SendAvailableIcons();
61 // { "name": profileName, "iconURL": iconURL }
62 void RequestNewProfileDefaults(const base::ListValue* args);
63
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);
67
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();
76
77 // Show disconnect managed profile dialog after generating domain and user
78 // specific strings.
79 void ShowDisconnectManagedProfileDialog(const base::ListValue* args);
80 45
81 // Callback for the "setProfileIconAndName" message. Sets the name and icon 46 // Callback for the "setProfileIconAndName" message. Sets the name and icon
82 // of a given profile. 47 // of a given profile.
83 // |args| is of the form: [ 48 // |args| is of the form: [
84 // /*string*/ profileFilePath, 49 // /*string*/ profileFilePath,
85 // /*string*/ newProfileIconURL 50 // /*string*/ newProfileIconURL
86 // /*string*/ newProfileName, 51 // /*string*/ newProfileName,
87 // ] 52 // ]
88 void SetProfileIconAndName(const base::ListValue* args); 53 void SetProfileIconAndName(const base::ListValue* args);
89 54
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
96
97 // Callback for the 'profileIconSelectionChanged' message. Used to update the 55 // Callback for the 'profileIconSelectionChanged' message. Used to update the
98 // name in the manager profile dialog based on the selected icon. 56 // name in the manager profile dialog based on the selected icon.
99 void ProfileIconSelectionChanged(const base::ListValue* args); 57 void ProfileIconSelectionChanged(const base::ListValue* args);
100 58
101 // Callback for the "requestHasProfileShortcuts" message, which is called 59 // Callback for the "requestHasProfileShortcuts" message, which is called
102 // when editing an existing profile. Asks the profile shortcut manager whether 60 // when editing an existing profile. Asks the profile shortcut manager whether
103 // the profile has shortcuts and gets the result in |OnHasProfileShortcuts()|. 61 // the profile has shortcuts and gets the result in |OnHasProfileShortcuts()|.
104 // |args| is of the form: [ {string} profileFilePath ] 62 // |args| is of the form: [ {string} profileFilePath ]
105 void RequestHasProfileShortcuts(const base::ListValue* args); 63 void RequestHasProfileShortcuts(const base::ListValue* args);
106 64
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);
112
113 // When the pref allowing supervised-user creation changes, sends the new
114 // value to the UI.
115 void OnCreateSupervisedUserPrefChange();
116
117 // Callback invoked from the profile manager indicating whether the profile 65 // Callback invoked from the profile manager indicating whether the profile
118 // being edited has any desktop shortcuts. 66 // being edited has any desktop shortcuts.
119 void OnHasProfileShortcuts(bool has_shortcuts); 67 void OnHasProfileShortcuts(bool has_shortcuts);
120 68
121 // Callback for the "addProfileShortcut" message, which is called when editing 69 // Callback for the "addProfileShortcut" message, which is called when editing
122 // an existing profile and the user clicks the "Add desktop shortcut" button. 70 // an existing profile and the user clicks the "Add desktop shortcut" button.
123 // Adds a desktop shortcut for the profile. 71 // Adds a desktop shortcut for the profile.
124 void AddProfileShortcut(const base::ListValue* args); 72 void AddProfileShortcut(const base::ListValue* args);
125 73
126 // Callback for the "removeProfileShortcut" message, which is called when 74 // Callback for the "removeProfileShortcut" message, which is called when
127 // editing an existing profile and the user clicks the "Remove desktop 75 // editing an existing profile and the user clicks the "Remove desktop
128 // shortcut" button. Removes the desktop shortcut for the profile. 76 // shortcut" button. Removes the desktop shortcut for the profile.
129 void RemoveProfileShortcut(const base::ListValue* args); 77 void RemoveProfileShortcut(const base::ListValue* args);
130 78
131 // Callback for the "refreshGaiaPicture" message, which is called when the 79 // Callback for the "refreshGaiaPicture" message, which is called when the
132 // user is editing an existing profile. 80 // user is editing an existing profile.
133 void RefreshGaiaPicture(const base::ListValue* args); 81 void RefreshGaiaPicture(const base::ListValue* args);
134 82
83 // The associated profile.
Dan Beam 2015/12/28 23:28:57 might be worth mentioning weak ownership
tommycli 2016/01/04 21:40:13 Done.
84 Profile* profile_;
85
135 // URL for the current profile's GAIA picture. 86 // URL for the current profile's GAIA picture.
136 std::string gaia_picture_url_; 87 std::string gaia_picture_url_;
137 88
138 // Used to observe the preference that allows creating supervised users, which
139 // can be changed by policy.
140 PrefChangeRegistrar pref_change_registrar_;
141
142 // For generating weak pointers to itself for callbacks. 89 // For generating weak pointers to itself for callbacks.
143 base::WeakPtrFactory<ManageProfileHandler> weak_factory_; 90 base::WeakPtrFactory<ManageProfileHandler> weak_factory_;
144 91
145 DISALLOW_COPY_AND_ASSIGN(ManageProfileHandler); 92 DISALLOW_COPY_AND_ASSIGN(ManageProfileHandler);
146 }; 93 };
147 94
148 } // namespace options 95 } // namespace settings
149 96
150 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_MANAGE_PROFILE_HANDLER_H_ 97 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_MANAGE_PROFILE_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698