Index: chrome/common/extensions/features/simple_feature.cc |
diff --git a/chrome/common/extensions/features/feature.cc b/chrome/common/extensions/features/simple_feature.cc |
similarity index 89% |
copy from chrome/common/extensions/features/feature.cc |
copy to chrome/common/extensions/features/simple_feature.cc |
index 8e4bb64fba90576b50a64ec32e71d0e95d8cc7c8..528d0b03f4fe1fde96993a205984b978b239002d 100644 |
--- a/chrome/common/extensions/features/feature.cc |
+++ b/chrome/common/extensions/features/simple_feature.cc |
@@ -2,14 +2,15 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "chrome/common/extensions/features/feature.h" |
+#include "chrome/common/extensions/features/simple_feature.h" |
#include <map> |
+#include <vector> |
#include "base/command_line.h" |
#include "base/lazy_instance.h" |
-#include "base/stringprintf.h" |
#include "base/string_util.h" |
+#include "base/stringprintf.h" |
#include "chrome/common/chrome_switches.h" |
using chrome::VersionInfo; |
@@ -64,9 +65,6 @@ std::string GetChannelName(VersionInfo::Channel channel) { |
return "unknown"; |
} |
-const VersionInfo::Channel kDefaultChannel = VersionInfo::CHANNEL_STABLE; |
-VersionInfo::Channel g_current_channel = kDefaultChannel; |
- |
// TODO(aa): Can we replace all this manual parsing with JSON schema stuff? |
void ParseSet(const DictionaryValue* value, |
@@ -164,7 +162,7 @@ std::string GetDisplayTypeName(Extension::Type type) { |
namespace extensions { |
-Feature::Feature() |
+SimpleFeature::SimpleFeature() |
: location_(UNSPECIFIED_LOCATION), |
platform_(UNSPECIFIED_PLATFORM), |
min_manifest_version_(0), |
@@ -172,7 +170,7 @@ Feature::Feature() |
channel_(VersionInfo::CHANNEL_UNKNOWN) { |
} |
-Feature::Feature(const Feature& other) |
+SimpleFeature::SimpleFeature(const SimpleFeature& other) |
: whitelist_(other.whitelist_), |
extension_types_(other.extension_types_), |
contexts_(other.contexts_), |
@@ -183,10 +181,10 @@ Feature::Feature(const Feature& other) |
channel_(other.channel_) { |
} |
-Feature::~Feature() { |
+SimpleFeature::~SimpleFeature() { |
} |
-bool Feature::Equals(const Feature& other) const { |
+bool SimpleFeature::Equals(const SimpleFeature& other) const { |
return whitelist_ == other.whitelist_ && |
extension_types_ == other.extension_types_ && |
contexts_ == other.contexts_ && |
@@ -197,24 +195,7 @@ bool Feature::Equals(const Feature& other) const { |
channel_ == other.channel_; |
} |
-// static |
-Feature::Platform Feature::GetCurrentPlatform() { |
-#if defined(OS_CHROMEOS) |
- return CHROMEOS_PLATFORM; |
-#else |
- return UNSPECIFIED_PLATFORM; |
-#endif |
-} |
- |
-// static |
-Feature::Location Feature::ConvertLocation(Extension::Location location) { |
- if (location == Extension::COMPONENT) |
- return COMPONENT_LOCATION; |
- else |
- return UNSPECIFIED_LOCATION; |
-} |
- |
-void Feature::Parse(const DictionaryValue* value) { |
+void SimpleFeature::Parse(const DictionaryValue* value) { |
ParseSet(value, "whitelist", &whitelist_); |
ParseEnumSet<Extension::Type>(value, "extension_types", &extension_types_, |
g_mappings.Get().extension_types); |
@@ -231,7 +212,7 @@ void Feature::Parse(const DictionaryValue* value) { |
g_mappings.Get().channels); |
} |
-Feature::Availability Feature::IsAvailableToManifest( |
+Feature::Availability SimpleFeature::IsAvailableToManifest( |
const std::string& extension_id, |
Extension::Type type, |
Location location, |
@@ -274,16 +255,16 @@ Feature::Availability Feature::IsAvailableToManifest( |
if (max_manifest_version_ != 0 && manifest_version > max_manifest_version_) |
return CreateAvailability(INVALID_MAX_MANIFEST_VERSION, type); |
- if (channel_ < g_current_channel) |
+ if (channel_ < Feature::GetCurrentChannel()) |
return CreateAvailability(UNSUPPORTED_CHANNEL, type); |
return CreateAvailability(IS_AVAILABLE, type); |
} |
-Feature::Availability Feature::IsAvailableToContext( |
+Feature::Availability SimpleFeature::IsAvailableToContext( |
const Extension* extension, |
- Feature::Context context, |
- Feature::Platform platform) const { |
+ SimpleFeature::Context context, |
+ SimpleFeature::Platform platform) const { |
Availability result = IsAvailableToManifest( |
extension->id(), |
extension->GetType(), |
@@ -301,33 +282,7 @@ Feature::Availability Feature::IsAvailableToContext( |
return CreateAvailability(IS_AVAILABLE); |
} |
-// static |
-chrome::VersionInfo::Channel Feature::GetCurrentChannel() { |
- return g_current_channel; |
-} |
- |
-// static |
-void Feature::SetCurrentChannel(VersionInfo::Channel channel) { |
- g_current_channel = channel; |
-} |
- |
-// static |
-chrome::VersionInfo::Channel Feature::GetDefaultChannel() { |
- return kDefaultChannel; |
-} |
- |
-Feature::Availability Feature::CreateAvailability( |
- AvailabilityResult result) const { |
- return Availability( |
- result, GetAvailabilityMessage(result, Extension::TYPE_UNKNOWN)); |
-} |
- |
-Feature::Availability Feature::CreateAvailability( |
- AvailabilityResult result, Extension::Type type) const { |
- return Availability(result, GetAvailabilityMessage(result, type)); |
-} |
- |
-std::string Feature::GetAvailabilityMessage( |
+std::string SimpleFeature::GetAvailabilityMessage( |
AvailabilityResult result, Extension::Type type) const { |
switch (result) { |
case IS_AVAILABLE: |
@@ -398,5 +353,19 @@ std::string Feature::GetAvailabilityMessage( |
return ""; |
} |
+Feature::Availability SimpleFeature::CreateAvailability( |
+ AvailabilityResult result) const { |
+ return Availability( |
+ result, GetAvailabilityMessage(result, Extension::TYPE_UNKNOWN)); |
+} |
+ |
+Feature::Availability SimpleFeature::CreateAvailability( |
+ AvailabilityResult result, Extension::Type type) const { |
+ return Availability(result, GetAvailabilityMessage(result, type)); |
+} |
+ |
+std::set<Feature::Context>* SimpleFeature::GetContexts() { |
+ return &contexts_; |
+} |
} // namespace extensions |