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/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 extension_prefs_->app_sorting()->FixNTPOrdinalCollisions(); | 276 extension_prefs_->app_sorting()->FixNTPOrdinalCollisions(); |
277 | 277 |
278 return syncer::SyncError(); | 278 return syncer::SyncError(); |
279 } | 279 } |
280 | 280 |
281 ExtensionSyncData ExtensionSyncService::GetExtensionSyncData( | 281 ExtensionSyncData ExtensionSyncService::GetExtensionSyncData( |
282 const Extension& extension) const { | 282 const Extension& extension) const { |
283 return ExtensionSyncData( | 283 return ExtensionSyncData( |
284 extension, | 284 extension, |
285 extension_service_->IsExtensionEnabled(extension.id()), | 285 extension_service_->IsExtensionEnabled(extension.id()), |
| 286 extension_prefs_->GetDisableReasons(extension.id()), |
286 extensions::util::IsIncognitoEnabled(extension.id(), profile_), | 287 extensions::util::IsIncognitoEnabled(extension.id(), profile_), |
287 extension_prefs_->HasDisableReason(extension.id(), | 288 extension_prefs_->HasDisableReason(extension.id(), |
288 Extension::DISABLE_REMOTE_INSTALL), | 289 Extension::DISABLE_REMOTE_INSTALL), |
289 GetAllowedOnAllUrlsOptionalBoolean(extension.id(), profile_)); | 290 GetAllowedOnAllUrlsOptionalBoolean(extension.id(), profile_)); |
290 } | 291 } |
291 | 292 |
292 AppSyncData ExtensionSyncService::GetAppSyncData( | 293 AppSyncData ExtensionSyncService::GetAppSyncData( |
293 const Extension& extension) const { | 294 const Extension& extension) const { |
294 return AppSyncData( | 295 return AppSyncData( |
295 extension, extension_service_->IsExtensionEnabled(extension.id()), | 296 extension, extension_service_->IsExtensionEnabled(extension.id()), |
| 297 extension_prefs_->GetDisableReasons(extension.id()), |
296 extensions::util::IsIncognitoEnabled(extension.id(), profile_), | 298 extensions::util::IsIncognitoEnabled(extension.id(), profile_), |
297 extension_prefs_->HasDisableReason(extension.id(), | 299 extension_prefs_->HasDisableReason(extension.id(), |
298 Extension::DISABLE_REMOTE_INSTALL), | 300 Extension::DISABLE_REMOTE_INSTALL), |
299 GetAllowedOnAllUrlsOptionalBoolean(extension.id(), profile_), | 301 GetAllowedOnAllUrlsOptionalBoolean(extension.id(), profile_), |
300 extension_prefs_->app_sorting()->GetAppLaunchOrdinal(extension.id()), | 302 extension_prefs_->app_sorting()->GetAppLaunchOrdinal(extension.id()), |
301 extension_prefs_->app_sorting()->GetPageOrdinal(extension.id()), | 303 extension_prefs_->app_sorting()->GetPageOrdinal(extension.id()), |
302 extensions::GetLaunchTypePrefValue(extension_prefs_, extension.id())); | 304 extensions::GetLaunchTypePrefValue(extension_prefs_, extension.id())); |
303 } | 305 } |
304 | 306 |
305 std::vector<ExtensionSyncData> | 307 std::vector<ExtensionSyncData> |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 // been installed yet, so we don't know if the disable reason was a | 511 // been installed yet, so we don't know if the disable reason was a |
510 // permissions increase. That will be updated once CheckPermissionsIncrease | 512 // permissions increase. That will be updated once CheckPermissionsIncrease |
511 // is called for it. | 513 // is called for it. |
512 // However if the extension is marked as a remote install in sync, we know | 514 // However if the extension is marked as a remote install in sync, we know |
513 // what the disable reason is, so set it to that directly. Note that when | 515 // what the disable reason is, so set it to that directly. Note that when |
514 // CheckPermissionsIncrease runs, it might still add permissions increase | 516 // CheckPermissionsIncrease runs, it might still add permissions increase |
515 // as a disable reason for the extension. | 517 // as a disable reason for the extension. |
516 if (extension_sync_data.enabled()) { | 518 if (extension_sync_data.enabled()) { |
517 extension_service_->EnableExtension(id); | 519 extension_service_->EnableExtension(id); |
518 } else if (!IsPendingEnable(id)) { | 520 } else if (!IsPendingEnable(id)) { |
| 521 int disable_reasons = extension_sync_data.disable_reasons(); |
519 if (extension_sync_data.remote_install()) { | 522 if (extension_sync_data.remote_install()) { |
520 extension_service_->DisableExtension(id, | 523 // In the non-legacy case (>=M45) where disable reasons are synced at all, |
521 Extension::DISABLE_REMOTE_INSTALL); | 524 // DISABLE_REMOTE_INSTALL should be among them already. |
522 } else { | 525 DCHECK(!disable_reasons || |
523 extension_service_->DisableExtension( | 526 (disable_reasons & Extension::DISABLE_REMOTE_INSTALL)); |
524 id, Extension::DISABLE_UNKNOWN_FROM_SYNC); | 527 disable_reasons |= Extension::DISABLE_REMOTE_INSTALL; |
525 } | 528 } |
| 529 if (!disable_reasons) { |
| 530 // Legacy case (<M45), from before we synced disable reasons (see |
| 531 // crbug.com/484214). |
| 532 disable_reasons = Extension::DISABLE_UNKNOWN_FROM_SYNC; |
| 533 } |
| 534 |
| 535 extension_service_->DisableExtension( |
| 536 id, Extension::DisableReason(disable_reasons)); |
526 } | 537 } |
527 | 538 |
528 // We need to cache some version information here because setting the | 539 // We need to cache some version information here because setting the |
529 // incognito flag invalidates the |extension| pointer (it reloads the | 540 // incognito flag invalidates the |extension| pointer (it reloads the |
530 // extension). | 541 // extension). |
531 bool extension_installed = (extension != NULL); | 542 bool extension_installed = (extension != NULL); |
532 int version_compare_result = extension ? | 543 int version_compare_result = extension ? |
533 extension->version()->CompareTo(extension_sync_data.version()) : 0; | 544 extension->version()->CompareTo(extension_sync_data.version()) : 0; |
534 | 545 |
535 // If the target extension has already been installed ephemerally, it can | 546 // If the target extension has already been installed ephemerally, it can |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 app_sync_bundle_.SyncChangeIfNeeded(extension); | 600 app_sync_bundle_.SyncChangeIfNeeded(extension); |
590 else if (extension_service_->is_ready() && !flare_.is_null()) | 601 else if (extension_service_->is_ready() && !flare_.is_null()) |
591 flare_.Run(syncer::APPS); | 602 flare_.Run(syncer::APPS); |
592 } else if (extensions::util::ShouldSyncExtension(&extension, profile_)) { | 603 } else if (extensions::util::ShouldSyncExtension(&extension, profile_)) { |
593 if (extension_sync_bundle_.IsSyncing()) | 604 if (extension_sync_bundle_.IsSyncing()) |
594 extension_sync_bundle_.SyncChangeIfNeeded(extension); | 605 extension_sync_bundle_.SyncChangeIfNeeded(extension); |
595 else if (extension_service_->is_ready() && !flare_.is_null()) | 606 else if (extension_service_->is_ready() && !flare_.is_null()) |
596 flare_.Run(syncer::EXTENSIONS); | 607 flare_.Run(syncer::EXTENSIONS); |
597 } | 608 } |
598 } | 609 } |
OLD | NEW |