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