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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 90 |
91 using content::BrowserContext; | 91 using content::BrowserContext; |
92 using content::BrowserThread; | 92 using content::BrowserThread; |
93 using content::DevToolsAgentHost; | 93 using content::DevToolsAgentHost; |
94 using extensions::CrxInstaller; | 94 using extensions::CrxInstaller; |
95 using extensions::Extension; | 95 using extensions::Extension; |
96 using extensions::ExtensionIdSet; | 96 using extensions::ExtensionIdSet; |
97 using extensions::ExtensionInfo; | 97 using extensions::ExtensionInfo; |
98 using extensions::ExtensionRegistry; | 98 using extensions::ExtensionRegistry; |
99 using extensions::ExtensionSet; | 99 using extensions::ExtensionSet; |
100 using extensions::FeatureSwitch; | |
101 using extensions::InstallVerifier; | 100 using extensions::InstallVerifier; |
102 using extensions::ManagementPolicy; | 101 using extensions::ManagementPolicy; |
103 using extensions::Manifest; | 102 using extensions::Manifest; |
104 using extensions::PermissionMessage; | 103 using extensions::PermissionMessage; |
105 using extensions::PermissionMessages; | 104 using extensions::PermissionMessages; |
106 using extensions::PermissionSet; | 105 using extensions::PermissionSet; |
107 using extensions::SharedModuleInfo; | 106 using extensions::SharedModuleInfo; |
108 using extensions::SharedModuleService; | 107 using extensions::SharedModuleService; |
109 using extensions::UnloadedExtensionInfo; | 108 using extensions::UnloadedExtensionInfo; |
110 | 109 |
(...skipping 2022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2133 | 2132 |
2134 bool ExtensionService::ShouldEnableOnInstall(const Extension* extension) { | 2133 bool ExtensionService::ShouldEnableOnInstall(const Extension* extension) { |
2135 // Extensions installed by policy can't be disabled. So even if a previous | 2134 // Extensions installed by policy can't be disabled. So even if a previous |
2136 // installation disabled the extension, make sure it is now enabled. | 2135 // installation disabled the extension, make sure it is now enabled. |
2137 if (system_->management_policy()->MustRemainEnabled(extension, NULL)) | 2136 if (system_->management_policy()->MustRemainEnabled(extension, NULL)) |
2138 return true; | 2137 return true; |
2139 | 2138 |
2140 if (extension_prefs_->IsExtensionDisabled(extension->id())) | 2139 if (extension_prefs_->IsExtensionDisabled(extension->id())) |
2141 return false; | 2140 return false; |
2142 | 2141 |
2143 if (FeatureSwitch::prompt_for_external_extensions()->IsEnabled()) { | |
2144 // External extensions are initially disabled. We prompt the user before | 2142 // External extensions are initially disabled. We prompt the user before |
2145 // enabling them. Hosted apps are excepted because they are not dangerous | 2143 // enabling them. Hosted apps are excepted because they are not dangerous |
2146 // (they need to be launched by the user anyway). | 2144 // (they need to be launched by the user anyway). |
2147 if (extension->GetType() != Manifest::TYPE_HOSTED_APP && | 2145 if (extension->GetType() != Manifest::TYPE_HOSTED_APP && |
2148 Manifest::IsExternalLocation(extension->location()) && | 2146 Manifest::IsExternalLocation(extension->location()) && |
2149 !extension_prefs_->IsExternalExtensionAcknowledged(extension->id())) { | 2147 !extension_prefs_->IsExternalExtensionAcknowledged(extension->id())) { |
2150 return false; | 2148 return false; |
2151 } | 2149 } |
2152 } | |
2153 | 2150 |
2154 return true; | 2151 return true; |
2155 } | 2152 } |
2156 | 2153 |
2157 bool ExtensionService::ShouldDelayExtensionUpdate( | 2154 bool ExtensionService::ShouldDelayExtensionUpdate( |
2158 const std::string& extension_id, | 2155 const std::string& extension_id, |
2159 bool install_immediately) const { | 2156 bool install_immediately) const { |
2160 const char kOnUpdateAvailableEvent[] = "runtime.onUpdateAvailable"; | 2157 const char kOnUpdateAvailableEvent[] = "runtime.onUpdateAvailable"; |
2161 | 2158 |
2162 // If delayed updates are globally disabled, or just for this extension, | 2159 // If delayed updates are globally disabled, or just for this extension, |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2367 } | 2364 } |
2368 | 2365 |
2369 void ExtensionService::OnProfileDestructionStarted() { | 2366 void ExtensionService::OnProfileDestructionStarted() { |
2370 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); | 2367 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); |
2371 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); | 2368 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); |
2372 it != ids_to_unload.end(); | 2369 it != ids_to_unload.end(); |
2373 ++it) { | 2370 ++it) { |
2374 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); | 2371 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); |
2375 } | 2372 } |
2376 } | 2373 } |
OLD | NEW |