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> | 7 #include <utility> |
8 | 8 |
9 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" | 9 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" |
10 #include "ui/app_list/app_list_item.h" | 10 #include "ui/app_list/app_list_item.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 void AppListModelBuilder::InitializeWithProfile(Profile* profile, | 35 void AppListModelBuilder::InitializeWithProfile(Profile* profile, |
36 app_list::AppListModel* model) { | 36 app_list::AppListModel* model) { |
37 DCHECK(!service_ && !profile_); | 37 DCHECK(!service_ && !profile_); |
38 model_ = model; | 38 model_ = model; |
39 model_->top_level_item_list()->AddObserver(this); | 39 model_->top_level_item_list()->AddObserver(this); |
40 profile_ = profile; | 40 profile_ = profile; |
41 | 41 |
42 BuildModel(); | 42 BuildModel(); |
43 } | 43 } |
44 | 44 |
45 void AppListModelBuilder::InsertApp(scoped_ptr<app_list::AppListItem> app) { | 45 void AppListModelBuilder::InsertApp( |
| 46 std::unique_ptr<app_list::AppListItem> app) { |
46 if (service_) { | 47 if (service_) { |
47 service_->AddItem(std::move(app)); | 48 service_->AddItem(std::move(app)); |
48 return; | 49 return; |
49 } | 50 } |
50 model_->AddItem(std::move(app)); | 51 model_->AddItem(std::move(app)); |
51 } | 52 } |
52 | 53 |
53 void AppListModelBuilder::RemoveApp(const std::string& id) { | 54 void AppListModelBuilder::RemoveApp(const std::string& id) { |
54 if (service_) { | 55 if (service_) { |
55 service_->RemoveUninstalledItem(id); | 56 service_->RemoveUninstalledItem(id); |
56 return; | 57 return; |
57 } | 58 } |
58 model_->DeleteUninstalledItem(id); | 59 model_->DeleteUninstalledItem(id); |
59 } | 60 } |
60 | 61 |
61 const app_list::AppListSyncableService::SyncItem* | 62 const app_list::AppListSyncableService::SyncItem* |
62 AppListModelBuilder::GetSyncItem(const std::string& id) { | 63 AppListModelBuilder::GetSyncItem(const std::string& id) { |
63 return service_ ? service_->GetSyncItem(id) : nullptr; | 64 return service_ ? service_->GetSyncItem(id) : nullptr; |
64 } | 65 } |
65 | 66 |
66 app_list::AppListItem* AppListModelBuilder::GetAppItem(const std::string& id) { | 67 app_list::AppListItem* AppListModelBuilder::GetAppItem(const std::string& id) { |
67 app_list::AppListItem* item = model_->FindItem(id); | 68 app_list::AppListItem* item = model_->FindItem(id); |
68 if (item && item->GetItemType() != item_type_) { | 69 if (item && item->GetItemType() != item_type_) { |
69 VLOG(2) << "App Item matching id: " << id | 70 VLOG(2) << "App Item matching id: " << id |
70 << " has incorrect type: '" << item->GetItemType() << "'"; | 71 << " has incorrect type: '" << item->GetItemType() << "'"; |
71 return nullptr; | 72 return nullptr; |
72 } | 73 } |
73 return item; | 74 return item; |
74 } | 75 } |
OLD | NEW |