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..9bf79f074b50cb22dc1ee6a7a6afe5b97f68fef1 100644 |
--- a/extensions/common/features/simple_feature.cc |
+++ b/extensions/common/features/simple_feature.cc |
@@ -22,6 +22,9 @@ |
namespace extensions { |
+// static |
+std::string* SimpleFeature::whitelisted_extension_id_ = NULL; |
+ |
namespace { |
Feature::Availability IsAvailableToManifestForBind( |
@@ -344,20 +347,9 @@ 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) && |
+ extension_id != whitelisted_extension_id()) { |
tapted
2015/03/31 03:26:49
I'm not sure we know for certain whether `extensio
jackhou1
2015/03/31 04:37:45
Added check for empty whitelisted_extension_id.
|
+ return CreateAvailability(NOT_FOUND_IN_WHITELIST, type); |
} |
if (!MatchesManifestLocation(location)) |
@@ -583,4 +575,14 @@ Feature::Availability SimpleFeature::CheckDependencies( |
return CreateAvailability(IS_AVAILABLE); |
} |
+// static |
+const std::string& SimpleFeature::whitelisted_extension_id() { |
+ if (!whitelisted_extension_id_) { |
tapted
2015/03/31 03:26:49
use
CR_DEFINE_STATIC_LOCAL(std::string, whiteli
jackhou1
2015/03/31 04:37:45
Done.
|
+ whitelisted_extension_id_ = new std::string( |
+ base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
+ switches::kWhitelistedExtensionID)); |
+ } |
+ return *whitelisted_extension_id_; |
+} |
+ |
} // namespace extensions |