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

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: ready to land 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
« no previous file with comments | « chrome/common/chrome_switches.cc ('k') | chrome/common/extensions/feature_switch.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
22 public:
23 ScopedOverride(FeatureSwitch* feature, bool override_value);
24 ~ScopedOverride();
25 private:
26 friend FeatureSwitch;
27 FeatureSwitch* feature_;
28 bool previous_value_;
29 DISALLOW_COPY_AND_ASSIGN(ScopedOverride);
30 };
31
32 enum DefaultValue {
33 DEFAULT_ENABLED,
34 DEFAULT_DISABLED
35 };
36
37 FeatureSwitch(const CommandLine* command_line,
38 const char* switch_name,
39 DefaultValue default_value);
40
41 bool IsEnabled() const;
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
« no previous file with comments | « chrome/common/chrome_switches.cc ('k') | chrome/common/extensions/feature_switch.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698