| 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/browser/extension_registry.h" | 26 #include "extensions/browser/extension_registry.h" |
| 26 #include "extensions/common/extension.h" | 27 #include "extensions/common/extension.h" |
| 27 #include "extensions/common/feature_switch.h" | 28 #include "extensions/common/feature_switch.h" |
| 28 #include "extensions/common/manifest_constants.h" | 29 #include "extensions/common/manifest_constants.h" |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 extension_util::IsIncognitoEnabled(extension.id(), extension_service_)); | 235 extension_util::IsIncognitoEnabled(extension.id(), extension_service_)); |
| 235 } | 236 } |
| 236 | 237 |
| 237 extensions::AppSyncData ExtensionSyncService::GetAppSyncData( | 238 extensions::AppSyncData ExtensionSyncService::GetAppSyncData( |
| 238 const Extension& extension) const { | 239 const Extension& extension) const { |
| 239 return extensions::AppSyncData( | 240 return extensions::AppSyncData( |
| 240 extension, | 241 extension, |
| 241 extension_service_->IsExtensionEnabled(extension.id()), | 242 extension_service_->IsExtensionEnabled(extension.id()), |
| 242 extension_util::IsIncognitoEnabled(extension.id(), extension_service_), | 243 extension_util::IsIncognitoEnabled(extension.id(), extension_service_), |
| 243 extension_prefs_->app_sorting()->GetAppLaunchOrdinal(extension.id()), | 244 extension_prefs_->app_sorting()->GetAppLaunchOrdinal(extension.id()), |
| 244 extension_prefs_->app_sorting()->GetPageOrdinal(extension.id())); | 245 extension_prefs_->app_sorting()->GetPageOrdinal(extension.id()), |
| 246 extensions::GetLaunchTypePrefValue(extension_prefs_, extension.id())); |
| 247 |
| 245 } | 248 } |
| 246 | 249 |
| 247 std::vector<extensions::ExtensionSyncData> | 250 std::vector<extensions::ExtensionSyncData> |
| 248 ExtensionSyncService::GetExtensionSyncDataList() const { | 251 ExtensionSyncService::GetExtensionSyncDataList() const { |
| 249 ExtensionRegistry* registry = ExtensionRegistry::Get(profile_); | 252 ExtensionRegistry* registry = ExtensionRegistry::Get(profile_); |
| 250 std::vector<extensions::ExtensionSyncData> extension_sync_list; | 253 std::vector<extensions::ExtensionSyncData> extension_sync_list; |
| 251 extension_sync_bundle_.GetExtensionSyncDataListHelper( | 254 extension_sync_bundle_.GetExtensionSyncDataListHelper( |
| 252 registry->enabled_extensions(), &extension_sync_list); | 255 registry->enabled_extensions(), &extension_sync_list); |
| 253 extension_sync_bundle_.GetExtensionSyncDataListHelper( | 256 extension_sync_bundle_.GetExtensionSyncDataListHelper( |
| 254 registry->disabled_extensions(), &extension_sync_list); | 257 registry->disabled_extensions(), &extension_sync_list); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 if (app_sync_data.app_launch_ordinal().IsValid() && | 307 if (app_sync_data.app_launch_ordinal().IsValid() && |
| 305 app_sync_data.page_ordinal().IsValid()) { | 308 app_sync_data.page_ordinal().IsValid()) { |
| 306 extension_prefs_->app_sorting()->SetAppLaunchOrdinal( | 309 extension_prefs_->app_sorting()->SetAppLaunchOrdinal( |
| 307 id, | 310 id, |
| 308 app_sync_data.app_launch_ordinal()); | 311 app_sync_data.app_launch_ordinal()); |
| 309 extension_prefs_->app_sorting()->SetPageOrdinal( | 312 extension_prefs_->app_sorting()->SetPageOrdinal( |
| 310 id, | 313 id, |
| 311 app_sync_data.page_ordinal()); | 314 app_sync_data.page_ordinal()); |
| 312 } | 315 } |
| 313 | 316 |
| 317 // The corresponding validation of this value during AppSyncData population |
| 318 // is in AppSyncData::PopulateAppSpecifics. |
| 319 if (app_sync_data.launch_type() >= extensions::LAUNCH_TYPE_FIRST && |
| 320 app_sync_data.launch_type() < extensions::NUM_LAUNCH_TYPES) { |
| 321 extensions::SetLaunchType(extension_service_, id, |
| 322 app_sync_data.launch_type()); |
| 323 } |
| 324 |
| 314 if (!ProcessExtensionSyncDataHelper(app_sync_data.extension_sync_data(), | 325 if (!ProcessExtensionSyncDataHelper(app_sync_data.extension_sync_data(), |
| 315 syncer::APPS)) { | 326 syncer::APPS)) { |
| 316 app_sync_bundle_.AddPendingApp(id, app_sync_data); | 327 app_sync_bundle_.AddPendingApp(id, app_sync_data); |
| 317 extension_service_->CheckForUpdatesSoon(); | 328 extension_service_->CheckForUpdatesSoon(); |
| 318 return false; | 329 return false; |
| 319 } | 330 } |
| 320 | 331 |
| 321 return true; | 332 return true; |
| 322 } | 333 } |
| 323 | 334 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 app_sync_bundle_.SyncChangeIfNeeded(extension); | 457 app_sync_bundle_.SyncChangeIfNeeded(extension); |
| 447 else if (extension_service_->is_ready() && !flare_.is_null()) | 458 else if (extension_service_->is_ready() && !flare_.is_null()) |
| 448 flare_.Run(syncer::APPS); | 459 flare_.Run(syncer::APPS); |
| 449 } else if (extensions::sync_helper::IsSyncableExtension(&extension)) { | 460 } else if (extensions::sync_helper::IsSyncableExtension(&extension)) { |
| 450 if (extension_sync_bundle_.IsSyncing()) | 461 if (extension_sync_bundle_.IsSyncing()) |
| 451 extension_sync_bundle_.SyncChangeIfNeeded(extension); | 462 extension_sync_bundle_.SyncChangeIfNeeded(extension); |
| 452 else if (extension_service_->is_ready() && !flare_.is_null()) | 463 else if (extension_service_->is_ready() && !flare_.is_null()) |
| 453 flare_.Run(syncer::EXTENSIONS); | 464 flare_.Run(syncer::EXTENSIONS); |
| 454 } | 465 } |
| 455 } | 466 } |
| OLD | NEW |