Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: chrome/browser/extensions/extension_service.cc

Issue 10689097: Enforce the 'requirements' field in manifests. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Conforming to the doc Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <set> 8 #include <set>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 2074 matching lines...) Expand 10 before | Expand all | Expand 10 after
2085 if (!extension->is_theme() && extension->location() != Extension::COMPONENT) 2085 if (!extension->is_theme() && extension->location() != Extension::COMPONENT)
2086 extension_ids.insert(extension->id()); 2086 extension_ids.insert(extension->id());
2087 } 2087 }
2088 2088
2089 child_process_logging::SetActiveExtensions(extension_ids); 2089 child_process_logging::SetActiveExtensions(extension_ids);
2090 } 2090 }
2091 2091
2092 void ExtensionService::OnExtensionInstalled( 2092 void ExtensionService::OnExtensionInstalled(
2093 const Extension* extension, 2093 const Extension* extension,
2094 bool from_webstore, 2094 bool from_webstore,
2095 const StringOrdinal& page_ordinal) { 2095 const StringOrdinal& page_ordinal,
2096 const std::vector<std::string>& requirement_errors) {
2096 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 2097 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
2097 2098
2098 // Ensure extension is deleted unless we transfer ownership. 2099 // Ensure extension is deleted unless we transfer ownership.
2099 scoped_refptr<const Extension> scoped_extension(extension); 2100 scoped_refptr<const Extension> scoped_extension(extension);
2100 const std::string& id = extension->id(); 2101 const std::string& id = extension->id();
2101 // Extensions installed by policy can't be disabled. So even if a previous 2102 // Extensions installed by policy can't be disabled. So even if a previous
2102 // installation disabled the extension, make sure it is now enabled. 2103 // installation disabled the extension, make sure it is now enabled.
2103 bool initial_enable = 2104 bool initial_enable =
2104 !extension_prefs_->IsExtensionDisabled(id) || 2105 !extension_prefs_->IsExtensionDisabled(id) ||
2105 system_->management_policy()->MustRemainEnabled(extension, NULL); 2106 system_->management_policy()->MustRemainEnabled(extension, NULL);
(...skipping 26 matching lines...) Expand all
2132 pending_extension_manager()->Remove(id); 2133 pending_extension_manager()->Remove(id);
2133 } else { 2134 } else {
2134 // We explicitly want to re-enable an uninstalled external 2135 // We explicitly want to re-enable an uninstalled external
2135 // extension; if we're here, that means the user is manually 2136 // extension; if we're here, that means the user is manually
2136 // installing the extension. 2137 // installing the extension.
2137 if (IsExternalExtensionUninstalled(id)) { 2138 if (IsExternalExtensionUninstalled(id)) {
2138 initial_enable = true; 2139 initial_enable = true;
2139 } 2140 }
2140 } 2141 }
2141 2142
2143 // Unsupported requirements overrides the management policy.
2144 if (!requirement_errors.empty()) {
2145 initial_enable = false;
2146 // If the extension was disabled because of unsupported requirements but
2147 // now supports all requirements after an update, enable it.
2148 } else if (extension_prefs_->HasUnsupportedRequirements(id)) {
2149 initial_enable = true;
2150 }
2151
2142 // Do not record the install histograms for upgrades. 2152 // Do not record the install histograms for upgrades.
2143 if (!GetExtensionByIdInternal(extension->id(), true, true, false)) { 2153 if (!GetExtensionByIdInternal(extension->id(), true, true, false)) {
2144 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallType", 2154 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallType",
2145 extension->GetType(), 100); 2155 extension->GetType(), 100);
2146 RecordPermissionMessagesHistogram( 2156 RecordPermissionMessagesHistogram(
2147 extension, "Extensions.Permissions_Install"); 2157 extension, "Extensions.Permissions_Install");
2148 } 2158 }
2149 2159
2150 // Certain extension locations are specific enough that we can 2160 // Certain extension locations are specific enough that we can
2151 // auto-acknowledge any extension that came from one of them. 2161 // auto-acknowledge any extension that came from one of them.
2152 if (extension->location() == Extension::EXTERNAL_POLICY_DOWNLOAD) { 2162 if (extension->location() == Extension::EXTERNAL_POLICY_DOWNLOAD) {
2153 AcknowledgeExternalExtension(extension->id()); 2163 AcknowledgeExternalExtension(extension->id());
2154 } 2164 }
2155 2165
2156 extension_prefs_->OnExtensionInstalled( 2166 extension_prefs_->OnExtensionInstalled(
2157 extension, 2167 extension,
2158 initial_enable ? Extension::ENABLED : Extension::DISABLED, 2168 initial_enable ? Extension::ENABLED : Extension::DISABLED,
2159 from_webstore, 2169 from_webstore,
2160 page_ordinal); 2170 page_ordinal);
2161 2171
2172 if (!requirement_errors.empty()) {
2173 extension_prefs_->SetDisableReason(
2174 id, Extension::DISABLE_UNSUPPORTED_REQUIREMENT);
2175 extension_prefs_->SetUnsupportedRequirements(id, requirement_errors);
2176 }
2177
2162 // Unpacked extensions default to allowing file access, but if that has been 2178 // Unpacked extensions default to allowing file access, but if that has been
2163 // overridden, don't reset the value. 2179 // overridden, don't reset the value.
2164 if (Extension::ShouldAlwaysAllowFileAccess(extension->location()) && 2180 if (Extension::ShouldAlwaysAllowFileAccess(extension->location()) &&
2165 !extension_prefs_->HasAllowFileAccessSetting(id)) { 2181 !extension_prefs_->HasAllowFileAccessSetting(id)) {
2166 extension_prefs_->SetAllowFileAccess(id, true); 2182 extension_prefs_->SetAllowFileAccess(id, true);
2167 } 2183 }
2168 2184
2169 content::NotificationService::current()->Notify( 2185 content::NotificationService::current()->Notify(
2170 chrome::NOTIFICATION_EXTENSION_INSTALLED, 2186 chrome::NOTIFICATION_EXTENSION_INSTALLED,
2171 content::Source<Profile>(profile_), 2187 content::Source<Profile>(profile_),
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
2539 2555
2540 ExtensionService::NaClModuleInfoList::iterator 2556 ExtensionService::NaClModuleInfoList::iterator
2541 ExtensionService::FindNaClModule(const GURL& url) { 2557 ExtensionService::FindNaClModule(const GURL& url) {
2542 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); 2558 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin();
2543 iter != nacl_module_list_.end(); ++iter) { 2559 iter != nacl_module_list_.end(); ++iter) {
2544 if (iter->url == url) 2560 if (iter->url == url)
2545 return iter; 2561 return iter;
2546 } 2562 }
2547 return nacl_module_list_.end(); 2563 return nacl_module_list_.end();
2548 } 2564 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698