Chromium Code Reviews| Index: chrome/browser/ui/app_list/app_list_model_builder.h |
| diff --git a/chrome/browser/ui/app_list/app_list_model_builder.h b/chrome/browser/ui/app_list/app_list_model_builder.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..35077e6dbfa77869d49fe9370bc5acd8b2805627 |
| --- /dev/null |
| +++ b/chrome/browser/ui/app_list/app_list_model_builder.h |
| @@ -0,0 +1,72 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_UI_APP_LIST_APP_LIST_MODEL_BUILDER_H_ |
| +#define CHROME_BROWSER_UI_APP_LIST_APP_LIST_MODEL_BUILDER_H_ |
| + |
| +#include <string> |
| + |
| +#include "base/macros.h" |
| +#include "chrome/browser/ui/app_list/app_list_syncable_service.h" |
| +#include "ui/app_list/app_list_item_list_observer.h" |
| +#include "ui/app_list/app_list_model.h" |
| + |
| +class AppListControllerDelegate; |
| +class Profile; |
| + |
| +// This abstract class populates and maintains the given |model| with |
| +// information from |profile| for the specific item type. |
| +class AppListModelBuilder : public app_list::AppListItemListObserver { |
| + public: |
| + explicit AppListModelBuilder(AppListControllerDelegate* controller, |
|
jochen (gone - plz use gerrit)
2015/12/03 10:25:39
no explicit, can you clarify whether it takes owne
khmel1
2015/12/03 12:34:49
Removed explicit (left from legacy code with one p
|
| + const char* item_type); |
| + ~AppListModelBuilder() override; |
| + |
| + // Initialize to use app-list sync and sets |service_| to |service|. |
|
jochen (gone - plz use gerrit)
2015/12/03 10:25:39
this comment should tell whether it takes ownershi
khmel1
2015/12/03 12:34:49
Done.
|
| + void InitializeWithService(app_list::AppListSyncableService* service, |
| + app_list::AppListModel* model); |
| + |
| + // Initialize to use extension sync and sets |service_| to NULL. Used in |
|
jochen (gone - plz use gerrit)
2015/12/03 10:25:39
nullptr
khmel1
2015/12/03 12:34:49
Done.
|
| + // tests and when AppList sync is not enabled. |
| + void InitializeWithProfile(Profile* profile, app_list::AppListModel* model); |
| + |
| + protected: |
| + // Builds the model with the current profile. |
| + virtual void BuildModel() = 0; |
| + |
| + app_list::AppListSyncableService* service() { return service_; } |
| + |
| + Profile* profile() { return profile_; } |
| + |
| + AppListControllerDelegate* controller() { return controller_; } |
| + |
| + app_list::AppListModel* model() { return model_; } |
| + |
| + // Inserts an app based on app ordinal prefs. |
| + void InsertApp(scoped_ptr<app_list::AppListItem> app); |
| + |
| + const app_list::AppListSyncableService::SyncItem* GetSyncItem( |
| + const std::string& id); |
| + |
| + // Returns app instance matching |id| or NULL. |
| + app_list::AppListItem* GetAppItem(const std::string& id); |
| + |
| + private: |
| + // Unowned pointers to the service that owns this and associated profile. |
| + app_list::AppListSyncableService* service_ = nullptr; |
| + Profile* profile_ = nullptr; |
| + |
| + // Unowned pointer to the app list controller. |
| + AppListControllerDelegate* controller_; |
| + |
| + // Unowned pointer to the app list model. |
| + app_list::AppListModel* model_ = nullptr; |
| + |
| + // Global constant defined for each item type. |
| + const char* item_type_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(AppListModelBuilder); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_MODEL_BUILDER_H_ |