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

Side by Side Diff: ui/app_list/app_list_model.h

Issue 20656002: Add profile selector menu to app list. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, remove dead code in app_list_menu_views, add ui assets Created 7 years, 3 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 UI_APP_LIST_APP_LIST_MODEL_H_ 5 #ifndef UI_APP_LIST_APP_LIST_MODEL_H_
6 #define UI_APP_LIST_APP_LIST_MODEL_H_ 6 #define UI_APP_LIST_APP_LIST_MODEL_H_
7 7
8 #include <vector>
9
8 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/files/file_path.h"
9 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
10 #include "base/observer_list.h" 13 #include "base/observer_list.h"
11 #include "base/strings/string16.h" 14 #include "base/strings/string16.h"
12 #include "ui/app_list/app_list_export.h" 15 #include "ui/app_list/app_list_export.h"
13 #include "ui/base/models/list_model.h" 16 #include "ui/base/models/list_model.h"
14 17
15 namespace app_list { 18 namespace app_list {
16 19
17 class AppListItemModel; 20 class AppListItemModel;
18 class AppListModelObserver; 21 class AppListModelObserver;
19 class SearchBoxModel; 22 class SearchBoxModel;
20 class SearchResult; 23 class SearchResult;
21 24
22 // Master model of app list that consists of three sub models: Apps, 25 // Master model of app list that consists of three sub models: Apps,
23 // SearchBoxModel and SearchResults. The Apps sub model owns a list of 26 // SearchBoxModel and SearchResults. The Apps sub model owns a list of
24 // AppListItemModel and is displayed in the grid view. SearchBoxModel is 27 // AppListItemModel and is displayed in the grid view. SearchBoxModel is
25 // the model for SearchBoxView. SearchResults owns a list of SearchResult. 28 // the model for SearchBoxView. SearchResults owns a list of SearchResult.
26 class APP_LIST_EXPORT AppListModel { 29 class APP_LIST_EXPORT AppListModel {
27 public: 30 public:
31 // A user of the app list.
32 struct User {
33 // Whether or not the app list is currently instantiated for this user.
koz (OOO until 15th September) 2013/09/09 22:58:07 Maybe "Whether or not this user is the current use
calamity 2013/09/10 22:50:46 Done.
34 bool active;
tapted 2013/09/10 00:29:26 You should probably initialize |active| to somethi
calamity 2013/09/10 22:50:46 Done.
35
36 // The name of this user.
37 string16 name;
tapted 2013/09/10 00:29:26 nit: base::string16 unless there's a prevailing co
calamity 2013/09/10 22:50:46 Done.
38
39 // The email address of this user.
40 string16 email;
41
42 // The path to this user's profile directory.
43 base::FilePath profile_path;
44 };
45
28 enum Status { 46 enum Status {
29 STATUS_NORMAL, 47 STATUS_NORMAL,
30 STATUS_SYNCING, // Syncing apps or installing synced apps. 48 STATUS_SYNCING, // Syncing apps or installing synced apps.
31 }; 49 };
32 50
33 typedef ui::ListModel<AppListItemModel> Apps; 51 typedef ui::ListModel<AppListItemModel> Apps;
34 typedef ui::ListModel<SearchResult> SearchResults; 52 typedef ui::ListModel<SearchResult> SearchResults;
53 typedef std::vector<User*> Users;
koz (OOO until 15th September) 2013/09/09 22:58:07 You should just use User here, not User*. This is
calamity 2013/09/10 22:50:46 Done.
35 54
36 AppListModel(); 55 AppListModel();
37 ~AppListModel(); 56 ~AppListModel();
38 57
39 void AddObserver(AppListModelObserver* observer); 58 void AddObserver(AppListModelObserver* observer);
40 void RemoveObserver(AppListModelObserver* observer); 59 void RemoveObserver(AppListModelObserver* observer);
41 60
42 void SetStatus(Status status); 61 void SetStatus(Status status);
43 void SetCurrentUser(const base::string16& current_user_name, 62 void SetUsers(const Users& profile_menu_items);
44 const base::string16& current_user_email);
45 void SetSignedIn(bool signed_in); 63 void SetSignedIn(bool signed_in);
46 64
47 Apps* apps() { return apps_.get(); } 65 Apps* apps() { return apps_.get(); }
48 SearchBoxModel* search_box() { return search_box_.get(); } 66 SearchBoxModel* search_box() { return search_box_.get(); }
49 SearchResults* results() { return results_.get(); } 67 SearchResults* results() { return results_.get(); }
50 Status status() const { return status_; } 68 Status status() const { return status_; }
51 bool signed_in() const { return signed_in_; } 69 bool signed_in() const { return signed_in_; }
52 const base::string16& current_user_name() const { return current_user_name_; } 70
53 const base::string16& current_user_email() const { 71 const Users& users() const {
54 return current_user_email_; 72 return users_;
55 } 73 }
56 74
57 private: 75 private:
58 scoped_ptr<Apps> apps_; 76 scoped_ptr<Apps> apps_;
59 77
60 scoped_ptr<SearchBoxModel> search_box_; 78 scoped_ptr<SearchBoxModel> search_box_;
61 scoped_ptr<SearchResults> results_; 79 scoped_ptr<SearchResults> results_;
62 80
63 base::string16 current_user_name_; 81 base::string16 current_user_name_;
tapted 2013/09/10 00:29:26 is this (and current_user_email_) still needed?
calamity 2013/09/10 22:50:46 Removed.
64 base::string16 current_user_email_; 82 base::string16 current_user_email_;
65 bool signed_in_; 83 bool signed_in_;
84 Users users_;
tapted 2013/09/10 00:29:26 nit: maybe move above signed_in_ -- it's nice to k
calamity 2013/09/10 22:50:46 Done.
66 85
67 Status status_; 86 Status status_;
68 ObserverList<AppListModelObserver> observers_; 87 ObserverList<AppListModelObserver> observers_;
69 88
70 DISALLOW_COPY_AND_ASSIGN(AppListModel); 89 DISALLOW_COPY_AND_ASSIGN(AppListModel);
71 }; 90 };
72 91
73 } // namespace app_list 92 } // namespace app_list
74 93
75 #endif // UI_APP_LIST_APP_LIST_MODEL_H_ 94 #endif // UI_APP_LIST_APP_LIST_MODEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698