| 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/extensions/extension_sync_service.h" | 5 #include "chrome/browser/extensions/extension_sync_service.h" |
| 6 | 6 |
| 7 #include <iterator> | 7 #include <iterator> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/threading/sequenced_worker_pool.h" | 10 #include "base/threading/sequenced_worker_pool.h" |
| 11 #include "base/threading/thread_restrictions.h" | 11 #include "base/threading/thread_restrictions.h" |
| 12 #include "chrome/browser/extensions/app_sync_data.h" | 12 #include "chrome/browser/extensions/app_sync_data.h" |
| 13 #include "chrome/browser/extensions/extension_error_ui.h" | 13 #include "chrome/browser/extensions/extension_error_ui.h" |
| 14 #include "chrome/browser/extensions/extension_prefs.h" | 14 #include "chrome/browser/extensions/extension_prefs.h" |
| 15 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
| 16 #include "chrome/browser/extensions/extension_sync_data.h" | 16 #include "chrome/browser/extensions/extension_sync_data.h" |
| 17 #include "chrome/browser/extensions/extension_sync_service_factory.h" | 17 #include "chrome/browser/extensions/extension_sync_service_factory.h" |
| 18 #include "chrome/browser/extensions/extension_util.h" | 18 #include "chrome/browser/extensions/extension_util.h" |
| 19 #include "chrome/browser/extensions/launch_util.h" |
| 19 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/sync/glue/sync_start_util.h" | 21 #include "chrome/browser/sync/glue/sync_start_util.h" |
| 21 #include "chrome/browser/sync/sync_prefs.h" | 22 #include "chrome/browser/sync/sync_prefs.h" |
| 22 #include "chrome/common/extensions/sync_helper.h" | 23 #include "chrome/common/extensions/sync_helper.h" |
| 23 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
| 24 #include "extensions/browser/app_sorting.h" | 25 #include "extensions/browser/app_sorting.h" |
| 25 #include "extensions/common/extension.h" | 26 #include "extensions/common/extension.h" |
| 26 #include "extensions/common/feature_switch.h" | 27 #include "extensions/common/feature_switch.h" |
| 27 #include "extensions/common/manifest_constants.h" | 28 #include "extensions/common/manifest_constants.h" |
| 28 #include "sync/api/sync_change.h" | 29 #include "sync/api/sync_change.h" |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 extension_util::IsIncognitoEnabled(extension.id(), extension_service_)); | 233 extension_util::IsIncognitoEnabled(extension.id(), extension_service_)); |
| 233 } | 234 } |
| 234 | 235 |
| 235 extensions::AppSyncData ExtensionSyncService::GetAppSyncData( | 236 extensions::AppSyncData ExtensionSyncService::GetAppSyncData( |
| 236 const Extension& extension) const { | 237 const Extension& extension) const { |
| 237 return extensions::AppSyncData( | 238 return extensions::AppSyncData( |
| 238 extension, | 239 extension, |
| 239 extension_service_->IsExtensionEnabled(extension.id()), | 240 extension_service_->IsExtensionEnabled(extension.id()), |
| 240 extension_util::IsIncognitoEnabled(extension.id(), extension_service_), | 241 extension_util::IsIncognitoEnabled(extension.id(), extension_service_), |
| 241 extension_prefs_->app_sorting()->GetAppLaunchOrdinal(extension.id()), | 242 extension_prefs_->app_sorting()->GetAppLaunchOrdinal(extension.id()), |
| 242 extension_prefs_->app_sorting()->GetPageOrdinal(extension.id())); | 243 extension_prefs_->app_sorting()->GetPageOrdinal(extension.id()), |
| 244 extensions::HasPreferredLaunchType(extension_prefs_, &extension) |
| 245 ? extensions::GetLaunchType(extension_prefs_, &extension) |
| 246 : extensions::LAUNCH_TYPE_INVALID); |
| 247 |
| 243 } | 248 } |
| 244 | 249 |
| 245 std::vector<extensions::ExtensionSyncData> | 250 std::vector<extensions::ExtensionSyncData> |
| 246 ExtensionSyncService::GetExtensionSyncDataList() const { | 251 ExtensionSyncService::GetExtensionSyncDataList() const { |
| 247 std::vector<extensions::ExtensionSyncData> extension_sync_list; | 252 std::vector<extensions::ExtensionSyncData> extension_sync_list; |
| 248 extension_sync_bundle_.GetExtensionSyncDataListHelper( | 253 extension_sync_bundle_.GetExtensionSyncDataListHelper( |
| 249 extension_service_->extensions(), &extension_sync_list); | 254 extension_service_->extensions(), &extension_sync_list); |
| 250 extension_sync_bundle_.GetExtensionSyncDataListHelper( | 255 extension_sync_bundle_.GetExtensionSyncDataListHelper( |
| 251 extension_service_->disabled_extensions(), &extension_sync_list); | 256 extension_service_->disabled_extensions(), &extension_sync_list); |
| 252 extension_sync_bundle_.GetExtensionSyncDataListHelper( | 257 extension_sync_bundle_.GetExtensionSyncDataListHelper( |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 if (app_sync_data.app_launch_ordinal().IsValid() && | 305 if (app_sync_data.app_launch_ordinal().IsValid() && |
| 301 app_sync_data.page_ordinal().IsValid()) { | 306 app_sync_data.page_ordinal().IsValid()) { |
| 302 extension_prefs_->app_sorting()->SetAppLaunchOrdinal( | 307 extension_prefs_->app_sorting()->SetAppLaunchOrdinal( |
| 303 id, | 308 id, |
| 304 app_sync_data.app_launch_ordinal()); | 309 app_sync_data.app_launch_ordinal()); |
| 305 extension_prefs_->app_sorting()->SetPageOrdinal( | 310 extension_prefs_->app_sorting()->SetPageOrdinal( |
| 306 id, | 311 id, |
| 307 app_sync_data.page_ordinal()); | 312 app_sync_data.page_ordinal()); |
| 308 } | 313 } |
| 309 | 314 |
| 315 if (app_sync_data.launch_type() >= extensions::LAUNCH_TYPE_FIRST && |
| 316 app_sync_data.launch_type() < extensions::NUM_LAUNCH_TYPES) { |
| 317 extensions::SetLaunchType(extension_service_, id, |
| 318 static_cast<extensions::LaunchType>(app_sync_data.launch_type())); |
| 319 } |
| 320 |
| 310 if (!ProcessExtensionSyncDataHelper(app_sync_data.extension_sync_data(), | 321 if (!ProcessExtensionSyncDataHelper(app_sync_data.extension_sync_data(), |
| 311 syncer::APPS)) { | 322 syncer::APPS)) { |
| 312 app_sync_bundle_.AddPendingApp(id, app_sync_data); | 323 app_sync_bundle_.AddPendingApp(id, app_sync_data); |
| 313 extension_service_->CheckForUpdatesSoon(); | 324 extension_service_->CheckForUpdatesSoon(); |
| 314 return false; | 325 return false; |
| 315 } | 326 } |
| 316 | 327 |
| 317 return true; | 328 return true; |
| 318 } | 329 } |
| 319 | 330 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 app_sync_bundle_.SyncChangeIfNeeded(extension); | 453 app_sync_bundle_.SyncChangeIfNeeded(extension); |
| 443 else if (extension_service_->is_ready() && !flare_.is_null()) | 454 else if (extension_service_->is_ready() && !flare_.is_null()) |
| 444 flare_.Run(syncer::APPS); | 455 flare_.Run(syncer::APPS); |
| 445 } else if (extensions::sync_helper::IsSyncableExtension(&extension)) { | 456 } else if (extensions::sync_helper::IsSyncableExtension(&extension)) { |
| 446 if (extension_sync_bundle_.IsSyncing()) | 457 if (extension_sync_bundle_.IsSyncing()) |
| 447 extension_sync_bundle_.SyncChangeIfNeeded(extension); | 458 extension_sync_bundle_.SyncChangeIfNeeded(extension); |
| 448 else if (extension_service_->is_ready() && !flare_.is_null()) | 459 else if (extension_service_->is_ready() && !flare_.is_null()) |
| 449 flare_.Run(syncer::EXTENSIONS); | 460 flare_.Run(syncer::EXTENSIONS); |
| 450 } | 461 } |
| 451 } | 462 } |
| OLD | NEW |