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