| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_ASH_APP_LIST_APPS_MODEL_BUILDER_H_ | |
| 6 #define CHROME_BROWSER_UI_ASH_APP_LIST_APPS_MODEL_BUILDER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/gtest_prod_util.h" | |
| 12 #include "content/public/browser/notification_observer.h" | |
| 13 #include "content/public/browser/notification_registrar.h" | |
| 14 #include "ui/app_list/app_list_model.h" | |
| 15 | |
| 16 class AppListController; | |
| 17 class Profile; | |
| 18 | |
| 19 class AppsModelBuilder : public content::NotificationObserver { | |
| 20 public: | |
| 21 AppsModelBuilder(Profile* profile, | |
| 22 app_list::AppListModel::Apps* model, | |
| 23 AppListController* controller); | |
| 24 virtual ~AppsModelBuilder(); | |
| 25 | |
| 26 // Populates the model. | |
| 27 void Build(); | |
| 28 | |
| 29 private: | |
| 30 typedef std::vector<app_list::AppListItemModel*> Apps; | |
| 31 | |
| 32 FRIEND_TEST_ALL_PREFIXES(AppsModelBuilderTest, GetExtensionApps); | |
| 33 FRIEND_TEST_ALL_PREFIXES(AppsModelBuilderTest, SortAndPopulateModel); | |
| 34 FRIEND_TEST_ALL_PREFIXES(AppsModelBuilderTest, InsertItemByTitle); | |
| 35 | |
| 36 void SortAndPopulateModel(const Apps& apps); | |
| 37 void InsertItemByTitle(app_list::AppListItemModel* app); | |
| 38 | |
| 39 void GetExtensionApps(Apps* apps); | |
| 40 void CreateSpecialApps(); | |
| 41 | |
| 42 // Returns the index of the application app with |app_id| in |model_|. If | |
| 43 // no match is found, returns -1. | |
| 44 int FindApp(const std::string& app_id); | |
| 45 | |
| 46 // 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 // is highlighted once per install notification. | |
| 49 void HighlightApp(); | |
| 50 | |
| 51 // content::NotificationObserver | |
| 52 virtual void Observe(int type, | |
| 53 const content::NotificationSource& source, | |
| 54 const content::NotificationDetails& details) OVERRIDE; | |
| 55 | |
| 56 Profile* profile_; | |
| 57 AppListController* controller_; | |
| 58 | |
| 59 // Sub apps model of AppListModel that represents apps grid view. | |
| 60 app_list::AppListModel::Apps* model_; | |
| 61 | |
| 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_; | |
| 67 | |
| 68 content::NotificationRegistrar registrar_; | |
| 69 | |
| 70 DISALLOW_COPY_AND_ASSIGN(AppsModelBuilder); | |
| 71 }; | |
| 72 | |
| 73 #endif // CHROME_BROWSER_UI_ASH_APP_LIST_APPS_MODEL_BUILDER_H_ | |
| OLD | NEW |