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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 using extensions::PermissionSet; | 120 using extensions::PermissionSet; |
121 using extensions::SharedModuleInfo; | 121 using extensions::SharedModuleInfo; |
122 using extensions::SharedModuleService; | 122 using extensions::SharedModuleService; |
123 using extensions::UnloadedExtensionInfo; | 123 using extensions::UnloadedExtensionInfo; |
124 | 124 |
125 namespace { | 125 namespace { |
126 | 126 |
127 // Wait this many seconds after an extensions becomes idle before updating it. | 127 // Wait this many seconds after an extensions becomes idle before updating it. |
128 const int kUpdateIdleDelay = 5; | 128 const int kUpdateIdleDelay = 5; |
129 | 129 |
130 #if defined(ENABLE_SUPERVISED_USERS) | |
131 // Callback for SupervisedUserService::AddExtensionUpdateRequest. | |
132 void ExtensionUpdateRequestSent(const std::string& id, bool success) { | |
133 LOG_IF(WARNING, !success) << "Failed sending update request for " << id; | |
134 } | |
135 #endif | |
136 | |
137 } // namespace | 130 } // namespace |
138 | 131 |
139 // ExtensionService. | 132 // ExtensionService. |
140 | 133 |
141 void ExtensionService::CheckExternalUninstall(const std::string& id) { | 134 void ExtensionService::CheckExternalUninstall(const std::string& id) { |
142 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 135 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
143 | 136 |
144 // Check if the providers know about this extension. | 137 // Check if the providers know about this extension. |
145 extensions::ProviderCollection::const_iterator i; | 138 extensions::ProviderCollection::const_iterator i; |
146 for (i = external_extension_providers_.begin(); | 139 for (i = external_extension_providers_.begin(); |
(...skipping 1495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1642 !(disable_reasons & Extension::DISABLE_REMOTE_INSTALL)) { | 1635 !(disable_reasons & Extension::DISABLE_REMOTE_INSTALL)) { |
1643 disable_reasons |= Extension::DISABLE_PERMISSIONS_INCREASE; | 1636 disable_reasons |= Extension::DISABLE_PERMISSIONS_INCREASE; |
1644 if (!extension_prefs_->DidExtensionEscalatePermissions(extension->id())) | 1637 if (!extension_prefs_->DidExtensionEscalatePermissions(extension->id())) |
1645 RecordPermissionMessagesHistogram(extension, "AutoDisable"); | 1638 RecordPermissionMessagesHistogram(extension, "AutoDisable"); |
1646 | 1639 |
1647 #if defined(ENABLE_SUPERVISED_USERS) | 1640 #if defined(ENABLE_SUPERVISED_USERS) |
1648 // If a custodian-installed extension is disabled for a supervised user due | 1641 // If a custodian-installed extension is disabled for a supervised user due |
1649 // to a permissions increase, send a request to the custodian if the | 1642 // to a permissions increase, send a request to the custodian if the |
1650 // supervised user themselves can't re-enable the extension. | 1643 // supervised user themselves can't re-enable the extension. |
1651 if (extensions::util::IsExtensionSupervised(extension, profile_) && | 1644 if (extensions::util::IsExtensionSupervised(extension, profile_) && |
1652 extensions::util::NeedCustodianApprovalForPermissionIncrease()) { | 1645 extensions::util::NeedCustodianApprovalForPermissionIncrease() && |
| 1646 !ExtensionSyncService::Get(profile_)->HasPendingReenable( |
| 1647 extension->id(), *extension->version())) { |
1653 SupervisedUserService* supervised_user_service = | 1648 SupervisedUserService* supervised_user_service = |
1654 SupervisedUserServiceFactory::GetForProfile(profile_); | 1649 SupervisedUserServiceFactory::GetForProfile(profile_); |
1655 supervised_user_service->AddExtensionUpdateRequest( | 1650 supervised_user_service->AddExtensionUpdateRequest(extension->id(), |
1656 extension->id(), *extension->version(), | 1651 *extension->version()); |
1657 base::Bind(ExtensionUpdateRequestSent, extension->id())); | |
1658 } | 1652 } |
1659 #endif | 1653 #endif |
1660 } | 1654 } |
1661 if (disable_reasons != Extension::DISABLE_NONE) | 1655 if (disable_reasons != Extension::DISABLE_NONE) |
1662 extension_prefs_->SetExtensionDisabled(extension->id(), disable_reasons); | 1656 extension_prefs_->SetExtensionDisabled(extension->id(), disable_reasons); |
1663 } | 1657 } |
1664 | 1658 |
1665 void ExtensionService::UpdateActiveExtensionsInCrashReporter() { | 1659 void ExtensionService::UpdateActiveExtensionsInCrashReporter() { |
1666 std::set<std::string> extension_ids; | 1660 std::set<std::string> extension_ids; |
1667 const ExtensionSet& extensions = registry_->enabled_extensions(); | 1661 const ExtensionSet& extensions = registry_->enabled_extensions(); |
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2557 } | 2551 } |
2558 | 2552 |
2559 void ExtensionService::OnProfileDestructionStarted() { | 2553 void ExtensionService::OnProfileDestructionStarted() { |
2560 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); | 2554 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); |
2561 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); | 2555 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); |
2562 it != ids_to_unload.end(); | 2556 it != ids_to_unload.end(); |
2563 ++it) { | 2557 ++it) { |
2564 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); | 2558 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); |
2565 } | 2559 } |
2566 } | 2560 } |
OLD | NEW |