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

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: 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 2075 matching lines...) Expand 10 before | Expand all | Expand 10 after
2086 if (!extension->is_theme() && extension->location() != Extension::COMPONENT) 2086 if (!extension->is_theme() && extension->location() != Extension::COMPONENT)
2087 extension_ids.insert(extension->id()); 2087 extension_ids.insert(extension->id());
2088 } 2088 }
2089 2089
2090 child_process_logging::SetActiveExtensions(extension_ids); 2090 child_process_logging::SetActiveExtensions(extension_ids);
2091 } 2091 }
2092 2092
2093 void ExtensionService::OnExtensionInstalled( 2093 void ExtensionService::OnExtensionInstalled(
2094 const Extension* extension, 2094 const Extension* extension,
2095 bool from_webstore, 2095 bool from_webstore,
2096 const StringOrdinal& page_ordinal) { 2096 const StringOrdinal& page_ordinal,
2097 const std::vector<std::string>& requirement_errors) {
2097 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 2098 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
2098 2099
2099 // Ensure extension is deleted unless we transfer ownership. 2100 // Ensure extension is deleted unless we transfer ownership.
2100 scoped_refptr<const Extension> scoped_extension(extension); 2101 scoped_refptr<const Extension> scoped_extension(extension);
2101 const std::string& id = extension->id(); 2102 const std::string& id = extension->id();
2102 // Extensions installed by policy can't be disabled. So even if a previous 2103 // Extensions installed by policy can't be disabled. So even if a previous
2103 // installation disabled the extension, make sure it is now enabled. 2104 // installation disabled the extension, make sure it is now enabled.
2104 bool initial_enable = 2105 bool initial_enable =
2105 !extension_prefs_->IsExtensionDisabled(id) || 2106 !extension_prefs_->IsExtensionDisabled(id) ||
2106 system_->management_policy()->MustRemainEnabled(extension, NULL); 2107 system_->management_policy()->MustRemainEnabled(extension, NULL);
(...skipping 26 matching lines...) Expand all
2133 pending_extension_manager()->Remove(id); 2134 pending_extension_manager()->Remove(id);
2134 } else { 2135 } else {
2135 // We explicitly want to re-enable an uninstalled external 2136 // We explicitly want to re-enable an uninstalled external
2136 // extension; if we're here, that means the user is manually 2137 // extension; if we're here, that means the user is manually
2137 // installing the extension. 2138 // installing the extension.
2138 if (IsExternalExtensionUninstalled(id)) { 2139 if (IsExternalExtensionUninstalled(id)) {
2139 initial_enable = true; 2140 initial_enable = true;
2140 } 2141 }
2141 } 2142 }
2142 2143
2144 // Unsupported requirements overrides the management policy.
2145 if (!requirement_errors.empty()) {
2146 initial_enable = false;
Aaron Boodman 2012/08/01 03:58:54 Oh cool. Since we already had code that was initia
eaugusti 2012/08/03 01:06:26 Done.
2147 // If the extension was disabled because of unsupported requirements but
2148 // now supports all requirements after an update, enable it.
2149 } else if (extension_prefs_->HasUnsupportedRequirements(id)) {
Aaron Boodman 2012/08/01 03:58:54 Can you check whether state == DISABLE_UNSUPPORTED
eaugusti 2012/08/03 01:06:26 If we remove the unsupported requirements in the p
2150 initial_enable = true;
2151 }
2152
2143 // Do not record the install histograms for upgrades. 2153 // Do not record the install histograms for upgrades.
2144 if (!GetExtensionByIdInternal(extension->id(), true, true, false)) { 2154 if (!GetExtensionByIdInternal(extension->id(), true, true, false)) {
2145 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallType", 2155 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallType",
2146 extension->GetType(), 100); 2156 extension->GetType(), 100);
2147 RecordPermissionMessagesHistogram( 2157 RecordPermissionMessagesHistogram(
2148 extension, "Extensions.Permissions_Install"); 2158 extension, "Extensions.Permissions_Install");
2149 } 2159 }
2150 2160
2151 // Certain extension locations are specific enough that we can 2161 // Certain extension locations are specific enough that we can
2152 // auto-acknowledge any extension that came from one of them. 2162 // auto-acknowledge any extension that came from one of them.
2153 if (extension->location() == Extension::EXTERNAL_POLICY_DOWNLOAD) { 2163 if (extension->location() == Extension::EXTERNAL_POLICY_DOWNLOAD) {
2154 AcknowledgeExternalExtension(extension->id()); 2164 AcknowledgeExternalExtension(extension->id());
2155 } 2165 }
2156 2166
2157 extension_prefs_->OnExtensionInstalled( 2167 extension_prefs_->OnExtensionInstalled(
2158 extension, 2168 extension,
2159 initial_enable ? Extension::ENABLED : Extension::DISABLED, 2169 initial_enable ? Extension::ENABLED : Extension::DISABLED,
2160 from_webstore, 2170 from_webstore,
2161 page_ordinal); 2171 page_ordinal);
2162 2172
2173 if (!requirement_errors.empty()) {
2174 extension_prefs_->SetDisableReason(
2175 id, Extension::DISABLE_UNSUPPORTED_REQUIREMENT);
2176 extension_prefs_->SetUnsupportedRequirements(id, requirement_errors);
2177 }
2178
2163 // Unpacked extensions default to allowing file access, but if that has been 2179 // Unpacked extensions default to allowing file access, but if that has been
2164 // overridden, don't reset the value. 2180 // overridden, don't reset the value.
2165 if (Extension::ShouldAlwaysAllowFileAccess(extension->location()) && 2181 if (Extension::ShouldAlwaysAllowFileAccess(extension->location()) &&
2166 !extension_prefs_->HasAllowFileAccessSetting(id)) { 2182 !extension_prefs_->HasAllowFileAccessSetting(id)) {
2167 extension_prefs_->SetAllowFileAccess(id, true); 2183 extension_prefs_->SetAllowFileAccess(id, true);
2168 } 2184 }
2169 2185
2170 content::NotificationService::current()->Notify( 2186 content::NotificationService::current()->Notify(
2171 chrome::NOTIFICATION_EXTENSION_INSTALLED, 2187 chrome::NOTIFICATION_EXTENSION_INSTALLED,
2172 content::Source<Profile>(profile_), 2188 content::Source<Profile>(profile_),
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
2540 2556
2541 ExtensionService::NaClModuleInfoList::iterator 2557 ExtensionService::NaClModuleInfoList::iterator
2542 ExtensionService::FindNaClModule(const GURL& url) { 2558 ExtensionService::FindNaClModule(const GURL& url) {
2543 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); 2559 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin();
2544 iter != nacl_module_list_.end(); ++iter) { 2560 iter != nacl_module_list_.end(); ++iter) {
2545 if (iter->url == url) 2561 if (iter->url == url)
2546 return iter; 2562 return iter;
2547 } 2563 }
2548 return nacl_module_list_.end(); 2564 return nacl_module_list_.end();
2549 } 2565 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698