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

Unified Diff: chrome/common/extensions/extension_switch_utils.cc

Issue 10565017: Parse the script_badge manifest section. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix more review comments, and make script_badge_ non-mutable Created 8 years, 6 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/extension_switch_utils.cc
diff --git a/chrome/common/extensions/extension_switch_utils.cc b/chrome/common/extensions/extension_switch_utils.cc
index 8b41231917b059c0acb68c24542dda745838f411..42b27bb7d7388fba5a25450e502b21155c0c9947 100644
--- a/chrome/common/extensions/extension_switch_utils.cc
+++ b/chrome/common/extensions/extension_switch_utils.cc
@@ -5,6 +5,7 @@
#include "chrome/common/extensions/extension_switch_utils.h"
#include "base/command_line.h"
+#include "base/logging.h"
#include "chrome/common/chrome_switches.h"
namespace extensions {
@@ -27,9 +28,42 @@ bool IsActionBoxEnabled() {
switches::kEnableActionBox);
}
+enum SwitchState {
+ USE_COMMAND_LINE,
+ FORCE_ENABLE,
+ FORCE_DISABLE
+};
+static SwitchState script_badge_switch_state = USE_COMMAND_LINE;
+
+
bool AreScriptBadgesEnabled() {
- return CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableScriptBadges);
+ switch (script_badge_switch_state) {
+ case USE_COMMAND_LINE:
+ return CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableScriptBadges);
+ case FORCE_ENABLE:
+ return true;
+ case FORCE_DISABLE:
+ return false;
+ }
+ NOTREACHED();
+ return false;
+}
+
+ScopedSetScriptBadgeForTest::ScopedSetScriptBadgeForTest(EnabledState state) {
+ CHECK(script_badge_switch_state == USE_COMMAND_LINE)
+ << "Can't nest ScopedSetScriptBadgeForTest instances.";
+ switch (state) {
+ case ENABLED:
+ script_badge_switch_state = FORCE_ENABLE;
+ break;
+ case DISABLED:
+ script_badge_switch_state = FORCE_DISABLE;
+ break;
+ }
+}
+ScopedSetScriptBadgeForTest::~ScopedSetScriptBadgeForTest() {
+ script_badge_switch_state = USE_COMMAND_LINE;
}
} // switch_utils

Powered by Google App Engine
This is Rietveld 408576698