| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_service.h" | 5 #include "chrome/browser/extensions/extension_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 client.reset(ExtensionInstallUI::CreateInstallPromptWithProfile(profile_)); | 537 client.reset(ExtensionInstallUI::CreateInstallPromptWithProfile(profile_)); |
| 538 | 538 |
| 539 scoped_refptr<CrxInstaller> installer( | 539 scoped_refptr<CrxInstaller> installer( |
| 540 CrxInstaller::Create(this, client.Pass())); | 540 CrxInstaller::Create(this, client.Pass())); |
| 541 installer->set_expected_id(id); | 541 installer->set_expected_id(id); |
| 542 int creation_flags = Extension::NO_FLAGS; | 542 int creation_flags = Extension::NO_FLAGS; |
| 543 if (pending_extension_info) { | 543 if (pending_extension_info) { |
| 544 installer->set_install_source(pending_extension_info->install_source()); | 544 installer->set_install_source(pending_extension_info->install_source()); |
| 545 if (pending_extension_info->install_silently()) | 545 if (pending_extension_info->install_silently()) |
| 546 installer->set_allow_silent_install(true); | 546 installer->set_allow_silent_install(true); |
| 547 if (pending_extension_info->remote_install()) |
| 548 installer->set_grant_permissions(false); |
| 547 creation_flags = pending_extension_info->creation_flags(); | 549 creation_flags = pending_extension_info->creation_flags(); |
| 548 if (pending_extension_info->mark_acknowledged()) | 550 if (pending_extension_info->mark_acknowledged()) |
| 549 AcknowledgeExternalExtension(id); | 551 AcknowledgeExternalExtension(id); |
| 550 } else if (extension) { | 552 } else if (extension) { |
| 551 installer->set_install_source(extension->location()); | 553 installer->set_install_source(extension->location()); |
| 552 } | 554 } |
| 553 // If the extension was installed from or has migrated to the webstore, or | 555 // If the extension was installed from or has migrated to the webstore, or |
| 554 // its auto-update URL is from the webstore, treat it as a webstore install. | 556 // its auto-update URL is from the webstore, treat it as a webstore install. |
| 555 // Note that we ignore some older extensions with blank auto-update URLs | 557 // Note that we ignore some older extensions with blank auto-update URLs |
| 556 // because we are mostly concerned with restrictions on NaCl extensions, | 558 // because we are mostly concerned with restrictions on NaCl extensions, |
| (...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1485 } else if (!reloading && | 1487 } else if (!reloading && |
| 1486 extension_prefs_->IsExtensionDisabled(extension->id())) { | 1488 extension_prefs_->IsExtensionDisabled(extension->id())) { |
| 1487 registry_->AddDisabled(extension); | 1489 registry_->AddDisabled(extension); |
| 1488 if (extension_sync_service_) | 1490 if (extension_sync_service_) |
| 1489 extension_sync_service_->SyncExtensionChangeIfNeeded(*extension); | 1491 extension_sync_service_->SyncExtensionChangeIfNeeded(*extension); |
| 1490 content::NotificationService::current()->Notify( | 1492 content::NotificationService::current()->Notify( |
| 1491 chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, | 1493 chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, |
| 1492 content::Source<Profile>(profile_), | 1494 content::Source<Profile>(profile_), |
| 1493 content::Details<const Extension>(extension)); | 1495 content::Details<const Extension>(extension)); |
| 1494 | 1496 |
| 1495 // Show the extension disabled error if a permissions increase was the | 1497 // Show the extension disabled error if a permissions increase or a remote |
| 1496 // only reason it was disabled. | 1498 // installation is the reason it was disabled, and no other reasons exist. |
| 1497 if (extension_prefs_->GetDisableReasons(extension->id()) == | 1499 int reasons = extension_prefs_->GetDisableReasons(extension->id()); |
| 1498 Extension::DISABLE_PERMISSIONS_INCREASE) { | 1500 const int kReasonMask = Extension::DISABLE_PERMISSIONS_INCREASE | |
| 1499 extensions::AddExtensionDisabledError(this, extension); | 1501 Extension::DISABLE_REMOTE_INSTALL; |
| 1502 if (reasons & kReasonMask && !(reasons & ~kReasonMask)) { |
| 1503 extensions::AddExtensionDisabledError( |
| 1504 this, |
| 1505 extension, |
| 1506 extension_prefs_->HasDisableReason( |
| 1507 extension->id(), Extension::DISABLE_REMOTE_INSTALL)); |
| 1500 } | 1508 } |
| 1501 } else if (reloading) { | 1509 } else if (reloading) { |
| 1502 // Replace the old extension with the new version. | 1510 // Replace the old extension with the new version. |
| 1503 CHECK(!registry_->AddDisabled(extension)); | 1511 CHECK(!registry_->AddDisabled(extension)); |
| 1504 EnableExtension(extension->id()); | 1512 EnableExtension(extension->id()); |
| 1505 } else { | 1513 } else { |
| 1506 // All apps that are displayed in the launcher are ordered by their ordinals | 1514 // All apps that are displayed in the launcher are ordered by their ordinals |
| 1507 // so we must ensure they have valid ordinals. | 1515 // so we must ensure they have valid ordinals. |
| 1508 if (extension->RequiresSortOrdinal()) { | 1516 if (extension->RequiresSortOrdinal()) { |
| 1509 if (!extension->ShouldDisplayInNewTabPage()) { | 1517 if (!extension->ShouldDisplayInNewTabPage()) { |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1651 disable_reasons == Extension::DISABLE_UNKNOWN_FROM_SYNC) { | 1659 disable_reasons == Extension::DISABLE_UNKNOWN_FROM_SYNC) { |
| 1652 // Remove the DISABLE_UNKNOWN_FROM_SYNC reason. | 1660 // Remove the DISABLE_UNKNOWN_FROM_SYNC reason. |
| 1653 extension_prefs_->ClearDisableReasons(extension->id()); | 1661 extension_prefs_->ClearDisableReasons(extension->id()); |
| 1654 if (!is_privilege_increase) | 1662 if (!is_privilege_increase) |
| 1655 disable_reasons |= Extension::DISABLE_USER_ACTION; | 1663 disable_reasons |= Extension::DISABLE_USER_ACTION; |
| 1656 } | 1664 } |
| 1657 disable_reasons &= ~Extension::DISABLE_UNKNOWN_FROM_SYNC; | 1665 disable_reasons &= ~Extension::DISABLE_UNKNOWN_FROM_SYNC; |
| 1658 } | 1666 } |
| 1659 | 1667 |
| 1660 // Extension has changed permissions significantly. Disable it. A | 1668 // Extension has changed permissions significantly. Disable it. A |
| 1661 // notification should be sent by the caller. | 1669 // notification should be sent by the caller. If the extension is already |
| 1662 if (is_privilege_increase) { | 1670 // disabled because it was installed remotely, don't add another disable |
| 1671 // reason, but instead always set the "did escalate permissions" flag, to |
| 1672 // ensure enabling it will always show a warning. |
| 1673 if (disable_reasons == Extension::DISABLE_REMOTE_INSTALL) { |
| 1674 extension_prefs_->SetDidExtensionEscalatePermissions(extension, true); |
| 1675 } else if (is_privilege_increase) { |
| 1663 disable_reasons |= Extension::DISABLE_PERMISSIONS_INCREASE; | 1676 disable_reasons |= Extension::DISABLE_PERMISSIONS_INCREASE; |
| 1664 if (!extension_prefs_->DidExtensionEscalatePermissions(extension->id())) { | 1677 if (!extension_prefs_->DidExtensionEscalatePermissions(extension->id())) { |
| 1665 RecordPermissionMessagesHistogram( | 1678 RecordPermissionMessagesHistogram( |
| 1666 extension, "Extensions.Permissions_AutoDisable"); | 1679 extension, "Extensions.Permissions_AutoDisable"); |
| 1667 } | 1680 } |
| 1668 extension_prefs_->SetExtensionState(extension->id(), Extension::DISABLED); | 1681 extension_prefs_->SetExtensionState(extension->id(), Extension::DISABLED); |
| 1669 extension_prefs_->SetDidExtensionEscalatePermissions(extension, true); | 1682 extension_prefs_->SetDidExtensionEscalatePermissions(extension, true); |
| 1670 } | 1683 } |
| 1671 if (disable_reasons != Extension::DISABLE_NONE) { | 1684 if (disable_reasons != Extension::DISABLE_NONE) { |
| 1672 extension_prefs_->AddDisableReason( | 1685 extension_prefs_->AddDisableReason( |
| (...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2408 void ExtensionService::UnloadAllExtensionsInternal() { | 2421 void ExtensionService::UnloadAllExtensionsInternal() { |
| 2409 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); | 2422 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); |
| 2410 | 2423 |
| 2411 registry_->ClearAll(); | 2424 registry_->ClearAll(); |
| 2412 system_->runtime_data()->ClearAll(); | 2425 system_->runtime_data()->ClearAll(); |
| 2413 | 2426 |
| 2414 // TODO(erikkay) should there be a notification for this? We can't use | 2427 // TODO(erikkay) should there be a notification for this? We can't use |
| 2415 // EXTENSION_UNLOADED since that implies that the extension has been disabled | 2428 // EXTENSION_UNLOADED since that implies that the extension has been disabled |
| 2416 // or uninstalled. | 2429 // or uninstalled. |
| 2417 } | 2430 } |
| OLD | NEW |