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" |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "ui/app_list/app_list_folder_item.h" | 29 #include "ui/app_list/app_list_folder_item.h" |
30 #include "ui/app_list/app_list_item.h" | 30 #include "ui/app_list/app_list_item.h" |
31 #include "ui/app_list/app_list_model.h" | 31 #include "ui/app_list/app_list_model.h" |
32 #include "ui/app_list/app_list_model_observer.h" | 32 #include "ui/app_list/app_list_model_observer.h" |
33 #include "ui/app_list/app_list_switches.h" | 33 #include "ui/app_list/app_list_switches.h" |
34 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
35 | 35 |
36 #if defined(OS_CHROMEOS) | 36 #if defined(OS_CHROMEOS) |
37 #include "chrome/browser/chromeos/file_manager/app_id.h" | 37 #include "chrome/browser/chromeos/file_manager/app_id.h" |
38 #include "chrome/browser/chromeos/genius_app/app_id.h" | 38 #include "chrome/browser/chromeos/genius_app/app_id.h" |
| 39 #include "chrome/browser/ui/app_list/arc/arc_app_item.h" |
| 40 #include "chrome/browser/ui/app_list/arc/arc_app_model_builder.h" |
39 #endif | 41 #endif |
40 | 42 |
41 using syncer::SyncChange; | 43 using syncer::SyncChange; |
42 | 44 |
43 namespace app_list { | 45 namespace app_list { |
44 | 46 |
45 namespace { | 47 namespace { |
46 | 48 |
47 const char kOemFolderId[] = "ddb1da55-d478-4243-8642-56d3041f0263"; | 49 const char kOemFolderId[] = "ddb1da55-d478-4243-8642-56d3041f0263"; |
48 | 50 |
(...skipping 76 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 #if defined(OS_CHROMEOS) |
| 138 } else if (item_type == ArcAppItem::kItemType) { |
| 139 *type = sync_pb::AppListSpecifics::TYPE_APP; |
| 140 #endif |
135 } else if (item_type == AppListFolderItem::kItemType) { | 141 } else if (item_type == AppListFolderItem::kItemType) { |
136 *type = sync_pb::AppListSpecifics::TYPE_FOLDER; | 142 *type = sync_pb::AppListSpecifics::TYPE_FOLDER; |
137 } else { | 143 } else { |
138 LOG(ERROR) << "Unrecognized model type: " << item_type; | 144 LOG(ERROR) << "Unrecognized model type: " << item_type; |
139 return false; | 145 return false; |
140 } | 146 } |
141 return true; | 147 return true; |
142 } | 148 } |
143 | 149 |
144 bool IsDriveAppSyncId(const std::string& sync_id) { | 150 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 | 264 // For now, use the AppListControllerDelegate associated with the native |
259 // desktop. TODO(stevenjb): Remove ExtensionAppModelBuilder controller | 265 // desktop. TODO(stevenjb): Remove ExtensionAppModelBuilder controller |
260 // dependency and move the dependent methods from AppListControllerDelegate | 266 // dependency and move the dependent methods from AppListControllerDelegate |
261 // to an extension service delegate associated with this class. | 267 // to an extension service delegate associated with this class. |
262 AppListControllerDelegate* controller = NULL; | 268 AppListControllerDelegate* controller = NULL; |
263 AppListService* service = | 269 AppListService* service = |
264 AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE); | 270 AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE); |
265 if (service) | 271 if (service) |
266 controller = service->GetControllerDelegate(); | 272 controller = service->GetControllerDelegate(); |
267 apps_builder_.reset(new ExtensionAppModelBuilder(controller)); | 273 apps_builder_.reset(new ExtensionAppModelBuilder(controller)); |
| 274 #if defined(OS_CHROMEOS) |
| 275 arc_apps_builder_.reset(new ArcAppModelBuilder(controller)); |
| 276 #endif |
268 DCHECK(profile_); | 277 DCHECK(profile_); |
269 if (app_list::switches::IsAppListSyncEnabled()) { | 278 if (app_list::switches::IsAppListSyncEnabled()) { |
270 VLOG(1) << this << ": AppListSyncableService: InitializeWithService."; | 279 VLOG(1) << this << ": AppListSyncableService: InitializeWithService."; |
271 SyncStarted(); | 280 SyncStarted(); |
272 apps_builder_->InitializeWithService(this, model_.get()); | 281 apps_builder_->InitializeWithService(this, model_.get()); |
| 282 #if defined(OS_CHROMEOS) |
| 283 arc_apps_builder_->InitializeWithService(this, model_.get()); |
| 284 #endif |
273 } else { | 285 } else { |
274 VLOG(1) << this << ": AppListSyncableService: InitializeWithProfile."; | 286 VLOG(1) << this << ": AppListSyncableService: InitializeWithProfile."; |
275 apps_builder_->InitializeWithProfile(profile_, model_.get()); | 287 apps_builder_->InitializeWithProfile(profile_, model_.get()); |
| 288 #if defined(OS_CHROMEOS) |
| 289 arc_apps_builder_->InitializeWithProfile(profile_, model_.get()); |
| 290 #endif |
276 } | 291 } |
277 | 292 |
278 model_pref_updater_.reset( | 293 model_pref_updater_.reset( |
279 new ModelPrefUpdater(AppListPrefs::Get(profile_), model_.get())); | 294 new ModelPrefUpdater(AppListPrefs::Get(profile_), model_.get())); |
280 | 295 |
281 if (app_list::switches::IsDriveAppsInAppListEnabled()) | 296 if (app_list::switches::IsDriveAppsInAppListEnabled()) |
282 drive_app_provider_.reset(new DriveAppProvider(profile_, this)); | 297 drive_app_provider_.reset(new DriveAppProvider(profile_, this)); |
283 } | 298 } |
284 | 299 |
285 size_t AppListSyncableService::GetNumSyncItemsForTest() { | 300 size_t AppListSyncableService::GetNumSyncItemsForTest() { |
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 } else { | 1010 } else { |
996 res += " { " + item_name + " }"; | 1011 res += " { " + item_name + " }"; |
997 res += " [" + item_ordinal.ToDebugString() + "]"; | 1012 res += " [" + item_ordinal.ToDebugString() + "]"; |
998 if (!parent_id.empty()) | 1013 if (!parent_id.empty()) |
999 res += " <" + parent_id.substr(0, 8) + ">"; | 1014 res += " <" + parent_id.substr(0, 8) + ">"; |
1000 } | 1015 } |
1001 return res; | 1016 return res; |
1002 } | 1017 } |
1003 | 1018 |
1004 } // namespace app_list | 1019 } // namespace app_list |
OLD | NEW |