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

Unified Diff: extensions/common/features/simple_feature.cc

Issue 1076393002: Revert of Cache --whitelisted-extension-id in SimpleFeature. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/common/features/simple_feature.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/common/features/simple_feature.cc
diff --git a/extensions/common/features/simple_feature.cc b/extensions/common/features/simple_feature.cc
index 31f641bfc01a39e059d702f62ad72ecb28c4385c..6a5bece485df46b7ccc9db8ef21c5d62a521ba93 100644
--- a/extensions/common/features/simple_feature.cc
+++ b/extensions/common/features/simple_feature.cc
@@ -11,7 +11,6 @@
#include "base/bind.h"
#include "base/command_line.h"
#include "base/debug/alias.h"
-#include "base/macros.h"
#include "base/sha1.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
@@ -24,10 +23,6 @@
namespace extensions {
namespace {
-
-// A singleton copy of the --whitelisted-extension-id so that we don't need to
-// copy it from the CommandLine each time.
-std::string* g_whitelisted_extension_id = NULL;
Feature::Availability IsAvailableToManifestForBind(
const std::string& extension_id,
@@ -227,32 +222,7 @@
return false;
}
-bool IsWhitelistedForTest(const std::string& extension_id) {
- // TODO(jackhou): Delete the commandline whitelisting mechanism.
- // Since it is only used it tests, ideally it should not be set via the
- // commandline. At the moment the commandline is used as a mechanism to pass
- // the id to the renderer process.
- if (!g_whitelisted_extension_id) {
- g_whitelisted_extension_id = new std::string(
- base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
- switches::kWhitelistedExtensionID));
- }
- return !g_whitelisted_extension_id->empty() &&
- *g_whitelisted_extension_id == extension_id;
-}
-
} // namespace
-
-SimpleFeature::ScopedWhitelistForTest::ScopedWhitelistForTest(
- const std::string& id)
- : previous_id_(g_whitelisted_extension_id) {
- g_whitelisted_extension_id = new std::string(id);
-}
-
-SimpleFeature::ScopedWhitelistForTest::~ScopedWhitelistForTest() {
- delete g_whitelisted_extension_id;
- g_whitelisted_extension_id = previous_id_;
-}
struct SimpleFeature::Mappings {
Mappings() {
@@ -393,9 +363,20 @@
if (component_extensions_auto_granted_ && location == Manifest::COMPONENT)
return CreateAvailability(IS_AVAILABLE, type);
- if (!whitelist_.empty() && !IsIdInWhitelist(extension_id) &&
- !IsWhitelistedForTest(extension_id)) {
- return CreateAvailability(NOT_FOUND_IN_WHITELIST, type);
+ if (!whitelist_.empty()) {
+ if (!IsIdInWhitelist(extension_id)) {
+ // TODO(aa): This is gross. There should be a better way to test the
+ // whitelist.
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+ if (!command_line->HasSwitch(switches::kWhitelistedExtensionID))
+ return CreateAvailability(NOT_FOUND_IN_WHITELIST, type);
+
+ std::string whitelist_switch_value =
+ base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kWhitelistedExtensionID);
+ if (extension_id != whitelist_switch_value)
+ return CreateAvailability(NOT_FOUND_IN_WHITELIST, type);
+ }
}
if (!MatchesManifestLocation(location))
« no previous file with comments | « extensions/common/features/simple_feature.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698