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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 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 #include "chrome/browser/ui/app_list/app_list_model_builder.h"
6
7 #include "chrome/browser/ui/app_list/app_list_syncable_service.h"
8 #include "ui/app_list/app_list_item.h"
9 #include "ui/app_list/app_list_model.h"
10
11 AppListModelBuilder::AppListModelBuilder(AppListControllerDelegate* controller,
12 const char* item_type)
13 : controller_(controller),
14 item_type_(item_type) {
15 }
16
17 AppListModelBuilder::~AppListModelBuilder() {
18 if (!service_)
19 model_->top_level_item_list()->RemoveObserver(this);
20 }
21
22 void AppListModelBuilder::InitializeWithService(
23 app_list::AppListSyncableService* service,
24 app_list::AppListModel* model) {
25 DCHECK(!service_ && !profile_);
26 model_ = model;
27 service_ = service;
28 profile_ = service->profile();
29
30 BuildModel();
31 }
32
33 void AppListModelBuilder::InitializeWithProfile(Profile* profile,
34 app_list::AppListModel* model) {
35 DCHECK(!service_ && !profile_);
36 model_ = model;
37 model_->top_level_item_list()->AddObserver(this);
38 profile_ = profile;
39
40 BuildModel();
41 }
42
43 void AppListModelBuilder::InsertApp(scoped_ptr<app_list::AppListItem> app) {
44 if (service_) {
45 service_->AddItem(app.Pass());
46 return;
47 }
48 model_->AddItem(app.Pass());
49 }
50
51 const app_list::AppListSyncableService::SyncItem*
52 AppListModelBuilder::GetSyncItem(const std::string& id) {
53 return service_ ? service_->GetSyncItem(id) : nullptr;
54 }
55
56 app_list::AppListItem* AppListModelBuilder::GetAppItem(const std::string& id) {
57 app_list::AppListItem* item = model_->FindItem(id);
58 if (item && item->GetItemType() != item_type_) {
59 VLOG(2) << "App Item matching id: " << id
60 << " has incorrect type: '" << item->GetItemType() << "'";
61 return nullptr;
62 }
63 return item;
64 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/app_list_model_builder.h ('k') | chrome/browser/ui/app_list/app_list_syncable_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698