| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_MANAGE_PROFILE_HANDLER_H_ | |
| 6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_MANAGE_PROFILE_HANDLER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/memory/weak_ptr.h" | |
| 11 #include "chrome/browser/profiles/profile_info_cache_observer.h" | |
| 12 #include "chrome/browser/ui/webui/settings/md_settings_ui.h" | |
| 13 | |
| 14 namespace base { | |
| 15 class StringValue; | |
| 16 } | |
| 17 | |
| 18 class Profile; | |
| 19 | |
| 20 namespace settings { | |
| 21 | |
| 22 // Chrome personal stuff profiles manage overlay UI handler. | |
| 23 class ManageProfileHandler : public settings::SettingsPageUIHandler, | |
| 24 public ProfileInfoCacheObserver { | |
| 25 public: | |
| 26 explicit ManageProfileHandler(Profile* profile); | |
| 27 ~ManageProfileHandler() override; | |
| 28 | |
| 29 // settings::SettingsPageUIHandler: | |
| 30 void RegisterMessages() override; | |
| 31 | |
| 32 // ProfileInfoCacheObserver: | |
| 33 void OnProfileNameChanged(const base::FilePath& profile_path, | |
| 34 const base::string16& old_profile_name) override; | |
| 35 void OnProfileAvatarChanged(const base::FilePath& profile_path) override; | |
| 36 | |
| 37 private: | |
| 38 // Callback for the "requestDefaultProfileIcons" message. | |
| 39 // Sends the array of default profile icon URLs and profile names to WebUI. | |
| 40 // First item of |args| is the dialog mode, i.e. "create" or "manage". | |
| 41 void RequestDefaultProfileIcons(const base::ListValue* args); | |
| 42 | |
| 43 // Send all the available profile icons to choose from. | |
| 44 void SendAvailableIcons(); | |
| 45 | |
| 46 // Callback for the "setProfileIconAndName" message. Sets the name and icon | |
| 47 // of a given profile. | |
| 48 // |args| is of the form: [ | |
| 49 // /*string*/ profileFilePath, | |
| 50 // /*string*/ newProfileIconURL | |
| 51 // /*string*/ newProfileName, | |
| 52 // ] | |
| 53 void SetProfileIconAndName(const base::ListValue* args); | |
| 54 | |
| 55 // Callback for the 'profileIconSelectionChanged' message. Used to update the | |
| 56 // name in the manager profile dialog based on the selected icon. | |
| 57 void ProfileIconSelectionChanged(const base::ListValue* args); | |
| 58 | |
| 59 // Callback for the "requestHasProfileShortcuts" message, which is called | |
| 60 // when editing an existing profile. Asks the profile shortcut manager whether | |
| 61 // the profile has shortcuts and gets the result in |OnHasProfileShortcuts()|. | |
| 62 // |args| is of the form: [ {string} profileFilePath ] | |
| 63 void RequestHasProfileShortcuts(const base::ListValue* args); | |
| 64 | |
| 65 // Callback invoked from the profile manager indicating whether the profile | |
| 66 // being edited has any desktop shortcuts. | |
| 67 void OnHasProfileShortcuts(bool has_shortcuts); | |
| 68 | |
| 69 // Callback for the "addProfileShortcut" message, which is called when editing | |
| 70 // an existing profile and the user clicks the "Add desktop shortcut" button. | |
| 71 // Adds a desktop shortcut for the profile. | |
| 72 void AddProfileShortcut(const base::ListValue* args); | |
| 73 | |
| 74 // Callback for the "removeProfileShortcut" message, which is called when | |
| 75 // editing an existing profile and the user clicks the "Remove desktop | |
| 76 // shortcut" button. Removes the desktop shortcut for the profile. | |
| 77 void RemoveProfileShortcut(const base::ListValue* args); | |
| 78 | |
| 79 // Callback for the "refreshGaiaPicture" message, which is called when the | |
| 80 // user is editing an existing profile. | |
| 81 void RefreshGaiaPicture(const base::ListValue* args); | |
| 82 | |
| 83 // Non-owning pointer to the associated profile. | |
| 84 Profile* profile_; | |
| 85 | |
| 86 // URL for the current profile's GAIA picture. | |
| 87 std::string gaia_picture_url_; | |
| 88 | |
| 89 // For generating weak pointers to itself for callbacks. | |
| 90 base::WeakPtrFactory<ManageProfileHandler> weak_factory_; | |
| 91 | |
| 92 DISALLOW_COPY_AND_ASSIGN(ManageProfileHandler); | |
| 93 }; | |
| 94 | |
| 95 } // namespace settings | |
| 96 | |
| 97 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_SETTINGS_MANAGE_PROFILE_HANDLER_H_ | |
| OLD | NEW |