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

Side by Side Diff: chrome/common/extensions/feature.h

Issue 10054035: Allow extension APIs to be restricted to a subset of Chrome channels using the (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/common/extensions/feature.cc » ('j') | chrome/common/extensions/feature.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 DEPENDENCY_NOT_PRESENT,
67 UNSUPPORTED_CHANNEL,
66 }; 68 };
67 69
68 Feature(); 70 Feature();
69 Feature(const Feature& other); 71 Feature(const Feature& other);
70 virtual ~Feature(); 72 virtual ~Feature();
71 73
74 // Sets the Channel to compare against. This will be initialized as
75 // chrome::VersionInfo::GetChannel(), which is fine for all but testing
76 // purposes.
77 void SetChannelForTesting(chrome::VersionInfo::Channel channel);
78
72 const std::string& name() const { return name_; } 79 const std::string& name() const { return name_; }
73 void set_name(const std::string& name) { name_ = name; } 80 void set_name(const std::string& name) { name_ = name; }
74 81
75 // Gets the platform the code is currently running on. 82 // Gets the platform the code is currently running on.
76 static Platform GetCurrentPlatform(); 83 static Platform GetCurrentPlatform();
77 84
78 // Gets the Feature::Location value for the specified Extension::Location. 85 // Gets the Feature::Location value for the specified Extension::Location.
79 static Location ConvertLocation(Extension::Location extension_location); 86 static Location ConvertLocation(Extension::Location extension_location);
80 87
81 std::set<std::string>* whitelist() { return &whitelist_; } 88 std::set<std::string>* whitelist() { return &whitelist_; }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // members the same way: it matches everything. It is up to the higher level 148 // 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 149 // code that reads Features out of static data to validate that data and set
143 // sensible defaults. 150 // sensible defaults.
144 std::set<std::string> whitelist_; 151 std::set<std::string> whitelist_;
145 std::set<Extension::Type> extension_types_; 152 std::set<Extension::Type> extension_types_;
146 std::set<Context> contexts_; 153 std::set<Context> contexts_;
147 Location location_; // we only care about component/not-component now 154 Location location_; // we only care about component/not-component now
148 Platform platform_; // we only care about chromeos/not-chromeos now 155 Platform platform_; // we only care about chromeos/not-chromeos now
149 int min_manifest_version_; 156 int min_manifest_version_;
150 int max_manifest_version_; 157 int max_manifest_version_;
158
159 // The Channel to compare against |supported_channel_|. Mutable for unit
160 // tests, usually this is just chrome::VersionInfo::GetChannel().
161 chrome::VersionInfo::Channel channel_;
Aaron Boodman 2012/04/11 23:35:53 Sucks to have a separate value here for every sing
not at google - send to devlin 2012/04/12 00:05:21 Yeah, nicer.
162
163 chrome::VersionInfo::Channel supported_channel_;
151 }; 164 };
152 165
153 } // namespace extensions 166 } // namespace extensions
154 167
155 #endif // CHROME_COMMON_EXTENSIONS_FEATURE_H_ 168 #endif // CHROME_COMMON_EXTENSIONS_FEATURE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/feature.cc » ('j') | chrome/common/extensions/feature.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698