| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_syncable_service.h" | 5 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 | 256 |
| 257 oem_folder_name_ = | 257 oem_folder_name_ = |
| 258 l10n_util::GetStringUTF8(IDS_APP_LIST_OEM_DEFAULT_FOLDER_NAME); | 258 l10n_util::GetStringUTF8(IDS_APP_LIST_OEM_DEFAULT_FOLDER_NAME); |
| 259 } | 259 } |
| 260 | 260 |
| 261 AppListSyncableService::~AppListSyncableService() { | 261 AppListSyncableService::~AppListSyncableService() { |
| 262 // Remove observers. | 262 // Remove observers. |
| 263 model_observer_.reset(); | 263 model_observer_.reset(); |
| 264 model_pref_updater_.reset(); | 264 model_pref_updater_.reset(); |
| 265 | 265 |
| 266 STLDeleteContainerPairSecondPointers(sync_items_.begin(), sync_items_.end()); | 266 base::STLDeleteContainerPairSecondPointers(sync_items_.begin(), |
| 267 sync_items_.end()); |
| 267 } | 268 } |
| 268 | 269 |
| 269 void AppListSyncableService::BuildModel() { | 270 void AppListSyncableService::BuildModel() { |
| 270 // TODO(calamity): make this a DCHECK after a dev channel release. | 271 // TODO(calamity): make this a DCHECK after a dev channel release. |
| 271 CHECK(extension_system_->extension_service() && | 272 CHECK(extension_system_->extension_service() && |
| 272 extension_system_->extension_service()->is_ready()); | 273 extension_system_->extension_service()->is_ready()); |
| 273 AppListControllerDelegate* controller = NULL; | 274 AppListControllerDelegate* controller = NULL; |
| 274 AppListService* service = AppListService::Get(); | 275 AppListService* service = AppListService::Get(); |
| 275 if (service) | 276 if (service) |
| 276 controller = service->GetControllerDelegate(); | 277 controller = service->GetControllerDelegate(); |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 std::set<std::string> parent_ids; | 616 std::set<std::string> parent_ids; |
| 616 for (SyncItemMap::iterator iter = sync_items_.begin(); | 617 for (SyncItemMap::iterator iter = sync_items_.begin(); |
| 617 iter != sync_items_.end(); ++iter) { | 618 iter != sync_items_.end(); ++iter) { |
| 618 parent_ids.insert(iter->second->parent_id); | 619 parent_ids.insert(iter->second->parent_id); |
| 619 } | 620 } |
| 620 for (SyncItemMap::iterator iter = sync_items_.begin(); | 621 for (SyncItemMap::iterator iter = sync_items_.begin(); |
| 621 iter != sync_items_.end(); ) { | 622 iter != sync_items_.end(); ) { |
| 622 SyncItem* sync_item = (iter++)->second; | 623 SyncItem* sync_item = (iter++)->second; |
| 623 if (sync_item->item_type != sync_pb::AppListSpecifics::TYPE_FOLDER) | 624 if (sync_item->item_type != sync_pb::AppListSpecifics::TYPE_FOLDER) |
| 624 continue; | 625 continue; |
| 625 if (!ContainsKey(parent_ids, sync_item->item_id)) | 626 if (!base::ContainsKey(parent_ids, sync_item->item_id)) |
| 626 DeleteSyncItem(sync_item); | 627 DeleteSyncItem(sync_item); |
| 627 } | 628 } |
| 628 } | 629 } |
| 629 | 630 |
| 630 // AppListSyncableService syncer::SyncableService | 631 // AppListSyncableService syncer::SyncableService |
| 631 | 632 |
| 632 syncer::SyncMergeResult AppListSyncableService::MergeDataAndStartSyncing( | 633 syncer::SyncMergeResult AppListSyncableService::MergeDataAndStartSyncing( |
| 633 syncer::ModelType type, | 634 syncer::ModelType type, |
| 634 const syncer::SyncDataList& initial_sync_data, | 635 const syncer::SyncDataList& initial_sync_data, |
| 635 std::unique_ptr<syncer::SyncChangeProcessor> sync_processor, | 636 std::unique_ptr<syncer::SyncChangeProcessor> sync_processor, |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 938 SyncItemMap::iterator iter = sync_items_.find(item_id); | 939 SyncItemMap::iterator iter = sync_items_.find(item_id); |
| 939 if (iter == sync_items_.end()) | 940 if (iter == sync_items_.end()) |
| 940 return NULL; | 941 return NULL; |
| 941 return iter->second; | 942 return iter->second; |
| 942 } | 943 } |
| 943 | 944 |
| 944 AppListSyncableService::SyncItem* | 945 AppListSyncableService::SyncItem* |
| 945 AppListSyncableService::CreateSyncItem( | 946 AppListSyncableService::CreateSyncItem( |
| 946 const std::string& item_id, | 947 const std::string& item_id, |
| 947 sync_pb::AppListSpecifics::AppListItemType item_type) { | 948 sync_pb::AppListSpecifics::AppListItemType item_type) { |
| 948 DCHECK(!ContainsKey(sync_items_, item_id)); | 949 DCHECK(!base::ContainsKey(sync_items_, item_id)); |
| 949 SyncItem* sync_item = new SyncItem(item_id, item_type); | 950 SyncItem* sync_item = new SyncItem(item_id, item_type); |
| 950 sync_items_[item_id] = sync_item; | 951 sync_items_[item_id] = sync_item; |
| 951 return sync_item; | 952 return sync_item; |
| 952 } | 953 } |
| 953 | 954 |
| 954 void AppListSyncableService::DeleteSyncItemSpecifics( | 955 void AppListSyncableService::DeleteSyncItemSpecifics( |
| 955 const sync_pb::AppListSpecifics& specifics) { | 956 const sync_pb::AppListSpecifics& specifics) { |
| 956 const std::string& item_id = specifics.item_id(); | 957 const std::string& item_id = specifics.item_id(); |
| 957 if (item_id.empty()) { | 958 if (item_id.empty()) { |
| 958 LOG(ERROR) << "Delete AppList item with empty ID"; | 959 LOG(ERROR) << "Delete AppList item with empty ID"; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1061 res += " { " + item_name + " }"; | 1062 res += " { " + item_name + " }"; |
| 1062 res += " [" + item_ordinal.ToDebugString() + "]"; | 1063 res += " [" + item_ordinal.ToDebugString() + "]"; |
| 1063 if (!parent_id.empty()) | 1064 if (!parent_id.empty()) |
| 1064 res += " <" + parent_id.substr(0, 8) + ">"; | 1065 res += " <" + parent_id.substr(0, 8) + ">"; |
| 1065 res += " [" + item_pin_ordinal.ToDebugString() + "]"; | 1066 res += " [" + item_pin_ordinal.ToDebugString() + "]"; |
| 1066 } | 1067 } |
| 1067 return res; | 1068 return res; |
| 1068 } | 1069 } |
| 1069 | 1070 |
| 1070 } // namespace app_list | 1071 } // namespace app_list |
| OLD | NEW |