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

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: recheck on enable Created 8 years, 3 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 2077 matching lines...) Expand 10 before | Expand all | Expand 10 after
2088 if (!extension->is_theme() && extension->location() != Extension::COMPONENT) 2088 if (!extension->is_theme() && extension->location() != Extension::COMPONENT)
2089 extension_ids.insert(extension->id()); 2089 extension_ids.insert(extension->id());
2090 } 2090 }
2091 2091
2092 child_process_logging::SetActiveExtensions(extension_ids); 2092 child_process_logging::SetActiveExtensions(extension_ids);
2093 } 2093 }
2094 2094
2095 void ExtensionService::OnExtensionInstalled( 2095 void ExtensionService::OnExtensionInstalled(
2096 const Extension* extension, 2096 const Extension* extension,
2097 bool from_webstore, 2097 bool from_webstore,
2098 const StringOrdinal& page_ordinal) { 2098 const StringOrdinal& page_ordinal,
2099 bool has_requirement_errors) {
2099 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 2100 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
2100 2101
2101 // Ensure extension is deleted unless we transfer ownership. 2102 // Ensure extension is deleted unless we transfer ownership.
2102 scoped_refptr<const Extension> scoped_extension(extension); 2103 scoped_refptr<const Extension> scoped_extension(extension);
2103 const std::string& id = extension->id(); 2104 const std::string& id = extension->id();
2104 // Extensions installed by policy can't be disabled. So even if a previous 2105 // Extensions installed by policy can't be disabled. So even if a previous
2105 // installation disabled the extension, make sure it is now enabled. 2106 // installation disabled the extension, make sure it is now enabled.
2106 bool initial_enable = 2107 bool initial_enable =
2107 !extension_prefs_->IsExtensionDisabled(id) || 2108 !extension_prefs_->IsExtensionDisabled(id) ||
2108 system_->management_policy()->MustRemainEnabled(extension, NULL); 2109 system_->management_policy()->MustRemainEnabled(extension, NULL);
(...skipping 26 matching lines...) Expand all
2135 pending_extension_manager()->Remove(id); 2136 pending_extension_manager()->Remove(id);
2136 } else { 2137 } else {
2137 // We explicitly want to re-enable an uninstalled external 2138 // We explicitly want to re-enable an uninstalled external
2138 // extension; if we're here, that means the user is manually 2139 // extension; if we're here, that means the user is manually
2139 // installing the extension. 2140 // installing the extension.
2140 if (IsExternalExtensionUninstalled(id)) { 2141 if (IsExternalExtensionUninstalled(id)) {
2141 initial_enable = true; 2142 initial_enable = true;
2142 } 2143 }
2143 } 2144 }
2144 2145
2146 // Unsupported requirements overrides the management policy.
2147 if (has_requirement_errors) {
2148 initial_enable = false;
2149 extension_prefs_->AddDisableReason(
2150 id, Extension::DISABLE_UNSUPPORTED_REQUIREMENT);
2151 // If the extension was disabled because of unsupported requirements but
2152 // now supports all requirements after an update and there are not other
2153 // disable reasons, enable it.
2154 } else if (extension_prefs_->GetDisableReasons(id) ==
2155 Extension::DISABLE_UNSUPPORTED_REQUIREMENT) {
2156 initial_enable = true;
2157 extension_prefs_->ClearDisableReasons(id);
2158 }
2159
2145 int include_mask = INCLUDE_ENABLED; 2160 int include_mask = INCLUDE_ENABLED;
2146 include_mask |= INCLUDE_DISABLED; 2161 include_mask |= INCLUDE_DISABLED;
2147 // Do not record the install histograms for upgrades. 2162 // Do not record the install histograms for upgrades.
2148 if (!GetExtensionByIdInternal(extension->id(), include_mask)) { 2163 if (!GetExtensionByIdInternal(extension->id(), include_mask)) {
2149 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallType", 2164 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallType",
2150 extension->GetType(), 100); 2165 extension->GetType(), 100);
2151 RecordPermissionMessagesHistogram( 2166 RecordPermissionMessagesHistogram(
2152 extension, "Extensions.Permissions_Install"); 2167 extension, "Extensions.Permissions_Install");
2153 } 2168 }
2154 2169
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
2553 2568
2554 ExtensionService::NaClModuleInfoList::iterator 2569 ExtensionService::NaClModuleInfoList::iterator
2555 ExtensionService::FindNaClModule(const GURL& url) { 2570 ExtensionService::FindNaClModule(const GURL& url) {
2556 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); 2571 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin();
2557 iter != nacl_module_list_.end(); ++iter) { 2572 iter != nacl_module_list_.end(); ++iter) {
2558 if (iter->url == url) 2573 if (iter->url == url)
2559 return iter; 2574 return iter;
2560 } 2575 }
2561 return nacl_module_list_.end(); 2576 return nacl_module_list_.end();
2562 } 2577 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698