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

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

Issue 11014009: Beginnings of the script bubble. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More minor cleanup Created 8 years, 2 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_COMMON_EXTENSIONS_FEATURE_SWITCH_H_
6 #define CHROME_COMMON_EXTENSIONS_FEATURE_SWITCH_H_
7
8 #include "base/basictypes.h"
9
10 class CommandLine;
11
12 namespace extensions {
13
14 // A switch that can turn a feature on or off. Typically controlled via
15 // command-line switches but can be overridden, e.g., for testing.
16 class FeatureSwitch {
17 public:
18 static FeatureSwitch* GetScriptBubble();
19
20 // A temporary override for the switch value.
21 class ScopedOverride {
Jeffrey Yasskin 2012/10/02 00:26:31 You should DISALLOW_COPY_AND_ASSIGN on this or it'
Aaron Boodman 2012/10/02 01:28:52 good point, done.
22 public:
23 ~ScopedOverride();
24 private:
25 friend FeatureSwitch;
26 ScopedOverride(FeatureSwitch* feature, bool override_value);
27 FeatureSwitch* feature_;
28 bool previous_value_;
29 };
30
31 enum DefaultValue {
32 DEFAULT_ENABLED,
33 DEFAULT_DISABLED
34 };
35
36 FeatureSwitch(const CommandLine* command_line,
37 const char* switch_name,
38 DefaultValue default_value);
39
40 bool IsEnabled() const;
41 ScopedOverride Override(bool override_value);
42
43 private:
44 enum OverrideValue {
45 OVERRIDE_NONE,
46 OVERRIDE_ENABLED,
47 OVERRIDE_DISABLED
48 };
49
50 void SetOverrideValue(OverrideValue value);
51
52 const CommandLine* command_line_;
53 const char* switch_name_;
54 bool default_value_;
55 OverrideValue override_value_;
56
57 DISALLOW_COPY_AND_ASSIGN(FeatureSwitch);
58 };
59
60 } // namespace extensions
61
62 #endif // CHROME_COMMON_EXTENSIONS_FEATURE_SWITCH_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698