| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 void AppListModelBuilder::InsertApp( | 45 void AppListModelBuilder::InsertApp( |
| 46 std::unique_ptr<app_list::AppListItem> app) { | 46 std::unique_ptr<app_list::AppListItem> app) { |
| 47 if (service_) { | 47 if (service_) { |
| 48 service_->AddItem(std::move(app)); | 48 service_->AddItem(std::move(app)); |
| 49 return; | 49 return; |
| 50 } | 50 } |
| 51 model_->AddItem(std::move(app)); | 51 model_->AddItem(std::move(app)); |
| 52 } | 52 } |
| 53 | 53 |
| 54 void AppListModelBuilder::RemoveApp(const std::string& id) { | 54 void AppListModelBuilder::RemoveApp(const std::string& id, |
| 55 if (service_) { | 55 bool unsynced_change) { |
| 56 if (!unsynced_change && service_) { |
| 56 service_->RemoveUninstalledItem(id); | 57 service_->RemoveUninstalledItem(id); |
| 57 return; | 58 return; |
| 58 } | 59 } |
| 59 model_->DeleteUninstalledItem(id); | 60 model_->DeleteUninstalledItem(id); |
| 60 } | 61 } |
| 61 | 62 |
| 62 const app_list::AppListSyncableService::SyncItem* | 63 const app_list::AppListSyncableService::SyncItem* |
| 63 AppListModelBuilder::GetSyncItem(const std::string& id) { | 64 AppListModelBuilder::GetSyncItem(const std::string& id) { |
| 64 return service_ ? service_->GetSyncItem(id) : nullptr; | 65 return service_ ? service_->GetSyncItem(id) : nullptr; |
| 65 } | 66 } |
| 66 | 67 |
| 67 app_list::AppListItem* AppListModelBuilder::GetAppItem(const std::string& id) { | 68 app_list::AppListItem* AppListModelBuilder::GetAppItem(const std::string& id) { |
| 68 app_list::AppListItem* item = model_->FindItem(id); | 69 app_list::AppListItem* item = model_->FindItem(id); |
| 69 if (item && item->GetItemType() != item_type_) { | 70 if (item && item->GetItemType() != item_type_) { |
| 70 VLOG(2) << "App Item matching id: " << id | 71 VLOG(2) << "App Item matching id: " << id |
| 71 << " has incorrect type: '" << item->GetItemType() << "'"; | 72 << " has incorrect type: '" << item->GetItemType() << "'"; |
| 72 return nullptr; | 73 return nullptr; |
| 73 } | 74 } |
| 74 return item; | 75 return item; |
| 75 } | 76 } |
| OLD | NEW |