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

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: cleanup 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 // Returns true if a channel has been set.
72 // be called on the browser process, since the check involves accessing the 72 static bool HasCurrentChannel();
73 // filesystem.
74 // See http://crbug.com/126535.
75 static void SetChannelCheckingEnabled(bool enabled);
76 static void ResetChannelCheckingEnabled();
77 73
78 // (Re)Sets the Channel to for all Features to compare against. This is 74 // Gets the current channel as seen by the Feature system.
79 // usually chrome::VersionInfo::GetChannel(), but for tests allow this to be 75 // SetCurrentChannel() must have already been called.
80 // overridden. 76 static chrome::VersionInfo::Channel GetCurrentChannel();
81 static void SetChannelForTesting(chrome::VersionInfo::Channel channel);
82 static void ResetChannelForTesting();
83 77
84 // Returns the current channel as seen by the Feature system (i.e. the 78 // Sets the current channel as seen by the Feature system. In the browser
85 // ChannelForTesting if one is set, otherwise the actual channel). 79 // process this should be chrome::VersionInfo::GetChannel(), and in the
86 static chrome::VersionInfo::Channel GetCurrentChannel(); 80 // renderer this will need to come from an IPC.
81 static void SetCurrentChannel(chrome::VersionInfo::Channel channel);
82
83 // Clears the current channel as seen by the Feature system.
84 static void ClearCurrentChannel();
85
86 // Scoped channel setter. Use for tests.
87 class ScopedCurrentChannel {
88 public:
89 explicit ScopedCurrentChannel(chrome::VersionInfo::Channel channel)
90 : has_original_channel_(false),
91 original_channel_(chrome::VersionInfo::CHANNEL_UNKNOWN) {
92 if (HasCurrentChannel()) {
93 has_original_channel_ = true;
94 original_channel_ = GetCurrentChannel();
95 }
96 SetCurrentChannel(channel);
97 }
98
99 ~ScopedCurrentChannel() {
100 if (has_original_channel_)
101 SetCurrentChannel(original_channel_);
Matt Perry 2012/08/08 19:17:26 else: ClearCurrentChannel?
not at google - send to devlin 2012/08/09 00:14:37 Oops. Thanks.
102 }
103
104 private:
105 bool has_original_channel_;
106 chrome::VersionInfo::Channel original_channel_;
107 };
87 108
88 const std::string& name() const { return name_; } 109 const std::string& name() const { return name_; }
89 void set_name(const std::string& name) { name_ = name; } 110 void set_name(const std::string& name) { name_ = name; }
90 111
91 // Gets the platform the code is currently running on. 112 // Gets the platform the code is currently running on.
92 static Platform GetCurrentPlatform(); 113 static Platform GetCurrentPlatform();
93 114
94 // Gets the Feature::Location value for the specified Extension::Location. 115 // Gets the Feature::Location value for the specified Extension::Location.
95 static Location ConvertLocation(Extension::Location extension_location); 116 static Location ConvertLocation(Extension::Location extension_location);
96 117
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 Location location_; // we only care about component/not-component now 184 Location location_; // we only care about component/not-component now
164 Platform platform_; // we only care about chromeos/not-chromeos now 185 Platform platform_; // we only care about chromeos/not-chromeos now
165 int min_manifest_version_; 186 int min_manifest_version_;
166 int max_manifest_version_; 187 int max_manifest_version_;
167 chrome::VersionInfo::Channel channel_; 188 chrome::VersionInfo::Channel channel_;
168 }; 189 };
169 190
170 } // namespace extensions 191 } // namespace extensions
171 192
172 #endif // CHROME_COMMON_EXTENSIONS_FEATURES_FEATURE_H_ 193 #endif // CHROME_COMMON_EXTENSIONS_FEATURES_FEATURE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698