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::GetLaunchTypePrefValue(extension_prefs_, extension.id())); | |
245 | |
243 } | 246 } |
244 | 247 |
245 std::vector<extensions::ExtensionSyncData> | 248 std::vector<extensions::ExtensionSyncData> |
246 ExtensionSyncService::GetExtensionSyncDataList() const { | 249 ExtensionSyncService::GetExtensionSyncDataList() const { |
247 std::vector<extensions::ExtensionSyncData> extension_sync_list; | 250 std::vector<extensions::ExtensionSyncData> extension_sync_list; |
248 extension_sync_bundle_.GetExtensionSyncDataListHelper( | 251 extension_sync_bundle_.GetExtensionSyncDataListHelper( |
249 extension_service_->extensions(), &extension_sync_list); | 252 extension_service_->extensions(), &extension_sync_list); |
250 extension_sync_bundle_.GetExtensionSyncDataListHelper( | 253 extension_sync_bundle_.GetExtensionSyncDataListHelper( |
251 extension_service_->disabled_extensions(), &extension_sync_list); | 254 extension_service_->disabled_extensions(), &extension_sync_list); |
252 extension_sync_bundle_.GetExtensionSyncDataListHelper( | 255 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() && | 303 if (app_sync_data.app_launch_ordinal().IsValid() && |
301 app_sync_data.page_ordinal().IsValid()) { | 304 app_sync_data.page_ordinal().IsValid()) { |
302 extension_prefs_->app_sorting()->SetAppLaunchOrdinal( | 305 extension_prefs_->app_sorting()->SetAppLaunchOrdinal( |
303 id, | 306 id, |
304 app_sync_data.app_launch_ordinal()); | 307 app_sync_data.app_launch_ordinal()); |
305 extension_prefs_->app_sorting()->SetPageOrdinal( | 308 extension_prefs_->app_sorting()->SetPageOrdinal( |
306 id, | 309 id, |
307 app_sync_data.page_ordinal()); | 310 app_sync_data.page_ordinal()); |
308 } | 311 } |
309 | 312 |
313 if (app_sync_data.launch_type() >= extensions::LAUNCH_TYPE_FIRST && | |
314 app_sync_data.launch_type() < extensions::NUM_LAUNCH_TYPES) { | |
benwells
2014/01/06 05:56:31
Nit: Could this check move into AppSyncData::Popul
calamity
2014/01/07 03:29:42
Done.
| |
315 extensions::SetLaunchType(extension_service_, id, | |
316 static_cast<extensions::LaunchType>(app_sync_data.launch_type())); | |
benwells
2014/01/06 05:56:31
Nit: why is this static cast needed? The type is a
calamity
2014/01/07 03:29:42
Done.
| |
317 } | |
318 | |
310 if (!ProcessExtensionSyncDataHelper(app_sync_data.extension_sync_data(), | 319 if (!ProcessExtensionSyncDataHelper(app_sync_data.extension_sync_data(), |
311 syncer::APPS)) { | 320 syncer::APPS)) { |
312 app_sync_bundle_.AddPendingApp(id, app_sync_data); | 321 app_sync_bundle_.AddPendingApp(id, app_sync_data); |
313 extension_service_->CheckForUpdatesSoon(); | 322 extension_service_->CheckForUpdatesSoon(); |
314 return false; | 323 return false; |
315 } | 324 } |
316 | 325 |
317 return true; | 326 return true; |
318 } | 327 } |
319 | 328 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
442 app_sync_bundle_.SyncChangeIfNeeded(extension); | 451 app_sync_bundle_.SyncChangeIfNeeded(extension); |
443 else if (extension_service_->is_ready() && !flare_.is_null()) | 452 else if (extension_service_->is_ready() && !flare_.is_null()) |
444 flare_.Run(syncer::APPS); | 453 flare_.Run(syncer::APPS); |
445 } else if (extensions::sync_helper::IsSyncableExtension(&extension)) { | 454 } else if (extensions::sync_helper::IsSyncableExtension(&extension)) { |
446 if (extension_sync_bundle_.IsSyncing()) | 455 if (extension_sync_bundle_.IsSyncing()) |
447 extension_sync_bundle_.SyncChangeIfNeeded(extension); | 456 extension_sync_bundle_.SyncChangeIfNeeded(extension); |
448 else if (extension_service_->is_ready() && !flare_.is_null()) | 457 else if (extension_service_->is_ready() && !flare_.is_null()) |
449 flare_.Run(syncer::EXTENSIONS); | 458 flare_.Run(syncer::EXTENSIONS); |
450 } | 459 } |
451 } | 460 } |
OLD | NEW |