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

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

Issue 20656002: Add profile selector menu to app list. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rework Created 7 years, 5 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_MODEL_H_ 5 #ifndef CHROME_BROWSER_PROFILES_AVATAR_MENU_MODEL_H_
6 #define CHROME_BROWSER_PROFILES_AVATAR_MENU_MODEL_H_ 6 #define CHROME_BROWSER_PROFILES_AVATAR_MENU_MODEL_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/strings/string16.h" 12 #include "base/strings/string16.h"
13 #include "chrome/browser/profiles/profile_metrics.h" 13 #include "chrome/browser/profiles/profile_metrics.h"
14 #include "content/public/browser/notification_observer.h" 14 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h" 15 #include "content/public/browser/notification_registrar.h"
16 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
17 #include "content/public/browser/web_contents_observer.h" 17 #include "content/public/browser/web_contents_observer.h"
18 #include "ui/gfx/image/image.h" 18 #include "ui/base/models/avatar_menu_item_model.h"
tapted 2013/07/29 01:59:10 nit: you probably keep a forward dec for GetManage
calamity 2013/07/30 08:42:34 Done.
19 19
20 class AvatarMenuModelObserver; 20 class AvatarMenuModelObserver;
21 class Browser; 21 class Browser;
22 class Profile; 22 class Profile;
23 class ProfileInfoInterface; 23 class ProfileInfoInterface;
24 24
25 // This class is the model for the menu-like interface that appears when the 25 // This class is the model for the menu-like interface that appears when the
26 // avatar icon is clicked in the browser window frame. This class will notify 26 // avatar icon is clicked in the browser window frame. This class will notify
27 // its observer when the backend data changes, and the controller/view for this 27 // its observer when the backend data changes, and the controller/view for this
28 // model should forward actions back to it in response to user events. 28 // model should forward actions back to it in response to user events.
29 class AvatarMenuModel : public content::NotificationObserver { 29 class AvatarMenuModel : public content::NotificationObserver {
30 public: 30 public:
31 // Represents an item in the menu.
32 struct Item {
33 Item(size_t model_index, const gfx::Image& icon);
34 ~Item();
35
36 // The icon to be displayed next to the item.
37 gfx::Image icon;
38
39 // Whether or not the current browser is using this profile.
40 bool active;
41
42 // The name of this profile.
43 string16 name;
44
45 // A string representing the sync state of the profile.
46 string16 sync_state;
47
48 // Whether or not the current profile is signed in. If true, |sync_state| is
49 // expected to be the email of the signed in user.
50 bool signed_in;
51
52 // Whether or not the current profile requires sign-in before use.
53 bool signin_required;
54
55 // The index in the |profile_cache| that this Item represents.
56 size_t model_index;
57 };
58
59 // Constructor. |observer| can be NULL. |browser| can be NULL and a new one 31 // Constructor. |observer| can be NULL. |browser| can be NULL and a new one
60 // will be created if an action requires it. 32 // will be created if an action requires it.
61 AvatarMenuModel(ProfileInfoInterface* profile_cache, 33 AvatarMenuModel(ProfileInfoInterface* profile_cache,
62 AvatarMenuModelObserver* observer, 34 AvatarMenuModelObserver* observer,
63 Browser* browser); 35 Browser* browser);
64 virtual ~AvatarMenuModel(); 36 virtual ~AvatarMenuModel();
65 37
66 // Actions performed by the view that the controller forwards back to the 38 // Actions performed by the view that the controller forwards back to the
67 // model: 39 // model:
68 // Opens a Browser with the specified profile in response to the user 40 // Opens a Browser with the specified profile in response to the user
(...skipping 11 matching lines...) Expand all
80 // Gets the path associated with the profile at |index|. 52 // Gets the path associated with the profile at |index|.
81 base::FilePath GetProfilePath(size_t index); 53 base::FilePath GetProfilePath(size_t index);
82 54
83 // Gets the number of profiles. 55 // Gets the number of profiles.
84 size_t GetNumberOfItems(); 56 size_t GetNumberOfItems();
85 57
86 // Returns the index of the active profile. 58 // Returns the index of the active profile.
87 size_t GetActiveProfileIndex(); 59 size_t GetActiveProfileIndex();
88 60
89 // Gets the an Item at a specified index. 61 // Gets the an Item at a specified index.
90 const Item& GetItemAt(size_t index); 62 const AvatarMenuItemModel& GetItemAt(size_t index);
91 63
92 // Returns true if the add profile link should be shown. 64 // Returns true if the add profile link should be shown.
93 bool ShouldShowAddNewProfileLink() const; 65 bool ShouldShowAddNewProfileLink() const;
94 66
95 // Returns information about a managed user which will be displayed in the 67 // Returns information about a managed user which will be displayed in the
96 // avatar menu. If the profile does not belong to a managed user, an empty 68 // avatar menu. If the profile does not belong to a managed user, an empty
97 // string will be returned. 69 // string will be returned.
98 base::string16 GetManagedUserInformation() const; 70 base::string16 GetManagedUserInformation() const;
99 71
100 // Returns the icon for the managed user which will be displayed in the 72 // Returns the icon for the managed user which will be displayed in the
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 // The cache that provides the profile information. Weak. 106 // The cache that provides the profile information. Weak.
135 ProfileInfoInterface* profile_info_; 107 ProfileInfoInterface* profile_info_;
136 108
137 // The observer of this model, which is notified of changes. Weak. 109 // The observer of this model, which is notified of changes. Weak.
138 AvatarMenuModelObserver* observer_; 110 AvatarMenuModelObserver* observer_;
139 111
140 // Browser in which this avatar menu resides. Weak. 112 // Browser in which this avatar menu resides. Weak.
141 Browser* browser_; 113 Browser* browser_;
142 114
143 // List of built "menu items." 115 // List of built "menu items."
144 std::vector<Item*> items_; 116 std::vector<AvatarMenuItemModel*> items_;
145 117
146 // Listens for notifications from the ProfileInfoCache. 118 // Listens for notifications from the ProfileInfoCache.
147 content::NotificationRegistrar registrar_; 119 content::NotificationRegistrar registrar_;
148 120
149 // Special "override" logout URL used to let tests work. 121 // Special "override" logout URL used to let tests work.
150 std::string logout_override_; 122 std::string logout_override_;
151 123
152 DISALLOW_COPY_AND_ASSIGN(AvatarMenuModel); 124 DISALLOW_COPY_AND_ASSIGN(AvatarMenuModel);
153 }; 125 };
154 126
155 #endif // CHROME_BROWSER_PROFILES_AVATAR_MENU_MODEL_H_ 127 #endif // CHROME_BROWSER_PROFILES_AVATAR_MENU_MODEL_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/profiles/avatar_menu_model.cc » ('j') | chrome/browser/ui/app_list/app_list_controller_delegate.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698