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

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: Changed plugins requirement schema 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 2093 matching lines...) Expand 10 before | Expand all | Expand 10 after
2104 if (!extension->is_theme() && extension->location() != Extension::COMPONENT) 2104 if (!extension->is_theme() && extension->location() != Extension::COMPONENT)
2105 extension_ids.insert(extension->id()); 2105 extension_ids.insert(extension->id());
2106 } 2106 }
2107 2107
2108 child_process_logging::SetActiveExtensions(extension_ids); 2108 child_process_logging::SetActiveExtensions(extension_ids);
2109 } 2109 }
2110 2110
2111 void ExtensionService::OnExtensionInstalled( 2111 void ExtensionService::OnExtensionInstalled(
2112 const Extension* extension, 2112 const Extension* extension,
2113 bool from_webstore, 2113 bool from_webstore,
2114 const StringOrdinal& page_ordinal) { 2114 const StringOrdinal& page_ordinal,
2115 bool has_requirement_errors) {
2115 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 2116 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
2116 2117
2117 // Ensure extension is deleted unless we transfer ownership. 2118 // Ensure extension is deleted unless we transfer ownership.
2118 scoped_refptr<const Extension> scoped_extension(extension); 2119 scoped_refptr<const Extension> scoped_extension(extension);
2119 const std::string& id = extension->id(); 2120 const std::string& id = extension->id();
2120 // Extensions installed by policy can't be disabled. So even if a previous 2121 // Extensions installed by policy can't be disabled. So even if a previous
2121 // installation disabled the extension, make sure it is now enabled. 2122 // installation disabled the extension, make sure it is now enabled.
2122 bool initial_enable = 2123 bool initial_enable =
2123 !extension_prefs_->IsExtensionDisabled(id) || 2124 !extension_prefs_->IsExtensionDisabled(id) ||
2124 system_->management_policy()->MustRemainEnabled(extension, NULL); 2125 system_->management_policy()->MustRemainEnabled(extension, NULL);
(...skipping 26 matching lines...) Expand all
2151 pending_extension_manager()->Remove(id); 2152 pending_extension_manager()->Remove(id);
2152 } else { 2153 } else {
2153 // We explicitly want to re-enable an uninstalled external 2154 // We explicitly want to re-enable an uninstalled external
2154 // extension; if we're here, that means the user is manually 2155 // extension; if we're here, that means the user is manually
2155 // installing the extension. 2156 // installing the extension.
2156 if (IsExternalExtensionUninstalled(id)) { 2157 if (IsExternalExtensionUninstalled(id)) {
2157 initial_enable = true; 2158 initial_enable = true;
2158 } 2159 }
2159 } 2160 }
2160 2161
2162 // Unsupported requirements overrides the management policy.
2163 if (has_requirement_errors) {
2164 initial_enable = false;
2165 extension_prefs_->AddDisableReason(
2166 id, Extension::DISABLE_UNSUPPORTED_REQUIREMENT);
2167 // If the extension was disabled because of unsupported requirements but
2168 // now supports all requirements after an update and there are not other
2169 // disable reasons, enable it.
2170 } else if (extension_prefs_->GetDisableReasons(id) ==
2171 Extension::DISABLE_UNSUPPORTED_REQUIREMENT) {
2172 initial_enable = true;
2173 extension_prefs_->ClearDisableReasons(id);
2174 }
2175
2161 int include_mask = INCLUDE_ENABLED; 2176 int include_mask = INCLUDE_ENABLED;
2162 include_mask |= INCLUDE_DISABLED; 2177 include_mask |= INCLUDE_DISABLED;
2163 // Do not record the install histograms for upgrades. 2178 // Do not record the install histograms for upgrades.
2164 if (!GetExtensionByIdInternal(extension->id(), include_mask)) { 2179 if (!GetExtensionByIdInternal(extension->id(), include_mask)) {
2165 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallType", 2180 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallType",
2166 extension->GetType(), 100); 2181 extension->GetType(), 100);
2167 RecordPermissionMessagesHistogram( 2182 RecordPermissionMessagesHistogram(
2168 extension, "Extensions.Permissions_Install"); 2183 extension, "Extensions.Permissions_Install");
2169 } 2184 }
2170 2185
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
2573 2588
2574 ExtensionService::NaClModuleInfoList::iterator 2589 ExtensionService::NaClModuleInfoList::iterator
2575 ExtensionService::FindNaClModule(const GURL& url) { 2590 ExtensionService::FindNaClModule(const GURL& url) {
2576 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); 2591 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin();
2577 iter != nacl_module_list_.end(); ++iter) { 2592 iter != nacl_module_list_.end(); ++iter) {
2578 if (iter->url == url) 2593 if (iter->url == url)
2579 return iter; 2594 return iter;
2580 } 2595 }
2581 return nacl_module_list_.end(); 2596 return nacl_module_list_.end();
2582 } 2597 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698