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

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: Fixed UnpackedInstller issue 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 2109 matching lines...) Expand 10 before | Expand all | Expand 10 after
2120 if (!extension->is_theme() && extension->location() != Extension::COMPONENT) 2120 if (!extension->is_theme() && extension->location() != Extension::COMPONENT)
2121 extension_ids.insert(extension->id()); 2121 extension_ids.insert(extension->id());
2122 } 2122 }
2123 2123
2124 child_process_logging::SetActiveExtensions(extension_ids); 2124 child_process_logging::SetActiveExtensions(extension_ids);
2125 } 2125 }
2126 2126
2127 void ExtensionService::OnExtensionInstalled( 2127 void ExtensionService::OnExtensionInstalled(
2128 const Extension* extension, 2128 const Extension* extension,
2129 bool from_webstore, 2129 bool from_webstore,
2130 const syncer::StringOrdinal& page_ordinal) { 2130 const syncer::StringOrdinal& page_ordinal,
2131 bool has_requirement_errors) {
2131 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 2132 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
2132 2133
2133 // Ensure extension is deleted unless we transfer ownership. 2134 // Ensure extension is deleted unless we transfer ownership.
2134 scoped_refptr<const Extension> scoped_extension(extension); 2135 scoped_refptr<const Extension> scoped_extension(extension);
2135 const std::string& id = extension->id(); 2136 const std::string& id = extension->id();
2136 // Extensions installed by policy can't be disabled. So even if a previous 2137 // Extensions installed by policy can't be disabled. So even if a previous
2137 // installation disabled the extension, make sure it is now enabled. 2138 // installation disabled the extension, make sure it is now enabled.
2138 bool initial_enable = 2139 bool initial_enable =
2139 !extension_prefs_->IsExtensionDisabled(id) || 2140 !extension_prefs_->IsExtensionDisabled(id) ||
2140 system_->management_policy()->MustRemainEnabled(extension, NULL); 2141 system_->management_policy()->MustRemainEnabled(extension, NULL);
(...skipping 26 matching lines...) Expand all
2167 pending_extension_manager()->Remove(id); 2168 pending_extension_manager()->Remove(id);
2168 } else { 2169 } else {
2169 // We explicitly want to re-enable an uninstalled external 2170 // We explicitly want to re-enable an uninstalled external
2170 // extension; if we're here, that means the user is manually 2171 // extension; if we're here, that means the user is manually
2171 // installing the extension. 2172 // installing the extension.
2172 if (IsExternalExtensionUninstalled(id)) { 2173 if (IsExternalExtensionUninstalled(id)) {
2173 initial_enable = true; 2174 initial_enable = true;
2174 } 2175 }
2175 } 2176 }
2176 2177
2178 // Unsupported requirements overrides the management policy.
2179 if (has_requirement_errors) {
2180 initial_enable = false;
2181 extension_prefs_->AddDisableReason(
2182 id, Extension::DISABLE_UNSUPPORTED_REQUIREMENT);
2183 // If the extension was disabled because of unsupported requirements but
2184 // now supports all requirements after an update and there are not other
2185 // disable reasons, enable it.
2186 } else if (extension_prefs_->GetDisableReasons(id) ==
2187 Extension::DISABLE_UNSUPPORTED_REQUIREMENT) {
2188 initial_enable = true;
2189 extension_prefs_->ClearDisableReasons(id);
2190 }
2191
2177 int include_mask = INCLUDE_ENABLED; 2192 int include_mask = INCLUDE_ENABLED;
2178 include_mask |= INCLUDE_DISABLED; 2193 include_mask |= INCLUDE_DISABLED;
2179 // Do not record the install histograms for upgrades. 2194 // Do not record the install histograms for upgrades.
2180 if (!GetExtensionByIdInternal(extension->id(), include_mask)) { 2195 if (!GetExtensionByIdInternal(extension->id(), include_mask)) {
2181 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallType", 2196 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallType",
2182 extension->GetType(), 100); 2197 extension->GetType(), 100);
2183 RecordPermissionMessagesHistogram( 2198 RecordPermissionMessagesHistogram(
2184 extension, "Extensions.Permissions_Install"); 2199 extension, "Extensions.Permissions_Install");
2185 } 2200 }
2186 2201
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
2624 extensions::ExtensionHost* extension_host) { 2639 extensions::ExtensionHost* extension_host) {
2625 if (!extension_host) 2640 if (!extension_host)
2626 return; 2641 return;
2627 2642
2628 #if !defined(OS_ANDROID) 2643 #if !defined(OS_ANDROID)
2629 extensions::LaunchPlatformApp(extension_host->profile(), 2644 extensions::LaunchPlatformApp(extension_host->profile(),
2630 extension_host->extension(), 2645 extension_host->extension(),
2631 NULL, FilePath()); 2646 NULL, FilePath());
2632 #endif 2647 #endif
2633 } 2648 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | chrome/browser/extensions/extension_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698