Index: extensions/common/features/simple_feature.cc |
diff --git a/extensions/common/features/simple_feature.cc b/extensions/common/features/simple_feature.cc |
index 7d1e06e35b11dffe0a7f4b469fc35bc61cb60e96..f363766b5f8988d6a7ac76e10ec52d9998b3c180 100644 |
--- a/extensions/common/features/simple_feature.cc |
+++ b/extensions/common/features/simple_feature.cc |
@@ -11,6 +11,7 @@ |
#include "base/command_line.h" |
#include "base/debug/alias.h" |
#include "base/lazy_instance.h" |
+#include "base/macros.h" |
#include "base/sha1.h" |
#include "base/stl_util.h" |
#include "base/strings/string_number_conversions.h" |
@@ -344,20 +345,10 @@ Feature::Availability SimpleFeature::IsAvailableToManifest( |
if (component_extensions_auto_granted_ && location == Manifest::COMPONENT) |
return CreateAvailability(IS_AVAILABLE, 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 (!whitelist_.empty() && !IsIdInWhitelist(extension_id) && |
+ (whitelisted_extension_id().empty() || |
tapted
2015/03/31 04:46:07
hm - two function calls isn't quite as nice..
If
jackhou1
2015/03/31 05:28:22
Done.
|
+ extension_id != whitelisted_extension_id())) { |
+ return CreateAvailability(NOT_FOUND_IN_WHITELIST, type); |
} |
if (!MatchesManifestLocation(location)) |
@@ -583,4 +574,13 @@ Feature::Availability SimpleFeature::CheckDependencies( |
return CreateAvailability(IS_AVAILABLE); |
} |
+// static |
+const std::string& SimpleFeature::whitelisted_extension_id() { |
+ CR_DEFINE_STATIC_LOCAL( |
+ std::string, whitelisted_extension_id, |
+ (base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
+ switches::kWhitelistedExtensionID))); |
+ return whitelisted_extension_id; |
+} |
+ |
} // namespace extensions |