OLD | NEW |
---|---|
(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_) { | |
jochen (gone - plz use gerrit)
2015/12/03 10:25:39
no {} for single line body
khmel1
2015/12/03 12:34:49
Done.
| |
19 model_->top_level_item_list()->RemoveObserver(this); | |
20 } | |
21 } | |
22 | |
23 void AppListModelBuilder::InitializeWithService( | |
24 app_list::AppListSyncableService* service, | |
25 app_list::AppListModel* model) { | |
26 DCHECK(!service_ && !profile_); | |
27 model_ = model; | |
28 service_ = service; | |
29 profile_ = service->profile(); | |
30 | |
31 BuildModel(); | |
32 } | |
33 | |
34 void AppListModelBuilder::InitializeWithProfile(Profile* profile, | |
35 app_list::AppListModel* model) { | |
36 DCHECK(!service_ && !profile_); | |
37 model_ = model; | |
38 model_->top_level_item_list()->AddObserver(this); | |
39 profile_ = profile; | |
40 | |
41 BuildModel(); | |
42 } | |
43 | |
44 void AppListModelBuilder::InsertApp(scoped_ptr<app_list::AppListItem> app) { | |
45 if (service_) { | |
46 service_->AddItem(app.Pass()); | |
47 return; | |
48 } | |
49 model_->AddItem(app.Pass()); | |
50 } | |
51 | |
52 const app_list::AppListSyncableService::SyncItem* | |
53 AppListModelBuilder::GetSyncItem(const std::string& id) { | |
54 return service_ ? service_->GetSyncItem(id) : nullptr; | |
55 } | |
56 | |
57 app_list::AppListItem* AppListModelBuilder::GetAppItem(const std::string& id) { | |
58 app_list::AppListItem* item = model_->FindItem(id); | |
59 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
| |
60 << "App Item matching id: " << id | |
61 << " has incorrect type: '" << item->GetItemType() << "'"; | |
62 return item; | |
63 } | |
OLD | NEW |