manage_profile_handler.h revision 8bcbed890bc3ce4d7a057a8f32cab53fa534672e
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. 4 5#ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_MANAGE_PROFILE_HANDLER_H_ 6#define CHROME_BROWSER_UI_WEBUI_OPTIONS_MANAGE_PROFILE_HANDLER_H_ 7 8#include <string> 9 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 15namespace base { 16class StringValue; 17} 18 19namespace options { 20 21// Chrome personal stuff profiles manage overlay UI handler. 22class ManageProfileHandler : public OptionsPageUIHandler, 23 public ProfileSyncServiceObserver { 24 public: 25 ManageProfileHandler(); 26 virtual ~ManageProfileHandler(); 27 28 // OptionsPageUIHandler: 29 virtual void GetLocalizedValues( 30 base::DictionaryValue* localized_strings) OVERRIDE; 31 virtual void InitializeHandler() OVERRIDE; 32 virtual void InitializePage() OVERRIDE; 33 virtual void Uninitialize() OVERRIDE; 34 35 // WebUIMessageHandler: 36 virtual void RegisterMessages() OVERRIDE; 37 38 // content::NotificationObserver: 39 virtual void Observe(int type, 40 const content::NotificationSource& source, 41 const content::NotificationDetails& details) OVERRIDE; 42 43 // ProfileSyncServiceObserver: 44 virtual void OnStateChanged() OVERRIDE; 45 46 private: 47 // Callback for the "requestDefaultProfileIcons" message. 48 // Sends the array of default profile icon URLs to WebUI. 49 // |args| is of the form: [ {string} iconURL ] 50 void RequestDefaultProfileIcons(const base::ListValue* args); 51 52 // Callback for the "requestNewProfileDefaults" message. 53 // Sends an object to WebUI of the form: 54 // { "name": profileName, "iconURL": iconURL } 55 void RequestNewProfileDefaults(const base::ListValue* args); 56 57 // Send all profile icons to the overlay. 58 // |iconGrid| is the name of the grid to populate with icons (i.e. 59 // "create-profile-icon-grid" or "manage-profile-icon-grid"). 60 void SendProfileIcons(const base::StringValue& icon_grid); 61 62 // Sends an object to WebUI of the form: 63 // profileNames = { 64 // "Profile Name 1": true, 65 // "Profile Name 2": true, 66 // ... 67 // }; 68 // This is used to detect duplicate profile names. 69 void SendProfileNames(); 70 71 // Callback for the "setProfileIconAndName" message. Sets the name and icon 72 // of a given profile. 73 // |args| is of the form: [ 74 // /*string*/ profileFilePath, 75 // /*string*/ newProfileIconURL 76 // /*string*/ newProfileName, 77 // ] 78 void SetProfileIconAndName(const base::ListValue* args); 79 80#if defined(ENABLE_SETTINGS_APP) 81 // Callback for the "switchAppListProfile" message. Asks the 82 // app_list_controller to change the profile registered for the AppList. 83 // |args| is of the form: [ {string} profileFilePath ] 84 void SwitchAppListProfile(const base::ListValue* args); 85#endif 86 87 // Callback for the 'profileIconSelectionChanged' message. Used to update the 88 // name in the manager profile dialog based on the selected icon. 89 void ProfileIconSelectionChanged(const base::ListValue* args); 90 91 // Callback for the "requestHasProfileShortcuts" message, which is called 92 // when editing an existing profile. Asks the profile shortcut manager whether 93 // the profile has shortcuts and gets the result in |OnHasProfileShortcuts()|. 94 // |args| is of the form: [ {string} profileFilePath ] 95 void RequestHasProfileShortcuts(const base::ListValue* args); 96 97 // Callback for the "RequestCreateProfileUpdate" message. 98 // Sends the email address of the signed-in user, or an empty string if the 99 // user is not signed in. Also sends information about whether managed users 100 // may be created. 101 void RequestCreateProfileUpdate(const base::ListValue* args); 102 103 // When the pref allowing managed-user creation changes, sends the new value 104 // to the UI. 105 void OnCreateManagedUserPrefChange(); 106 107 // Callback invoked from the profile manager indicating whether the profile 108 // being edited has any desktop shortcuts. 109 void OnHasProfileShortcuts(bool has_shortcuts); 110 111 // Callback for the "addProfileShortcut" message, which is called when editing 112 // an existing profile and the user clicks the "Add desktop shortcut" button. 113 // Adds a desktop shortcut for the profile. 114 void AddProfileShortcut(const base::ListValue* args); 115 116 // Callback for the "removeProfileShortcut" message, which is called when 117 // editing an existing profile and the user clicks the "Remove desktop 118 // shortcut" button. Removes the desktop shortcut for the profile. 119 void RemoveProfileShortcut(const base::ListValue* args); 120 121 // URL for the current profile's GAIA picture. 122 std::string gaia_picture_url_; 123 124 // Used to observe the preference that allows creating managed users, which 125 // can be changed by policy. 126 PrefChangeRegistrar pref_change_registrar_; 127 128 // For generating weak pointers to itself for callbacks. 129 base::WeakPtrFactory<ManageProfileHandler> weak_factory_; 130 131 DISALLOW_COPY_AND_ASSIGN(ManageProfileHandler); 132}; 133 134} // namespace options 135 136#endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_MANAGE_PROFILE_HANDLER_H_ 137