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

Unified 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, 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/feature_switch.h
diff --git a/chrome/common/extensions/feature_switch.h b/chrome/common/extensions/feature_switch.h
new file mode 100644
index 0000000000000000000000000000000000000000..a65a975c60b3486a569aaca2b4c376eba07b442b
--- /dev/null
+++ b/chrome/common/extensions/feature_switch.h
@@ -0,0 +1,62 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_COMMON_EXTENSIONS_FEATURE_SWITCH_H_
+#define CHROME_COMMON_EXTENSIONS_FEATURE_SWITCH_H_
+
+#include "base/basictypes.h"
+
+class CommandLine;
+
+namespace extensions {
+
+// A switch that can turn a feature on or off. Typically controlled via
+// command-line switches but can be overridden, e.g., for testing.
+class FeatureSwitch {
+ public:
+ static FeatureSwitch* GetScriptBubble();
+
+ // A temporary override for the switch value.
+ 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.
+ public:
+ ~ScopedOverride();
+ private:
+ friend FeatureSwitch;
+ ScopedOverride(FeatureSwitch* feature, bool override_value);
+ FeatureSwitch* feature_;
+ bool previous_value_;
+ };
+
+ enum DefaultValue {
+ DEFAULT_ENABLED,
+ DEFAULT_DISABLED
+ };
+
+ FeatureSwitch(const CommandLine* command_line,
+ const char* switch_name,
+ DefaultValue default_value);
+
+ bool IsEnabled() const;
+ ScopedOverride Override(bool override_value);
+
+ private:
+ enum OverrideValue {
+ OVERRIDE_NONE,
+ OVERRIDE_ENABLED,
+ OVERRIDE_DISABLED
+ };
+
+ void SetOverrideValue(OverrideValue value);
+
+ const CommandLine* command_line_;
+ const char* switch_name_;
+ bool default_value_;
+ OverrideValue override_value_;
+
+ DISALLOW_COPY_AND_ASSIGN(FeatureSwitch);
+};
+
+} // namespace extensions
+
+#endif // CHROME_COMMON_EXTENSIONS_FEATURE_SWITCH_H_

Powered by Google App Engine
This is Rietveld 408576698