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

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

Issue 10826199: Properly propagate the current Chrome channel into the Feature system on the (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make the default stable Created 8 years, 4 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
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_FEATURES_FEATURE_H_ 5 #ifndef CHROME_COMMON_EXTENSIONS_FEATURES_FEATURE_H_
6 #define CHROME_COMMON_EXTENSIONS_FEATURES_FEATURE_H_ 6 #define CHROME_COMMON_EXTENSIONS_FEATURES_FEATURE_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 INVALID_MIN_MANIFEST_VERSION, 61 INVALID_MIN_MANIFEST_VERSION,
62 INVALID_MAX_MANIFEST_VERSION, 62 INVALID_MAX_MANIFEST_VERSION,
63 NOT_PRESENT, 63 NOT_PRESENT,
64 UNSUPPORTED_CHANNEL, 64 UNSUPPORTED_CHANNEL,
65 }; 65 };
66 66
67 Feature(); 67 Feature();
68 Feature(const Feature& other); 68 Feature(const Feature& other);
69 virtual ~Feature(); 69 virtual ~Feature();
70 70
71 // (Re)Sets whether checking against "channel" should be done. This must only 71 // Gets the current channel as seen by the Feature system.
72 // be called on the browser process, since the check involves accessing the 72 // Defaults to CHANNEL_STABLE.
73 // filesystem. 73 static chrome::VersionInfo::Channel GetCurrentChannel();
74 // See http://crbug.com/126535.
75 static void SetChannelCheckingEnabled(bool enabled);
76 static void ResetChannelCheckingEnabled();
77 74
78 // (Re)Sets the Channel to for all Features to compare against. This is 75 // Sets the current channel as seen by the Feature system. In the browser
79 // usually chrome::VersionInfo::GetChannel(), but for tests allow this to be 76 // process this should be chrome::VersionInfo::GetChannel(), and in the
80 // overridden. 77 // renderer this will need to come from an IPC.
81 static void SetChannelForTesting(chrome::VersionInfo::Channel channel); 78 static void SetCurrentChannel(chrome::VersionInfo::Channel channel);
82 static void ResetChannelForTesting();
83 79
84 // Returns the current channel as seen by the Feature system (i.e. the 80 // Scoped channel setter. Use for tests.
85 // ChannelForTesting if one is set, otherwise the actual channel). 81 class ScopedCurrentChannel {
86 static chrome::VersionInfo::Channel GetCurrentChannel(); 82 public:
83 explicit ScopedCurrentChannel(chrome::VersionInfo::Channel channel)
84 : original_channel_(chrome::VersionInfo::CHANNEL_UNKNOWN) {
85 original_channel_ = GetCurrentChannel();
86 SetCurrentChannel(channel);
87 }
88
89 ~ScopedCurrentChannel() {
90 SetCurrentChannel(original_channel_);
91 }
92
93 private:
94 chrome::VersionInfo::Channel original_channel_;
95 };
87 96
88 const std::string& name() const { return name_; } 97 const std::string& name() const { return name_; }
89 void set_name(const std::string& name) { name_ = name; } 98 void set_name(const std::string& name) { name_ = name; }
90 99
91 // Gets the platform the code is currently running on. 100 // Gets the platform the code is currently running on.
92 static Platform GetCurrentPlatform(); 101 static Platform GetCurrentPlatform();
93 102
94 // Gets the Feature::Location value for the specified Extension::Location. 103 // Gets the Feature::Location value for the specified Extension::Location.
95 static Location ConvertLocation(Extension::Location extension_location); 104 static Location ConvertLocation(Extension::Location extension_location);
96 105
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 Location location_; // we only care about component/not-component now 172 Location location_; // we only care about component/not-component now
164 Platform platform_; // we only care about chromeos/not-chromeos now 173 Platform platform_; // we only care about chromeos/not-chromeos now
165 int min_manifest_version_; 174 int min_manifest_version_;
166 int max_manifest_version_; 175 int max_manifest_version_;
167 chrome::VersionInfo::Channel channel_; 176 chrome::VersionInfo::Channel channel_;
168 }; 177 };
169 178
170 } // namespace extensions 179 } // namespace extensions
171 180
172 #endif // CHROME_COMMON_EXTENSIONS_FEATURES_FEATURE_H_ 181 #endif // CHROME_COMMON_EXTENSIONS_FEATURES_FEATURE_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/script_badge_controller_unittest.cc ('k') | chrome/common/extensions/features/feature.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698