Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <iterator> | 10 #include <iterator> |
| (...skipping 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1633 if (previously_disabled && | 1633 if (previously_disabled && |
| 1634 (disable_reasons & Extension::DEPRECATED_DISABLE_UNKNOWN_FROM_SYNC)) { | 1634 (disable_reasons & Extension::DEPRECATED_DISABLE_UNKNOWN_FROM_SYNC)) { |
| 1635 // Remove the DISABLE_UNKNOWN_FROM_SYNC reason. | 1635 // Remove the DISABLE_UNKNOWN_FROM_SYNC reason. |
| 1636 disable_reasons &= ~Extension::DEPRECATED_DISABLE_UNKNOWN_FROM_SYNC; | 1636 disable_reasons &= ~Extension::DEPRECATED_DISABLE_UNKNOWN_FROM_SYNC; |
| 1637 extension_prefs_->RemoveDisableReason( | 1637 extension_prefs_->RemoveDisableReason( |
| 1638 extension->id(), Extension::DEPRECATED_DISABLE_UNKNOWN_FROM_SYNC); | 1638 extension->id(), Extension::DEPRECATED_DISABLE_UNKNOWN_FROM_SYNC); |
| 1639 // If there was no privilege increase, it was likely disabled by the user. | 1639 // If there was no privilege increase, it was likely disabled by the user. |
| 1640 if (!is_privilege_increase) | 1640 if (!is_privilege_increase) |
| 1641 disable_reasons |= Extension::DISABLE_USER_ACTION; | 1641 disable_reasons |= Extension::DISABLE_USER_ACTION; |
| 1642 } | 1642 } |
| 1643 | |
| 1644 // If the extension is disabled due to a permissions increase, but does in | |
| 1645 // fact have all permissions, remove that disable reason. | |
|
Devlin
2016/06/02 16:06:45
Might also be worth adding a TODO to decide whethe
Marc Treib
2016/06/02 16:36:14
Yup, that's the main reason I hadn't actually sent
Devlin
2016/06/03 15:26:58
Whoops, sorry for jumping the gun. Looked from th
| |
| 1646 if (previously_disabled && !is_privilege_increase && | |
| 1647 (disable_reasons & Extension::DISABLE_PERMISSIONS_INCREASE)) { | |
| 1648 // Remove the DISABLE_UNKNOWN_FROM_SYNC reason. | |
| 1649 disable_reasons &= ~Extension::DISABLE_PERMISSIONS_INCREASE; | |
| 1650 extension_prefs_->RemoveDisableReason( | |
| 1651 extension->id(), Extension::DISABLE_PERMISSIONS_INCREASE); | |
| 1652 } | |
| 1643 } | 1653 } |
| 1644 | 1654 |
| 1645 // Extension has changed permissions significantly. Disable it. A | 1655 // Extension has changed permissions significantly. Disable it. A |
| 1646 // notification should be sent by the caller. If the extension is already | 1656 // notification should be sent by the caller. If the extension is already |
| 1647 // disabled because it was installed remotely, don't add another disable | 1657 // disabled because it was installed remotely, don't add another disable |
| 1648 // reason. | 1658 // reason. |
| 1649 if (is_privilege_increase && | 1659 if (is_privilege_increase && |
| 1650 !(disable_reasons & Extension::DISABLE_REMOTE_INSTALL)) { | 1660 !(disable_reasons & Extension::DISABLE_REMOTE_INSTALL)) { |
| 1651 disable_reasons |= Extension::DISABLE_PERMISSIONS_INCREASE; | 1661 disable_reasons |= Extension::DISABLE_PERMISSIONS_INCREASE; |
| 1652 if (!extension_prefs_->DidExtensionEscalatePermissions(extension->id())) | 1662 if (!extension_prefs_->DidExtensionEscalatePermissions(extension->id())) |
| 1653 RecordPermissionMessagesHistogram(extension, "AutoDisable"); | 1663 RecordPermissionMessagesHistogram(extension, "AutoDisable"); |
| 1654 | 1664 |
| 1655 #if defined(ENABLE_SUPERVISED_USERS) | 1665 #if defined(ENABLE_SUPERVISED_USERS) |
| 1656 // If a custodian-installed extension is disabled for a supervised user due | 1666 // If a custodian-installed extension is disabled for a supervised user due |
| 1657 // to a permissions increase, send a request to the custodian if the | 1667 // to a permissions increase, send a request to the custodian if the |
| 1658 // supervised user themselves can't re-enable the extension. | 1668 // supervised user themselves can't re-enable the extension. |
| 1659 if (extensions::util::IsExtensionSupervised(extension, profile_) && | 1669 if (extensions::util::IsExtensionSupervised(extension, profile_) && |
| 1660 extensions::util::NeedCustodianApprovalForPermissionIncrease( | 1670 extensions::util::NeedCustodianApprovalForPermissionIncrease( |
| 1661 profile_) && | 1671 profile_) && |
| 1662 !ExtensionSyncService::Get(profile_)->HasPendingReenable( | 1672 !ExtensionSyncService::Get(profile_)->HasPendingReenable( |
| 1663 extension->id(), *extension->version())) { | 1673 extension->id(), *extension->version())) { |
| 1664 SupervisedUserService* supervised_user_service = | 1674 SupervisedUserService* supervised_user_service = |
| 1665 SupervisedUserServiceFactory::GetForProfile(profile_); | 1675 SupervisedUserServiceFactory::GetForProfile(profile_); |
| 1666 supervised_user_service->AddExtensionUpdateRequest(extension->id(), | 1676 supervised_user_service->AddExtensionUpdateRequest(extension->id(), |
| 1667 *extension->version()); | 1677 *extension->version()); |
| 1668 } | 1678 } |
| 1669 #endif | 1679 #endif |
| 1670 } | 1680 } |
| 1671 if (disable_reasons != Extension::DISABLE_NONE) | 1681 |
| 1682 if (disable_reasons == Extension::DISABLE_NONE) | |
| 1683 extension_prefs_->SetExtensionEnabled(extension->id()); | |
| 1684 else | |
| 1672 extension_prefs_->SetExtensionDisabled(extension->id(), disable_reasons); | 1685 extension_prefs_->SetExtensionDisabled(extension->id(), disable_reasons); |
| 1673 } | 1686 } |
| 1674 | 1687 |
| 1675 void ExtensionService::UpdateActiveExtensionsInCrashReporter() { | 1688 void ExtensionService::UpdateActiveExtensionsInCrashReporter() { |
| 1676 std::set<std::string> extension_ids; | 1689 std::set<std::string> extension_ids; |
| 1677 for (const auto& extension : registry_->enabled_extensions()) { | 1690 for (const auto& extension : registry_->enabled_extensions()) { |
| 1678 if (!extension->is_theme() && extension->location() != Manifest::COMPONENT) | 1691 if (!extension->is_theme() && extension->location() != Manifest::COMPONENT) |
| 1679 extension_ids.insert(extension->id()); | 1692 extension_ids.insert(extension->id()); |
| 1680 } | 1693 } |
| 1681 | 1694 |
| (...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2439 } | 2452 } |
| 2440 | 2453 |
| 2441 void ExtensionService::OnProfileDestructionStarted() { | 2454 void ExtensionService::OnProfileDestructionStarted() { |
| 2442 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); | 2455 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); |
| 2443 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); | 2456 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); |
| 2444 it != ids_to_unload.end(); | 2457 it != ids_to_unload.end(); |
| 2445 ++it) { | 2458 ++it) { |
| 2446 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); | 2459 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); |
| 2447 } | 2460 } |
| 2448 } | 2461 } |
| OLD | NEW |