Chromium Code Reviews| 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 where we sync disable reasons, |
| 521 Extension::DISABLE_REMOTE_INSTALL); | 524 // DISABLE_REMOTE_INSTALL should be there already. |
|
not at google - send to devlin
2015/05/19 14:32:10
It might be because I just woke up, but why is thi
Marc Treib
2015/05/19 15:30:55
What I'm checking is: If there are any disable rea
| |
| 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, from before we synced disable reasons. | |
|
not at google - send to devlin
2015/05/19 14:32:10
You might want to link to the bug# or mention the
Marc Treib
2015/05/19 15:30:55
Done.
| |
| 531 disable_reasons = Extension::DISABLE_UNKNOWN_FROM_SYNC; | |
|
not at google - send to devlin
2015/05/12 18:04:17
This is important to test, and rather than lumping
Marc Treib
2015/05/19 12:12:03
"This" being the legacy case, where no disable rea
not at google - send to devlin
2015/05/19 14:32:10
yeah that's what I mean, thanks.
| |
| 532 } | |
| 533 | |
| 534 extension_service_->DisableExtension( | |
| 535 id, Extension::DisableReason(disable_reasons)); | |
| 526 } | 536 } |
| 527 | 537 |
| 528 // We need to cache some version information here because setting the | 538 // We need to cache some version information here because setting the |
| 529 // incognito flag invalidates the |extension| pointer (it reloads the | 539 // incognito flag invalidates the |extension| pointer (it reloads the |
| 530 // extension). | 540 // extension). |
| 531 bool extension_installed = (extension != NULL); | 541 bool extension_installed = (extension != NULL); |
| 532 int version_compare_result = extension ? | 542 int version_compare_result = extension ? |
| 533 extension->version()->CompareTo(extension_sync_data.version()) : 0; | 543 extension->version()->CompareTo(extension_sync_data.version()) : 0; |
| 534 | 544 |
| 535 // If the target extension has already been installed ephemerally, it can | 545 // 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); | 599 app_sync_bundle_.SyncChangeIfNeeded(extension); |
| 590 else if (extension_service_->is_ready() && !flare_.is_null()) | 600 else if (extension_service_->is_ready() && !flare_.is_null()) |
| 591 flare_.Run(syncer::APPS); | 601 flare_.Run(syncer::APPS); |
| 592 } else if (extensions::util::ShouldSyncExtension(&extension, profile_)) { | 602 } else if (extensions::util::ShouldSyncExtension(&extension, profile_)) { |
| 593 if (extension_sync_bundle_.IsSyncing()) | 603 if (extension_sync_bundle_.IsSyncing()) |
| 594 extension_sync_bundle_.SyncChangeIfNeeded(extension); | 604 extension_sync_bundle_.SyncChangeIfNeeded(extension); |
| 595 else if (extension_service_->is_ready() && !flare_.is_null()) | 605 else if (extension_service_->is_ready() && !flare_.is_null()) |
| 596 flare_.Run(syncer::EXTENSIONS); | 606 flare_.Run(syncer::EXTENSIONS); |
| 597 } | 607 } |
| 598 } | 608 } |
| OLD | NEW |