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

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

Issue 1413153007: arc-app-launcher: Minimal support for ARC app launcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased 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
Index: chrome/browser/ui/app_list/app_list_model_builder.cc
diff --git a/chrome/browser/ui/app_list/app_list_model_builder.cc b/chrome/browser/ui/app_list/app_list_model_builder.cc
new file mode 100644
index 0000000000000000000000000000000000000000..bb84cfc198d4d05e8e120a63e417dad15261414c
--- /dev/null
+++ b/chrome/browser/ui/app_list/app_list_model_builder.cc
@@ -0,0 +1,63 @@
+// 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.
+
+#include "chrome/browser/ui/app_list/app_list_model_builder.h"
+
+#include "chrome/browser/ui/app_list/app_list_syncable_service.h"
+#include "ui/app_list/app_list_item.h"
+#include "ui/app_list/app_list_model.h"
+
+AppListModelBuilder::AppListModelBuilder(AppListControllerDelegate* controller,
+ const char* item_type)
+ : controller_(controller),
+ item_type_(item_type) {
+}
+
+AppListModelBuilder::~AppListModelBuilder() {
+ if (!service_) {
jochen (gone - plz use gerrit) 2015/12/03 10:25:39 no {} for single line body
khmel1 2015/12/03 12:34:49 Done.
+ model_->top_level_item_list()->RemoveObserver(this);
+ }
+}
+
+void AppListModelBuilder::InitializeWithService(
+ app_list::AppListSyncableService* service,
+ app_list::AppListModel* model) {
+ DCHECK(!service_ && !profile_);
+ model_ = model;
+ service_ = service;
+ profile_ = service->profile();
+
+ BuildModel();
+}
+
+void AppListModelBuilder::InitializeWithProfile(Profile* profile,
+ app_list::AppListModel* model) {
+ DCHECK(!service_ && !profile_);
+ model_ = model;
+ model_->top_level_item_list()->AddObserver(this);
+ profile_ = profile;
+
+ BuildModel();
+}
+
+void AppListModelBuilder::InsertApp(scoped_ptr<app_list::AppListItem> app) {
+ if (service_) {
+ service_->AddItem(app.Pass());
+ return;
+ }
+ model_->AddItem(app.Pass());
+}
+
+const app_list::AppListSyncableService::SyncItem*
+ AppListModelBuilder::GetSyncItem(const std::string& id) {
+ return service_ ? service_->GetSyncItem(id) : nullptr;
+}
+
+app_list::AppListItem* AppListModelBuilder::GetAppItem(const std::string& id) {
+ app_list::AppListItem* item = model_->FindItem(id);
+ LOG_IF(ERROR, item && item->GetItemType() != item_type_)
jochen (gone - plz use gerrit) 2015/12/03 10:25:39 VLOG() or DVLOG(). why are we returning the item
khmel1 2015/12/03 12:34:49 Good point. Return nullptr in this case
+ << "App Item matching id: " << id
+ << " has incorrect type: '" << item->GetItemType() << "'";
+ return item;
+}

Powered by Google App Engine
This is Rietveld 408576698