From ae342c9a0fa8a3c55bc89bf9a1543ad85f7d404f Mon Sep 17 00:00:00 2001 From: kalman Date: Fri, 12 Dec 2014 14:04:23 -0800 Subject: Add support for command line switches to Features, and as proof that it works, use it for the experimental permission. BUG=440194 R=rockot@chromium.org Review URL: https://codereview.chromium.org/801603002 Cr-Commit-Position: refs/heads/master@{#308176} --- .../common/manifest_handlers/permissions_parser.cc | 37 ++++++---------------- 1 file changed, 10 insertions(+), 27 deletions(-) (limited to 'extensions/common/manifest_handlers') diff --git a/extensions/common/manifest_handlers/permissions_parser.cc b/extensions/common/manifest_handlers/permissions_parser.cc index 0b08ef9..42d5c61 100644 --- a/extensions/common/manifest_handlers/permissions_parser.cc +++ b/extensions/common/manifest_handlers/permissions_parser.cc @@ -46,26 +46,6 @@ ManifestPermissions::ManifestPermissions( ManifestPermissions::~ManifestPermissions() { } -// Custom checks for the experimental permission that can't be expressed in -// _permission_features.json. -bool CanSpecifyExperimentalPermission(const Extension* extension) { - if (extension->location() == Manifest::COMPONENT) - return true; - - if (CommandLine::ForCurrentProcess()->HasSwitch( - switches::kEnableExperimentalExtensionApis)) { - return true; - } - - // We rely on the webstore to check access to experimental. This way we can - // whitelist extensions to have access to experimental in just the store, and - // not have to push a new version of the client. - if (extension->from_webstore()) - return true; - - return false; -} - // Checks whether the host |pattern| is allowed for the given |extension|, // given API permissions |permissions|. bool CanSpecifyHostPermission(const Extension* extension, @@ -146,6 +126,16 @@ bool ParseHelper(Extension* extension, continue; } + // Sneaky check for "experimental", which we always allow for extensions + // installed from the Webstore. This way we can whitelist extensions to + // have access to experimental in just the store, and not have to push a + // new version of the client. Otherwise, experimental goes through the + // usual features check. + if (iter->id() == APIPermission::kExperimental && + extension->from_webstore()) { + continue; + } + Feature::Availability availability = feature->IsAvailableToExtension(extension); if (!availability.is_available()) { @@ -157,13 +147,6 @@ bool ParseHelper(Extension* extension, to_remove.push_back(iter->id()); continue; } - - if (iter->id() == APIPermission::kExperimental) { - if (!CanSpecifyExperimentalPermission(extension)) { - *error = base::ASCIIToUTF16(errors::kExperimentalFlagRequired); - return false; - } - } } api_permissions->AddImpliedPermissions(); -- cgit v1.1