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 Profile; |
| 17 |
| 18 class AppsModelBuilder : public content::NotificationObserver { |
| 19 public: |
| 20 AppsModelBuilder(Profile* profile, app_list::AppListModel::Apps* model); |
| 21 virtual ~AppsModelBuilder(); |
| 22 |
| 23 // Populates the model. |
| 24 void Build(); |
| 25 |
| 26 private: |
| 27 typedef std::vector<app_list::AppListItemModel*> Apps; |
| 28 |
| 29 FRIEND_TEST_ALL_PREFIXES(AppsModelBuilderTest, GetExtensionApps); |
| 30 FRIEND_TEST_ALL_PREFIXES(AppsModelBuilderTest, SortAndPopulateModel); |
| 31 FRIEND_TEST_ALL_PREFIXES(AppsModelBuilderTest, InsertItemByTitle); |
| 32 |
| 33 void SortAndPopulateModel(const Apps& apps); |
| 34 void InsertItemByTitle(app_list::AppListItemModel* app); |
| 35 |
| 36 void GetExtensionApps(Apps* apps); |
| 37 void CreateSpecialApps(); |
| 38 |
| 39 // Returns the index of the application app with |app_id| in |model_|. If |
| 40 // no match is found, returns -1. |
| 41 int FindApp(const std::string& app_id); |
| 42 |
| 43 // Sets the application app with |highlight_app_id_| in |model_| as |
| 44 // highlighted. If such an app is found, reset |highlight_app_id_| so that it |
| 45 // is highlighted once per install notification. |
| 46 void HighlightApp(); |
| 47 |
| 48 // content::NotificationObserver |
| 49 virtual void Observe(int type, |
| 50 const content::NotificationSource& source, |
| 51 const content::NotificationDetails& details) OVERRIDE; |
| 52 |
| 53 Profile* profile_; |
| 54 |
| 55 // Sub apps model of AppListModel that represents apps grid view. |
| 56 app_list::AppListModel::Apps* model_; |
| 57 |
| 58 // Number of special apps in the model. Special apps index should be ranged |
| 59 // from [0, special_apps_count_ - 1]. |
| 60 int special_apps_count_; |
| 61 |
| 62 std::string highlight_app_id_; |
| 63 |
| 64 content::NotificationRegistrar registrar_; |
| 65 |
| 66 DISALLOW_COPY_AND_ASSIGN(AppsModelBuilder); |
| 67 }; |
| 68 |
| 69 #endif // CHROME_BROWSER_UI_ASH_APP_LIST_APPS_MODEL_BUILDER_H_ |
OLD | NEW |