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

Unified Diff: chrome/browser/ui/app_list/app_list_model_builder.h

Issue 1413153007: arc-app-launcher: Minimal support for ARC app launcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added missing links to BUILD.gn Created 5 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/BUILD.gn ('k') | chrome/browser/ui/app_list/app_list_model_builder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..0b53ea1d0d320d74a1fed733ee8d92379ddf1995
--- /dev/null
+++ b/chrome/browser/ui/app_list/app_list_model_builder.h
@@ -0,0 +1,75 @@
+// 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:
+ // |controller| is owned by implementation of AppListService.
+ AppListModelBuilder(AppListControllerDelegate* controller,
+ const char* item_type);
+ ~AppListModelBuilder() override;
+
+ // Initialize to use app-list sync and sets |service_| to |service|.
+ // |service| is the owner of this instance and |model|.
+ void InitializeWithService(app_list::AppListSyncableService* service,
+ app_list::AppListModel* model);
+
+ // Initialize to use extension sync and sets |service_| to nullptr. Used in
+ // tests and when AppList sync is not enabled.
+ // app_list::AppListSyncableService is the owner of |model|
+ 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 nullptr.
+ 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 model.
+ app_list::AppListModel* model_ = nullptr;
+
+ // Unowned pointer to the app list controller.
+ AppListControllerDelegate* controller_;
+
+ // 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_
« no previous file with comments | « chrome/browser/ui/BUILD.gn ('k') | chrome/browser/ui/app_list/app_list_model_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698