Chromium Code Reviews| 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "chrome/browser/apps/drive/drive_app_provider.h" | 9 #include "chrome/browser/apps/drive/drive_app_provider.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/ui/app_list/app_list_prefs.h" | 12 #include "chrome/browser/ui/app_list/app_list_prefs.h" |
| 13 #include "chrome/browser/ui/app_list/app_list_service.h" | 13 #include "chrome/browser/ui/app_list/app_list_service.h" |
| 14 #include "chrome/browser/ui/app_list/arc_app_item.h" | |
| 15 #include "chrome/browser/ui/app_list/arc_app_model_builder.h" | |
| 14 #include "chrome/browser/ui/app_list/extension_app_item.h" | 16 #include "chrome/browser/ui/app_list/extension_app_item.h" |
| 15 #include "chrome/browser/ui/app_list/extension_app_model_builder.h" | 17 #include "chrome/browser/ui/app_list/extension_app_model_builder.h" |
| 16 #include "chrome/browser/ui/app_list/model_pref_updater.h" | 18 #include "chrome/browser/ui/app_list/model_pref_updater.h" |
| 17 #include "chrome/browser/ui/host_desktop.h" | 19 #include "chrome/browser/ui/host_desktop.h" |
| 18 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 19 #include "chrome/common/extensions/extension_constants.h" | 21 #include "chrome/common/extensions/extension_constants.h" |
| 20 #include "chrome/grit/generated_resources.h" | 22 #include "chrome/grit/generated_resources.h" |
| 21 #include "extensions/browser/extension_prefs.h" | 23 #include "extensions/browser/extension_prefs.h" |
| 22 #include "extensions/browser/extension_system.h" | 24 #include "extensions/browser/extension_system.h" |
| 23 #include "extensions/browser/uninstall_reason.h" | 25 #include "extensions/browser/uninstall_reason.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 ExtensionService::UninstallExtensionHelper( | 127 ExtensionService::UninstallExtensionHelper( |
| 126 service, id, extensions::UNINSTALL_REASON_SYNC); | 128 service, id, extensions::UNINSTALL_REASON_SYNC); |
| 127 } | 129 } |
| 128 } | 130 } |
| 129 | 131 |
| 130 bool GetAppListItemType(AppListItem* item, | 132 bool GetAppListItemType(AppListItem* item, |
| 131 sync_pb::AppListSpecifics::AppListItemType* type) { | 133 sync_pb::AppListSpecifics::AppListItemType* type) { |
| 132 const char* item_type = item->GetItemType(); | 134 const char* item_type = item->GetItemType(); |
| 133 if (item_type == ExtensionAppItem::kItemType) { | 135 if (item_type == ExtensionAppItem::kItemType) { |
| 134 *type = sync_pb::AppListSpecifics::TYPE_APP; | 136 *type = sync_pb::AppListSpecifics::TYPE_APP; |
| 137 } else if (item_type == ArcAppItem::kItemType) { | |
| 138 *type = sync_pb::AppListSpecifics::TYPE_APP; | |
|
elijahtaylor1
2015/10/28 06:32:38
nit: alignment
khmel1
2015/10/29 08:12:18
Done.
| |
| 135 } else if (item_type == AppListFolderItem::kItemType) { | 139 } else if (item_type == AppListFolderItem::kItemType) { |
| 136 *type = sync_pb::AppListSpecifics::TYPE_FOLDER; | 140 *type = sync_pb::AppListSpecifics::TYPE_FOLDER; |
| 137 } else { | 141 } else { |
| 138 LOG(ERROR) << "Unrecognized model type: " << item_type; | 142 LOG(ERROR) << "Unrecognized model type: " << item_type; |
| 139 return false; | 143 return false; |
| 140 } | 144 } |
| 141 return true; | 145 return true; |
| 142 } | 146 } |
| 143 | 147 |
| 144 bool IsDriveAppSyncId(const std::string& sync_id) { | 148 bool IsDriveAppSyncId(const std::string& sync_id) { |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 258 // For now, use the AppListControllerDelegate associated with the native | 262 // For now, use the AppListControllerDelegate associated with the native |
| 259 // desktop. TODO(stevenjb): Remove ExtensionAppModelBuilder controller | 263 // desktop. TODO(stevenjb): Remove ExtensionAppModelBuilder controller |
| 260 // dependency and move the dependent methods from AppListControllerDelegate | 264 // dependency and move the dependent methods from AppListControllerDelegate |
| 261 // to an extension service delegate associated with this class. | 265 // to an extension service delegate associated with this class. |
| 262 AppListControllerDelegate* controller = NULL; | 266 AppListControllerDelegate* controller = NULL; |
| 263 AppListService* service = | 267 AppListService* service = |
| 264 AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE); | 268 AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE); |
| 265 if (service) | 269 if (service) |
| 266 controller = service->GetControllerDelegate(); | 270 controller = service->GetControllerDelegate(); |
| 267 apps_builder_.reset(new ExtensionAppModelBuilder(controller)); | 271 apps_builder_.reset(new ExtensionAppModelBuilder(controller)); |
| 272 arc_apps_builder_.reset(new ArcAppModelBuilder(controller)); | |
| 268 DCHECK(profile_); | 273 DCHECK(profile_); |
| 269 if (app_list::switches::IsAppListSyncEnabled()) { | 274 if (app_list::switches::IsAppListSyncEnabled()) { |
| 270 VLOG(1) << this << ": AppListSyncableService: InitializeWithService."; | 275 VLOG(1) << this << ": AppListSyncableService: InitializeWithService."; |
| 271 SyncStarted(); | 276 SyncStarted(); |
| 272 apps_builder_->InitializeWithService(this, model_.get()); | 277 apps_builder_->InitializeWithService(this, model_.get()); |
| 278 arc_apps_builder_->InitializeWithService(this, model_.get()); | |
| 273 } else { | 279 } else { |
| 274 VLOG(1) << this << ": AppListSyncableService: InitializeWithProfile."; | 280 VLOG(1) << this << ": AppListSyncableService: InitializeWithProfile."; |
| 275 apps_builder_->InitializeWithProfile(profile_, model_.get()); | 281 apps_builder_->InitializeWithProfile(profile_, model_.get()); |
| 282 arc_apps_builder_->InitializeWithProfile(profile_, model_.get()); | |
| 276 } | 283 } |
| 277 | 284 |
| 278 model_pref_updater_.reset( | 285 model_pref_updater_.reset( |
| 279 new ModelPrefUpdater(AppListPrefs::Get(profile_), model_.get())); | 286 new ModelPrefUpdater(AppListPrefs::Get(profile_), model_.get())); |
| 280 | 287 |
| 281 if (app_list::switches::IsDriveAppsInAppListEnabled()) | 288 if (app_list::switches::IsDriveAppsInAppListEnabled()) |
| 282 drive_app_provider_.reset(new DriveAppProvider(profile_, this)); | 289 drive_app_provider_.reset(new DriveAppProvider(profile_, this)); |
| 283 } | 290 } |
| 284 | 291 |
| 285 size_t AppListSyncableService::GetNumSyncItemsForTest() { | 292 size_t AppListSyncableService::GetNumSyncItemsForTest() { |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 995 } else { | 1002 } else { |
| 996 res += " { " + item_name + " }"; | 1003 res += " { " + item_name + " }"; |
| 997 res += " [" + item_ordinal.ToDebugString() + "]"; | 1004 res += " [" + item_ordinal.ToDebugString() + "]"; |
| 998 if (!parent_id.empty()) | 1005 if (!parent_id.empty()) |
| 999 res += " <" + parent_id.substr(0, 8) + ">"; | 1006 res += " <" + parent_id.substr(0, 8) + ">"; |
| 1000 } | 1007 } |
| 1001 return res; | 1008 return res; |
| 1002 } | 1009 } |
| 1003 | 1010 |
| 1004 } // namespace app_list | 1011 } // namespace app_list |
| OLD | NEW |