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

Side by Side Diff: chrome/browser/ui/app_list/apps_model_builder.h

Issue 10957048: app_list: Use NTP ordering in ExtensionSorting to sort apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | Annotate | Revision Log
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_UI_APP_LIST_APPS_MODEL_BUILDER_H_ 5 #ifndef CHROME_BROWSER_UI_APP_LIST_APPS_MODEL_BUILDER_H_
6 #define CHROME_BROWSER_UI_APP_LIST_APPS_MODEL_BUILDER_H_ 6 #define CHROME_BROWSER_UI_APP_LIST_APPS_MODEL_BUILDER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector>
10 9
11 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
11 #include "chrome/browser/api/prefs/pref_change_registrar.h"
12 #include "content/public/browser/notification_observer.h" 12 #include "content/public/browser/notification_observer.h"
13 #include "content/public/browser/notification_registrar.h" 13 #include "content/public/browser/notification_registrar.h"
14 #include "ui/app_list/app_list_model.h" 14 #include "ui/app_list/app_list_model.h"
15 15
16 class AppListController; 16 class AppListController;
17 class ExtensionAppItem;
17 class Profile; 18 class Profile;
18 19
19 class AppsModelBuilder : public content::NotificationObserver { 20 class AppsModelBuilder : public content::NotificationObserver {
20 public: 21 public:
21 AppsModelBuilder(Profile* profile, 22 AppsModelBuilder(Profile* profile,
22 app_list::AppListModel::Apps* model, 23 app_list::AppListModel::Apps* model,
23 AppListController* controller); 24 AppListController* controller);
24 virtual ~AppsModelBuilder(); 25 virtual ~AppsModelBuilder();
25 26
26 // Populates the model. 27 // Populates the model.
27 void Build(); 28 void Build();
28 29
29 private: 30 private:
30 typedef std::vector<app_list::AppListItemModel*> Apps; 31 // Populates the model with apps.
32 void PopulateApps();
31 33
32 FRIEND_TEST_ALL_PREFIXES(AppsModelBuilderTest, GetExtensionApps); 34 // Gets start and end index of app items in the model.
33 FRIEND_TEST_ALL_PREFIXES(AppsModelBuilderTest, SortAndPopulateModel); 35 void GetAppsRange(size_t* start, size_t* end);
34 FRIEND_TEST_ALL_PREFIXES(AppsModelBuilderTest, InsertItemByTitle);
35 36
36 void SortAndPopulateModel(const Apps& apps); 37 // Re-sort apps in case app ordinal prefs are changed.
37 void InsertItemByTitle(app_list::AppListItemModel* app); 38 void ResortApps();
38 39
39 void GetExtensionApps(Apps* apps); 40 // Inserts an app based on app ordinal prefs.
40 void CreateSpecialApps(); 41 void InsertApp(ExtensionAppItem* app);
41 42
42 // Returns the index of the application app with |app_id| in |model_|. If 43 // Returns the index of the application app with |app_id| in |model_|. If
43 // no match is found, returns -1. 44 // no match is found, returns -1.
44 int FindApp(const std::string& app_id); 45 int FindApp(const std::string& app_id);
45 46
46 // Sets the application app with |highlight_app_id_| in |model_| as 47 // Sets the application app with |highlight_app_id_| in |model_| as
47 // highlighted. If such an app is found, reset |highlight_app_id_| so that it 48 // highlighted. If such an app is found, reset |highlight_app_id_| so that it
48 // is highlighted once per install notification. 49 // is highlighted once per install notification.
49 void HighlightApp(); 50 void HighlightApp();
50 51
52 // Returns app instance at given |index|.
53 ExtensionAppItem* GetAppAt(size_t index);
54
51 // content::NotificationObserver 55 // content::NotificationObserver
52 virtual void Observe(int type, 56 virtual void Observe(int type,
53 const content::NotificationSource& source, 57 const content::NotificationSource& source,
54 const content::NotificationDetails& details) OVERRIDE; 58 const content::NotificationDetails& details) OVERRIDE;
55 59
56 Profile* profile_; 60 Profile* profile_;
57 AppListController* controller_; 61 AppListController* controller_;
58 62
59 // Sub apps model of AppListModel that represents apps grid view. 63 // Sub apps model of AppListModel that represents apps grid view.
60 app_list::AppListModel::Apps* model_; 64 app_list::AppListModel::Apps* model_;
61 65
62 // Number of special apps in the model. Special apps index should be ranged
63 // from [0, special_apps_count_ - 1].
64 int special_apps_count_;
65
66 std::string highlight_app_id_; 66 std::string highlight_app_id_;
67 67
68 content::NotificationRegistrar registrar_; 68 content::NotificationRegistrar registrar_;
69 PrefChangeRegistrar pref_change_registrar_;
69 70
70 DISALLOW_COPY_AND_ASSIGN(AppsModelBuilder); 71 DISALLOW_COPY_AND_ASSIGN(AppsModelBuilder);
71 }; 72 };
72 73
73 #endif // CHROME_BROWSER_UI_APP_LIST_APPS_MODEL_BUILDER_H_ 74 #endif // CHROME_BROWSER_UI_APP_LIST_APPS_MODEL_BUILDER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/app_list/apps_model_builder.cc » ('j') | chrome/browser/ui/app_list/apps_model_builder.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698