Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| 9 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
| 13 #include "base/strings/string16.h" | |
| 11 #include "ui/app_list/app_list_export.h" | 14 #include "ui/app_list/app_list_export.h" |
| 12 #include "ui/base/models/list_model.h" | 15 #include "ui/base/models/list_model.h" |
| 13 | 16 |
| 17 namespace ui{ | |
|
tapted
2013/07/31 05:43:53
nit: space before {
calamity
2013/08/01 08:35:45
Done.
| |
| 18 struct AvatarMenuItemModel; | |
| 19 } | |
| 20 | |
| 14 namespace app_list { | 21 namespace app_list { |
| 15 | 22 |
| 16 class AppListItemModel; | 23 class AppListItemModel; |
| 17 class AppListModelObserver; | 24 class AppListModelObserver; |
| 18 class SearchBoxModel; | 25 class SearchBoxModel; |
| 19 class SearchResult; | 26 class SearchResult; |
| 20 | 27 |
| 21 // Master model of app list that consists of three sub models: Apps, | 28 // Master model of app list that consists of three sub models: Apps, |
| 22 // SearchBoxModel and SearchResults. The Apps sub model owns a list of | 29 // SearchBoxModel and SearchResults. The Apps sub model owns a list of |
| 23 // AppListItemModel and is displayed in the grid view. SearchBoxModel is | 30 // AppListItemModel and is displayed in the grid view. SearchBoxModel is |
| 24 // the model for SearchBoxView. SearchResults owns a list of SearchResult. | 31 // the model for SearchBoxView. SearchResults owns a list of SearchResult. |
| 25 class APP_LIST_EXPORT AppListModel { | 32 class APP_LIST_EXPORT AppListModel { |
| 26 public: | 33 public: |
| 27 enum Status { | 34 enum Status { |
| 28 STATUS_NORMAL, | 35 STATUS_NORMAL, |
| 29 STATUS_SYNCING, // Syncing apps or installing synced apps. | 36 STATUS_SYNCING, // Syncing apps or installing synced apps. |
| 30 }; | 37 }; |
| 31 | 38 |
| 32 typedef ui::ListModel<AppListItemModel> Apps; | 39 typedef ui::ListModel<AppListItemModel> Apps; |
| 33 typedef ui::ListModel<SearchResult> SearchResults; | 40 typedef ui::ListModel<SearchResult> SearchResults; |
| 34 | 41 |
| 35 AppListModel(); | 42 AppListModel(); |
| 36 ~AppListModel(); | 43 ~AppListModel(); |
| 37 | 44 |
| 38 void AddObserver(AppListModelObserver* observer); | 45 void AddObserver(AppListModelObserver* observer); |
| 39 void RemoveObserver(AppListModelObserver* observer); | 46 void RemoveObserver(AppListModelObserver* observer); |
| 40 | 47 |
| 41 void SetStatus(Status status); | 48 void SetStatus(Status status); |
| 49 void SetCurrentUser(string16 user_name, string16 user_email); | |
|
tapted
2013/07/31 05:43:53
nit: const-reference args for strings
calamity
2013/08/01 08:35:45
Done.
| |
| 42 | 50 |
| 43 Apps* apps() { return apps_.get(); } | 51 Apps* apps() { return apps_.get(); } |
| 44 SearchBoxModel* search_box() { return search_box_.get(); } | 52 SearchBoxModel* search_box() { return search_box_.get(); } |
| 45 SearchResults* results() { return results_.get(); } | 53 SearchResults* results() { return results_.get(); } |
| 46 Status status() const { return status_; } | 54 Status status() const { return status_; } |
| 47 | 55 |
| 56 string16 current_user_name() { return current_user_name_; } | |
|
tapted
2013/07/31 05:43:53
I've seen new code using base::string16 a lot more
calamity
2013/08/01 08:35:45
Done.
| |
| 57 string16 current_user_email() { return current_user_email_; } | |
|
tapted
2013/07/31 05:43:53
Also, most app list code returns const-references
calamity
2013/08/01 08:35:45
Done.
| |
| 58 | |
| 59 std::vector<ui::AvatarMenuItemModel*>& avatar_menu_items() { | |
| 60 return avatar_menu_items_; | |
| 61 } | |
| 62 | |
| 48 private: | 63 private: |
| 49 scoped_ptr<Apps> apps_; | 64 scoped_ptr<Apps> apps_; |
| 50 | 65 |
| 51 scoped_ptr<SearchBoxModel> search_box_; | 66 scoped_ptr<SearchBoxModel> search_box_; |
| 52 scoped_ptr<SearchResults> results_; | 67 scoped_ptr<SearchResults> results_; |
| 53 | 68 |
| 69 string16 current_user_name_; | |
| 70 string16 current_user_email_; | |
| 71 std::vector<ui::AvatarMenuItemModel*> avatar_menu_items_; | |
|
tapted
2013/07/31 05:43:53
a thought: you could also use a ScopedVector - not
calamity
2013/08/01 08:35:45
Also might be worth using a ui::ListModel since it
| |
| 72 | |
| 54 Status status_; | 73 Status status_; |
| 55 ObserverList<AppListModelObserver> observers_; | 74 ObserverList<AppListModelObserver> observers_; |
| 56 | 75 |
| 57 DISALLOW_COPY_AND_ASSIGN(AppListModel); | 76 DISALLOW_COPY_AND_ASSIGN(AppListModel); |
| 58 }; | 77 }; |
| 59 | 78 |
| 60 } // namespace app_list | 79 } // namespace app_list |
| 61 | 80 |
| 62 #endif // UI_APP_LIST_APP_LIST_MODEL_H_ | 81 #endif // UI_APP_LIST_APP_LIST_MODEL_H_ |
| OLD | NEW |