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

Side by Side 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 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 #include "chrome/common/extensions/extension_switch_utils.h" 5 #include "chrome/common/extensions/extension_switch_utils.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h"
8 #include "chrome/common/chrome_switches.h" 9 #include "chrome/common/chrome_switches.h"
9 10
10 namespace extensions { 11 namespace extensions {
11 12
12 namespace switch_utils { 13 namespace switch_utils {
13 14
14 bool IsEasyOffStoreInstallEnabled() { 15 bool IsEasyOffStoreInstallEnabled() {
15 // Disabling easy off-store installation is not yet implemented for Aura. Not 16 // Disabling easy off-store installation is not yet implemented for Aura. Not
16 // sure what the Aura equivalent for this UI is. 17 // sure what the Aura equivalent for this UI is.
17 #if defined(USE_AURA) 18 #if defined(USE_AURA)
18 return true; 19 return true;
19 #else 20 #else
20 return CommandLine::ForCurrentProcess()->HasSwitch( 21 return CommandLine::ForCurrentProcess()->HasSwitch(
21 switches::kEnableEasyOffStoreExtensionInstall); 22 switches::kEnableEasyOffStoreExtensionInstall);
22 #endif 23 #endif
23 } 24 }
24 25
25 bool IsActionBoxEnabled() { 26 bool IsActionBoxEnabled() {
26 return CommandLine::ForCurrentProcess()->HasSwitch( 27 return CommandLine::ForCurrentProcess()->HasSwitch(
27 switches::kEnableActionBox); 28 switches::kEnableActionBox);
28 } 29 }
29 30
31 enum SwitchState {
32 USE_COMMAND_LINE,
33 FORCE_ENABLE,
34 FORCE_DISABLE
35 };
36 static SwitchState script_badge_switch_state = USE_COMMAND_LINE;
37
38
30 bool AreScriptBadgesEnabled() { 39 bool AreScriptBadgesEnabled() {
31 return CommandLine::ForCurrentProcess()->HasSwitch( 40 switch (script_badge_switch_state) {
32 switches::kEnableScriptBadges); 41 case USE_COMMAND_LINE:
42 return CommandLine::ForCurrentProcess()->HasSwitch(
43 switches::kEnableScriptBadges);
44 case FORCE_ENABLE:
45 return true;
46 case FORCE_DISABLE:
47 return false;
48 }
49 NOTREACHED();
50 return false;
51 }
52
53 ScopedSetScriptBadgeForTest::ScopedSetScriptBadgeForTest(EnabledState state) {
54 CHECK(script_badge_switch_state == USE_COMMAND_LINE)
55 << "Can't nest ScopedSetScriptBadgeForTest instances.";
56 switch (state) {
57 case ENABLED:
58 script_badge_switch_state = FORCE_ENABLE;
59 break;
60 case DISABLED:
61 script_badge_switch_state = FORCE_DISABLE;
62 break;
63 }
64 }
65 ScopedSetScriptBadgeForTest::~ScopedSetScriptBadgeForTest() {
66 script_badge_switch_state = USE_COMMAND_LINE;
33 } 67 }
34 68
35 } // switch_utils 69 } // switch_utils
36 70
37 } // extensions 71 } // extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698