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

Side by Side Diff: extensions/common/feature_switch.cc

Issue 2633253002: Split content script injections into multiple tasks (Closed)
Patch Set: Inject document_idle scripts before window.onload Created 3 years, 10 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "extensions/common/feature_switch.h" 5 #include "extensions/common/feature_switch.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "extensions/common/switches.h" 12 #include "extensions/common/switches.h"
13 13
14 namespace extensions { 14 namespace extensions {
15 15
16 namespace { 16 namespace {
17 17
18 // The switch load-media-router-component-extension is defined in 18 // The switch load-media-router-component-extension is defined in
19 // chrome/common/chrome_switches.cc, but we can't depend on chrome here. 19 // chrome/common/chrome_switches.cc, but we can't depend on chrome here.
20 const char kLoadMediaRouterComponentExtensionFlag[] = 20 const char kLoadMediaRouterComponentExtensionFlag[] =
21 "load-media-router-component-extension"; 21 "load-media-router-component-extension";
22 22
23 const char kYieldBetweenContentScriptRuns[] = "YieldBetweenContentScriptRuns";
24
23 class CommonSwitches { 25 class CommonSwitches {
24 public: 26 public:
25 CommonSwitches() 27 CommonSwitches()
26 : force_dev_mode_highlighting(switches::kForceDevModeHighlighting, 28 : force_dev_mode_highlighting(switches::kForceDevModeHighlighting,
27 FeatureSwitch::DEFAULT_DISABLED), 29 FeatureSwitch::DEFAULT_DISABLED),
28 prompt_for_external_extensions( 30 prompt_for_external_extensions(
29 #if defined(CHROMIUM_BUILD) 31 #if defined(CHROMIUM_BUILD)
30 switches::kPromptForExternalExtensions, 32 switches::kPromptForExternalExtensions,
31 #else 33 #else
32 nullptr, 34 nullptr,
(...skipping 14 matching lines...) Expand all
47 trace_app_source(switches::kTraceAppSource, 49 trace_app_source(switches::kTraceAppSource,
48 FeatureSwitch::DEFAULT_ENABLED), 50 FeatureSwitch::DEFAULT_ENABLED),
49 load_media_router_component_extension( 51 load_media_router_component_extension(
50 kLoadMediaRouterComponentExtensionFlag, 52 kLoadMediaRouterComponentExtensionFlag,
51 #if defined(GOOGLE_CHROME_BUILD) 53 #if defined(GOOGLE_CHROME_BUILD)
52 FeatureSwitch::DEFAULT_ENABLED), 54 FeatureSwitch::DEFAULT_ENABLED),
53 #else 55 #else
54 FeatureSwitch::DEFAULT_DISABLED), 56 FeatureSwitch::DEFAULT_DISABLED),
55 #endif // defined(GOOGLE_CHROME_BUILD) 57 #endif // defined(GOOGLE_CHROME_BUILD)
56 native_crx_bindings(switches::kNativeCrxBindings, 58 native_crx_bindings(switches::kNativeCrxBindings,
57 FeatureSwitch::DEFAULT_DISABLED) { 59 FeatureSwitch::DEFAULT_DISABLED),
60 yield_between_content_script_runs(
61 switches::kYieldBetweenContentScriptRuns,
62 kYieldBetweenContentScriptRuns,
63 FeatureSwitch::DEFAULT_DISABLED) {
58 } 64 }
59 65
60 FeatureSwitch force_dev_mode_highlighting; 66 FeatureSwitch force_dev_mode_highlighting;
61 67
62 // Should we prompt the user before allowing external extensions to install? 68 // Should we prompt the user before allowing external extensions to install?
63 // Default is yes. 69 // Default is yes.
64 FeatureSwitch prompt_for_external_extensions; 70 FeatureSwitch prompt_for_external_extensions;
65 71
66 FeatureSwitch error_console; 72 FeatureSwitch error_console;
67 FeatureSwitch enable_override_bookmarks_ui; 73 FeatureSwitch enable_override_bookmarks_ui;
68 FeatureSwitch extension_action_redesign; 74 FeatureSwitch extension_action_redesign;
69 FeatureSwitch scripts_require_action; 75 FeatureSwitch scripts_require_action;
70 FeatureSwitch embedded_extension_options; 76 FeatureSwitch embedded_extension_options;
71 FeatureSwitch trace_app_source; 77 FeatureSwitch trace_app_source;
72 FeatureSwitch load_media_router_component_extension; 78 FeatureSwitch load_media_router_component_extension;
73 FeatureSwitch native_crx_bindings; 79 FeatureSwitch native_crx_bindings;
80 FeatureSwitch yield_between_content_script_runs;
74 }; 81 };
75 82
76 base::LazyInstance<CommonSwitches> g_common_switches = 83 base::LazyInstance<CommonSwitches> g_common_switches =
77 LAZY_INSTANCE_INITIALIZER; 84 LAZY_INSTANCE_INITIALIZER;
78 85
79 } // namespace 86 } // namespace
80 87
81 FeatureSwitch* FeatureSwitch::force_dev_mode_highlighting() { 88 FeatureSwitch* FeatureSwitch::force_dev_mode_highlighting() {
82 return &g_common_switches.Get().force_dev_mode_highlighting; 89 return &g_common_switches.Get().force_dev_mode_highlighting;
83 } 90 }
(...skipping 17 matching lines...) Expand all
101 } 108 }
102 FeatureSwitch* FeatureSwitch::trace_app_source() { 109 FeatureSwitch* FeatureSwitch::trace_app_source() {
103 return &g_common_switches.Get().trace_app_source; 110 return &g_common_switches.Get().trace_app_source;
104 } 111 }
105 FeatureSwitch* FeatureSwitch::load_media_router_component_extension() { 112 FeatureSwitch* FeatureSwitch::load_media_router_component_extension() {
106 return &g_common_switches.Get().load_media_router_component_extension; 113 return &g_common_switches.Get().load_media_router_component_extension;
107 } 114 }
108 FeatureSwitch* FeatureSwitch::native_crx_bindings() { 115 FeatureSwitch* FeatureSwitch::native_crx_bindings() {
109 return &g_common_switches.Get().native_crx_bindings; 116 return &g_common_switches.Get().native_crx_bindings;
110 } 117 }
118 FeatureSwitch* FeatureSwitch::yield_between_content_script_runs() {
119 return &g_common_switches.Get().yield_between_content_script_runs;
120 }
111 121
112 FeatureSwitch::ScopedOverride::ScopedOverride(FeatureSwitch* feature, 122 FeatureSwitch::ScopedOverride::ScopedOverride(FeatureSwitch* feature,
113 bool override_value) 123 bool override_value)
114 : feature_(feature), 124 : feature_(feature),
115 previous_value_(feature->GetOverrideValue()) { 125 previous_value_(feature->GetOverrideValue()) {
116 feature_->SetOverrideValue( 126 feature_->SetOverrideValue(
117 override_value ? OVERRIDE_ENABLED : OVERRIDE_DISABLED); 127 override_value ? OVERRIDE_ENABLED : OVERRIDE_DISABLED);
118 } 128 }
119 129
120 FeatureSwitch::ScopedOverride::~ScopedOverride() { 130 FeatureSwitch::ScopedOverride::~ScopedOverride() {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 210
201 void FeatureSwitch::SetOverrideValue(OverrideValue override_value) { 211 void FeatureSwitch::SetOverrideValue(OverrideValue override_value) {
202 override_value_ = override_value; 212 override_value_ = override_value;
203 } 213 }
204 214
205 FeatureSwitch::OverrideValue FeatureSwitch::GetOverrideValue() const { 215 FeatureSwitch::OverrideValue FeatureSwitch::GetOverrideValue() const {
206 return override_value_; 216 return override_value_;
207 } 217 }
208 218
209 } // namespace extensions 219 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698