| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_COMMON_EXTENSIONS_FEATURE_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_FEATURE_H_ |
| 6 #define CHROME_COMMON_EXTENSIONS_FEATURE_H_ | 6 #define CHROME_COMMON_EXTENSIONS_FEATURE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "chrome/common/chrome_version_info.h" |
| 14 #include "chrome/common/extensions/extension.h" | 15 #include "chrome/common/extensions/extension.h" |
| 15 | 16 |
| 16 namespace extensions { | 17 namespace extensions { |
| 17 | 18 |
| 18 // Represents a single feature accessible to an extension developer, such as a | 19 // Represents a single feature accessible to an extension developer, such as a |
| 19 // top-level manifest key, a permission, or a programmatic API. A feature can | 20 // top-level manifest key, a permission, or a programmatic API. A feature can |
| 20 // express requirements for where it can be accessed, and supports testing | 21 // express requirements for where it can be accessed, and supports testing |
| 21 // support for those requirements. | 22 // support for those requirements. |
| 22 class Feature { | 23 class Feature { |
| 23 public: | 24 public: |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 enum Availability { | 56 enum Availability { |
| 56 IS_AVAILABLE, | 57 IS_AVAILABLE, |
| 57 NOT_FOUND_IN_WHITELIST, | 58 NOT_FOUND_IN_WHITELIST, |
| 58 INVALID_TYPE, | 59 INVALID_TYPE, |
| 59 INVALID_CONTEXT, | 60 INVALID_CONTEXT, |
| 60 INVALID_LOCATION, | 61 INVALID_LOCATION, |
| 61 INVALID_PLATFORM, | 62 INVALID_PLATFORM, |
| 62 INVALID_MIN_MANIFEST_VERSION, | 63 INVALID_MIN_MANIFEST_VERSION, |
| 63 INVALID_MAX_MANIFEST_VERSION, | 64 INVALID_MAX_MANIFEST_VERSION, |
| 64 NOT_PRESENT, | 65 NOT_PRESENT, |
| 65 DEPENDENCY_NOT_PRESENT | 66 UNSUPPORTED_CHANNEL, |
| 66 }; | 67 }; |
| 67 | 68 |
| 68 Feature(); | 69 Feature(); |
| 69 Feature(const Feature& other); | 70 Feature(const Feature& other); |
| 70 virtual ~Feature(); | 71 virtual ~Feature(); |
| 71 | 72 |
| 73 // Sets the Channel to for all Features to compare against. This is usually |
| 74 // chrome::VersionInfo::GetChannel(), but for tests all this to be overridden. |
| 75 static void SetChannelForTesting(chrome::VersionInfo::Channel channel); |
| 76 |
| 72 const std::string& name() const { return name_; } | 77 const std::string& name() const { return name_; } |
| 73 void set_name(const std::string& name) { name_ = name; } | 78 void set_name(const std::string& name) { name_ = name; } |
| 74 | 79 |
| 75 // Gets the platform the code is currently running on. | 80 // Gets the platform the code is currently running on. |
| 76 static Platform GetCurrentPlatform(); | 81 static Platform GetCurrentPlatform(); |
| 77 | 82 |
| 78 // Gets the Feature::Location value for the specified Extension::Location. | 83 // Gets the Feature::Location value for the specified Extension::Location. |
| 79 static Location ConvertLocation(Extension::Location extension_location); | 84 static Location ConvertLocation(Extension::Location extension_location); |
| 80 | 85 |
| 81 std::set<std::string>* whitelist() { return &whitelist_; } | 86 std::set<std::string>* whitelist() { return &whitelist_; } |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 // members the same way: it matches everything. It is up to the higher level | 146 // members the same way: it matches everything. It is up to the higher level |
| 142 // code that reads Features out of static data to validate that data and set | 147 // code that reads Features out of static data to validate that data and set |
| 143 // sensible defaults. | 148 // sensible defaults. |
| 144 std::set<std::string> whitelist_; | 149 std::set<std::string> whitelist_; |
| 145 std::set<Extension::Type> extension_types_; | 150 std::set<Extension::Type> extension_types_; |
| 146 std::set<Context> contexts_; | 151 std::set<Context> contexts_; |
| 147 Location location_; // we only care about component/not-component now | 152 Location location_; // we only care about component/not-component now |
| 148 Platform platform_; // we only care about chromeos/not-chromeos now | 153 Platform platform_; // we only care about chromeos/not-chromeos now |
| 149 int min_manifest_version_; | 154 int min_manifest_version_; |
| 150 int max_manifest_version_; | 155 int max_manifest_version_; |
| 156 chrome::VersionInfo::Channel supported_channel_; |
| 151 }; | 157 }; |
| 152 | 158 |
| 153 } // namespace extensions | 159 } // namespace extensions |
| 154 | 160 |
| 155 #endif // CHROME_COMMON_EXTENSIONS_FEATURE_H_ | 161 #endif // CHROME_COMMON_EXTENSIONS_FEATURE_H_ |
| OLD | NEW |