Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: chrome/browser/profiles/avatar_menu.h

Issue 895803003: [Profiles] Remove the NotificationService from the ProfileInfoCache (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: maybe fix NTPLoginHandler tests Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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_PROFILES_AVATAR_MENU_H_ 5 #ifndef CHROME_BROWSER_PROFILES_AVATAR_MENU_H_
6 #define CHROME_BROWSER_PROFILES_AVATAR_MENU_H_ 6 #define CHROME_BROWSER_PROFILES_AVATAR_MENU_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/scoped_observer.h" 13 #include "base/scoped_observer.h"
14 #include "base/strings/string16.h" 14 #include "base/strings/string16.h"
15 #include "chrome/browser/profiles/profile_info_cache_observer.h"
15 #include "chrome/browser/profiles/profile_metrics.h" 16 #include "chrome/browser/profiles/profile_metrics.h"
16 #include "chrome/browser/ui/host_desktop.h" 17 #include "chrome/browser/ui/host_desktop.h"
17 #include "content/public/browser/notification_observer.h"
18 #include "content/public/browser/notification_registrar.h"
19 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
20 #include "content/public/browser/web_contents_observer.h" 19 #include "content/public/browser/web_contents_observer.h"
21 #include "ui/gfx/image/image.h" 20 #include "ui/gfx/image/image.h"
22 21
23 #if defined(ENABLE_SUPERVISED_USERS) 22 #if defined(ENABLE_SUPERVISED_USERS)
24 #include "chrome/browser/supervised_user/supervised_user_service_observer.h" 23 #include "chrome/browser/supervised_user/supervised_user_service_observer.h"
25 #endif 24 #endif
26 25
27 class AvatarMenuActions; 26 class AvatarMenuActions;
28 class AvatarMenuObserver; 27 class AvatarMenuObserver;
29 class Browser; 28 class Browser;
30 class Profile; 29 class Profile;
31 class ProfileInfoInterface; 30 class ProfileInfoInterface;
32 class ProfileList; 31 class ProfileList;
33 class SupervisedUserService; 32 class SupervisedUserService;
34 33
35 // This class represents the menu-like interface used to select profiles, 34 // This class represents the menu-like interface used to select profiles,
36 // such as the bubble that appears when the avatar icon is clicked in the 35 // such as the bubble that appears when the avatar icon is clicked in the
37 // browser window frame. This class will notify its observer when the backend 36 // browser window frame. This class will notify its observer when the backend
38 // data changes, and the view for this model should forward actions 37 // data changes, and the view for this model should forward actions
39 // back to it in response to user events. 38 // back to it in response to user events.
40 class AvatarMenu : 39 class AvatarMenu :
41 #if defined(ENABLE_SUPERVISED_USERS) 40 #if defined(ENABLE_SUPERVISED_USERS)
42 public SupervisedUserServiceObserver, 41 public SupervisedUserServiceObserver,
43 #endif 42 #endif
44 public content::NotificationObserver { 43 public ProfileInfoCacheObserver {
45 public: 44 public:
46 // Represents an item in the menu. 45 // Represents an item in the menu.
47 struct Item { 46 struct Item {
48 Item(size_t menu_index, size_t profile_index, const gfx::Image& icon); 47 Item(size_t menu_index, size_t profile_index, const gfx::Image& icon);
49 ~Item(); 48 ~Item();
50 49
51 // The icon to be displayed next to the item. 50 // The icon to be displayed next to the item.
52 gfx::Image icon; 51 gfx::Image icon;
53 52
54 // Whether or not the current browser is using this profile. 53 // Whether or not the current browser is using this profile.
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 // This menu is also used for the always-present Mac system menubar. If the 139 // This menu is also used for the always-present Mac system menubar. If the
141 // last active browser changes, the menu will need to reference that browser. 140 // last active browser changes, the menu will need to reference that browser.
142 void ActiveBrowserChanged(Browser* browser); 141 void ActiveBrowserChanged(Browser* browser);
143 142
144 // Returns true if the add profile link should be shown. 143 // Returns true if the add profile link should be shown.
145 bool ShouldShowAddNewProfileLink() const; 144 bool ShouldShowAddNewProfileLink() const;
146 145
147 // Returns true if the edit profile link should be shown. 146 // Returns true if the edit profile link should be shown.
148 bool ShouldShowEditProfileLink() const; 147 bool ShouldShowEditProfileLink() const;
149 148
150 // content::NotificationObserver: 149 private:
151 void Observe(int type, 150 // ProfileInfoCacheObserver:
152 const content::NotificationSource& source, 151 void OnProfileAdded(const base::FilePath& profile_path) override;
153 const content::NotificationDetails& details) override; 152 void OnProfileWasRemoved(const base::FilePath& profile_path,
153 const base::string16& profile_name) override;
154 void OnProfileNameChanged(const base::FilePath& profile_path,
155 const base::string16& old_profile_name) override;
156 void OnProfileUserNameChanged(const base::FilePath& profile_path) override;
157 void OnProfileAvatarChanged(const base::FilePath& profile_path) override;
158 void OnProfileHighResAvatarLoaded(
159 const base::FilePath& profile_path) override;
160 void OnProfileSigninRequiredChanged(
161 const base::FilePath& profile_path) override;
154 162
155 private:
156 #if defined(ENABLE_SUPERVISED_USERS) 163 #if defined(ENABLE_SUPERVISED_USERS)
157 // SupervisedUserServiceObserver: 164 // SupervisedUserServiceObserver:
158 void OnCustodianInfoChanged() override; 165 void OnCustodianInfoChanged() override;
159 #endif 166 #endif
160 167
168 // Rebuilds the menu and notifies any observers that an update occured.
169 void Update();
170
161 // The model that provides the list of menu items. 171 // The model that provides the list of menu items.
162 scoped_ptr<ProfileList> profile_list_; 172 scoped_ptr<ProfileList> profile_list_;
163 173
164 // The controller for avatar menu actions. 174 // The controller for avatar menu actions.
165 scoped_ptr<AvatarMenuActions> menu_actions_; 175 scoped_ptr<AvatarMenuActions> menu_actions_;
166 176
167 #if defined(ENABLE_SUPERVISED_USERS) 177 #if defined(ENABLE_SUPERVISED_USERS)
168 // Observes changes to a supervised user's custodian info. 178 // Observes changes to a supervised user's custodian info.
169 ScopedObserver<SupervisedUserService, SupervisedUserServiceObserver> 179 ScopedObserver<SupervisedUserService, SupervisedUserServiceObserver>
170 supervised_user_observer_; 180 supervised_user_observer_;
171 #endif 181 #endif
172 182
173 // The cache that provides the profile information. Weak. 183 // The cache that provides the profile information. Weak.
174 ProfileInfoInterface* profile_info_; 184 ProfileInfoInterface* profile_info_;
175 185
176 // The observer of this model, which is notified of changes. Weak. 186 // The observer of this model, which is notified of changes. Weak.
177 AvatarMenuObserver* observer_; 187 AvatarMenuObserver* observer_;
178 188
179 // Browser in which this avatar menu resides. Weak. 189 // Browser in which this avatar menu resides. Weak.
180 Browser* browser_; 190 Browser* browser_;
181 191
182 // Listens for notifications from the ProfileInfoCache.
183 content::NotificationRegistrar registrar_;
184
185 DISALLOW_COPY_AND_ASSIGN(AvatarMenu); 192 DISALLOW_COPY_AND_ASSIGN(AvatarMenu);
186 }; 193 };
187 194
188 #endif // CHROME_BROWSER_PROFILES_AVATAR_MENU_H_ 195 #endif // CHROME_BROWSER_PROFILES_AVATAR_MENU_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698