| 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" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "chrome/browser/apps/drive/drive_app_provider.h" | 15 #include "chrome/browser/apps/drive/drive_app_provider.h" |
| 16 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/ui/app_list/app_list_prefs.h" | |
| 19 #include "chrome/browser/ui/app_list/app_list_service.h" | 18 #include "chrome/browser/ui/app_list/app_list_service.h" |
| 20 #include "chrome/browser/ui/app_list/extension_app_item.h" | 19 #include "chrome/browser/ui/app_list/extension_app_item.h" |
| 21 #include "chrome/browser/ui/app_list/extension_app_model_builder.h" | 20 #include "chrome/browser/ui/app_list/extension_app_model_builder.h" |
| 22 #include "chrome/browser/ui/app_list/model_pref_updater.h" | |
| 23 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
| 24 #include "chrome/common/extensions/extension_constants.h" | 22 #include "chrome/common/extensions/extension_constants.h" |
| 25 #include "chrome/grit/generated_resources.h" | 23 #include "chrome/grit/generated_resources.h" |
| 26 #include "components/sync/model/sync_change_processor.h" | 24 #include "components/sync/model/sync_change_processor.h" |
| 27 #include "components/sync/model/sync_data.h" | 25 #include "components/sync/model/sync_data.h" |
| 28 #include "components/sync/model/sync_merge_result.h" | 26 #include "components/sync/model/sync_merge_result.h" |
| 29 #include "components/sync/protocol/sync.pb.h" | 27 #include "components/sync/protocol/sync.pb.h" |
| 30 #include "extensions/browser/extension_prefs.h" | 28 #include "extensions/browser/extension_prefs.h" |
| 31 #include "extensions/browser/extension_system.h" | 29 #include "extensions/browser/extension_system.h" |
| 32 #include "extensions/browser/uninstall_reason.h" | 30 #include "extensions/browser/uninstall_reason.h" |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 return; | 267 return; |
| 270 } | 268 } |
| 271 | 269 |
| 272 oem_folder_name_ = | 270 oem_folder_name_ = |
| 273 l10n_util::GetStringUTF8(IDS_APP_LIST_OEM_DEFAULT_FOLDER_NAME); | 271 l10n_util::GetStringUTF8(IDS_APP_LIST_OEM_DEFAULT_FOLDER_NAME); |
| 274 } | 272 } |
| 275 | 273 |
| 276 AppListSyncableService::~AppListSyncableService() { | 274 AppListSyncableService::~AppListSyncableService() { |
| 277 // Remove observers. | 275 // Remove observers. |
| 278 model_observer_.reset(); | 276 model_observer_.reset(); |
| 279 model_pref_updater_.reset(); | |
| 280 } | 277 } |
| 281 | 278 |
| 282 void AppListSyncableService::BuildModel() { | 279 void AppListSyncableService::BuildModel() { |
| 283 // TODO(calamity): make this a DCHECK after a dev channel release. | 280 // TODO(calamity): make this a DCHECK after a dev channel release. |
| 284 CHECK(extension_system_->extension_service() && | 281 CHECK(extension_system_->extension_service() && |
| 285 extension_system_->extension_service()->is_ready()); | 282 extension_system_->extension_service()->is_ready()); |
| 286 AppListControllerDelegate* controller = NULL; | 283 AppListControllerDelegate* controller = NULL; |
| 287 AppListService* service = AppListService::Get(); | 284 AppListService* service = AppListService::Get(); |
| 288 if (service) | 285 if (service) |
| 289 controller = service->GetControllerDelegate(); | 286 controller = service->GetControllerDelegate(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 303 #endif | 300 #endif |
| 304 } else { | 301 } else { |
| 305 VLOG(1) << this << ": AppListSyncableService: InitializeWithProfile."; | 302 VLOG(1) << this << ": AppListSyncableService: InitializeWithProfile."; |
| 306 apps_builder_->InitializeWithProfile(profile_, model_.get()); | 303 apps_builder_->InitializeWithProfile(profile_, model_.get()); |
| 307 #if defined(OS_CHROMEOS) | 304 #if defined(OS_CHROMEOS) |
| 308 if (arc_apps_builder_.get()) | 305 if (arc_apps_builder_.get()) |
| 309 arc_apps_builder_->InitializeWithProfile(profile_, model_.get()); | 306 arc_apps_builder_->InitializeWithProfile(profile_, model_.get()); |
| 310 #endif | 307 #endif |
| 311 } | 308 } |
| 312 | 309 |
| 313 model_pref_updater_.reset( | |
| 314 new ModelPrefUpdater(AppListPrefs::Get(profile_), model_.get())); | |
| 315 | |
| 316 if (app_list::switches::IsDriveAppsInAppListEnabled()) | 310 if (app_list::switches::IsDriveAppsInAppListEnabled()) |
| 317 drive_app_provider_.reset(new DriveAppProvider(profile_, this)); | 311 drive_app_provider_.reset(new DriveAppProvider(profile_, this)); |
| 318 } | 312 } |
| 319 | 313 |
| 320 void AppListSyncableService::AddObserverAndStart(Observer* observer) { | 314 void AppListSyncableService::AddObserverAndStart(Observer* observer) { |
| 321 observer_list_.AddObserver(observer); | 315 observer_list_.AddObserver(observer); |
| 322 SyncStarted(); | 316 SyncStarted(); |
| 323 } | 317 } |
| 324 | 318 |
| 325 void AppListSyncableService::RemoveObserver(Observer* observer) { | 319 void AppListSyncableService::RemoveObserver(Observer* observer) { |
| (...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1075 res += " { " + item_name + " }"; | 1069 res += " { " + item_name + " }"; |
| 1076 res += " [" + item_ordinal.ToDebugString() + "]"; | 1070 res += " [" + item_ordinal.ToDebugString() + "]"; |
| 1077 if (!parent_id.empty()) | 1071 if (!parent_id.empty()) |
| 1078 res += " <" + parent_id.substr(0, 8) + ">"; | 1072 res += " <" + parent_id.substr(0, 8) + ">"; |
| 1079 res += " [" + item_pin_ordinal.ToDebugString() + "]"; | 1073 res += " [" + item_pin_ordinal.ToDebugString() + "]"; |
| 1080 } | 1074 } |
| 1081 return res; | 1075 return res; |
| 1082 } | 1076 } |
| 1083 | 1077 |
| 1084 } // namespace app_list | 1078 } // namespace app_list |
| OLD | NEW |