OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/app_list/app_list_model_builder.h" | 5 #include "chrome/browser/ui/app_list/app_list_model_builder.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" | 9 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" |
8 #include "ui/app_list/app_list_item.h" | 10 #include "ui/app_list/app_list_item.h" |
9 #include "ui/app_list/app_list_model.h" | 11 #include "ui/app_list/app_list_model.h" |
10 | 12 |
11 AppListModelBuilder::AppListModelBuilder(AppListControllerDelegate* controller, | 13 AppListModelBuilder::AppListModelBuilder(AppListControllerDelegate* controller, |
12 const char* item_type) | 14 const char* item_type) |
13 : controller_(controller), | 15 : controller_(controller), |
14 item_type_(item_type) { | 16 item_type_(item_type) { |
15 } | 17 } |
16 | 18 |
(...skipping 18 matching lines...) Expand all Loading... |
35 DCHECK(!service_ && !profile_); | 37 DCHECK(!service_ && !profile_); |
36 model_ = model; | 38 model_ = model; |
37 model_->top_level_item_list()->AddObserver(this); | 39 model_->top_level_item_list()->AddObserver(this); |
38 profile_ = profile; | 40 profile_ = profile; |
39 | 41 |
40 BuildModel(); | 42 BuildModel(); |
41 } | 43 } |
42 | 44 |
43 void AppListModelBuilder::InsertApp(scoped_ptr<app_list::AppListItem> app) { | 45 void AppListModelBuilder::InsertApp(scoped_ptr<app_list::AppListItem> app) { |
44 if (service_) { | 46 if (service_) { |
45 service_->AddItem(app.Pass()); | 47 service_->AddItem(std::move(app)); |
46 return; | 48 return; |
47 } | 49 } |
48 model_->AddItem(app.Pass()); | 50 model_->AddItem(std::move(app)); |
49 } | 51 } |
50 | 52 |
51 const app_list::AppListSyncableService::SyncItem* | 53 const app_list::AppListSyncableService::SyncItem* |
52 AppListModelBuilder::GetSyncItem(const std::string& id) { | 54 AppListModelBuilder::GetSyncItem(const std::string& id) { |
53 return service_ ? service_->GetSyncItem(id) : nullptr; | 55 return service_ ? service_->GetSyncItem(id) : nullptr; |
54 } | 56 } |
55 | 57 |
56 app_list::AppListItem* AppListModelBuilder::GetAppItem(const std::string& id) { | 58 app_list::AppListItem* AppListModelBuilder::GetAppItem(const std::string& id) { |
57 app_list::AppListItem* item = model_->FindItem(id); | 59 app_list::AppListItem* item = model_->FindItem(id); |
58 if (item && item->GetItemType() != item_type_) { | 60 if (item && item->GetItemType() != item_type_) { |
59 VLOG(2) << "App Item matching id: " << id | 61 VLOG(2) << "App Item matching id: " << id |
60 << " has incorrect type: '" << item->GetItemType() << "'"; | 62 << " has incorrect type: '" << item->GetItemType() << "'"; |
61 return nullptr; | 63 return nullptr; |
62 } | 64 } |
63 return item; | 65 return item; |
64 } | 66 } |
OLD | NEW |