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