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.
5 #include "content/browser/android/content_startup_flags.h"
7 #include "base/base_switches.h"
8 #include "base/command_line.h"
9 #include "base/logging.h"
10 #include "base/strings/string_number_conversions.h"
11 #include "cc/base/switches.h"
12 #include "content/public/browser/render_process_host.h"
13 #include "content/public/common/content_constants.h"
14 #include "content/public/common/content_switches.h"
15 #include "gpu/command_buffer/service/gpu_switches.h"
16 #include "ui/base/ui_base_switches.h"
17 #include "ui/native_theme/native_theme_switches.h"
21 void SetContentCommandLineFlags(int max_render_process_count
,
22 const std::string
& plugin_descriptor
) {
23 // May be called multiple times, to cover all possible program entry points.
24 static bool already_initialized
= false;
25 if (already_initialized
)
27 already_initialized
= true;
29 CommandLine
* parsed_command_line
= CommandLine::ForCurrentProcess();
31 int command_line_renderer_limit
= -1;
32 if (parsed_command_line
->HasSwitch(switches::kRendererProcessLimit
)) {
33 std::string limit
= parsed_command_line
->GetSwitchValueASCII(
34 switches::kRendererProcessLimit
);
36 if (base::StringToInt(limit
, &value
)) {
37 command_line_renderer_limit
= value
;
39 max_render_process_count
= 0;
43 if (command_line_renderer_limit
> 0) {
44 int limit
= std::min(command_line_renderer_limit
,
45 static_cast<int>(kMaxRendererProcessCount
));
46 RenderProcessHost::SetMaxRendererProcessCount(limit
);
47 } else if (max_render_process_count
<= 0) {
48 // Need to ensure the command line flag is consistent as a lot of chrome
49 // internal code checks this directly, but it wouldn't normally get set when
50 // we are implementing an embedded WebView.
51 parsed_command_line
->AppendSwitch(switches::kSingleProcess
);
53 int default_maximum
= RenderProcessHost::GetMaxRendererProcessCount();
54 DCHECK(default_maximum
<= static_cast<int>(kMaxRendererProcessCount
));
55 if (max_render_process_count
< default_maximum
)
56 RenderProcessHost::SetMaxRendererProcessCount(max_render_process_count
);
59 parsed_command_line
->AppendSwitch(switches::kForceCompositingMode
);
60 parsed_command_line
->AppendSwitch(switches::kEnableThreadedCompositing
);
61 parsed_command_line
->AppendSwitch(
62 switches::kEnableCompositingForFixedPosition
);
63 parsed_command_line
->AppendSwitch(switches::kEnableAcceleratedOverflowScroll
);
64 parsed_command_line
->AppendSwitch(switches::kEnableBeginFrameScheduling
);
66 parsed_command_line
->AppendSwitch(switches::kDisableGestureDebounce
);
67 parsed_command_line
->AppendSwitch(switches::kEnableGestureTapHighlight
);
68 parsed_command_line
->AppendSwitch(switches::kEnablePinch
);
69 parsed_command_line
->AppendSwitch(switches::kEnableOverlayFullscreenVideo
);
70 parsed_command_line
->AppendSwitch(switches::kEnableOverlayScrollbar
);
71 parsed_command_line
->AppendSwitch(switches::kEnableOverscrollNotifications
);
72 parsed_command_line
->AppendSwitchASCII(switches::kTouchAckTimeoutDelayMs
,
75 // Run the GPU service as a thread in the browser instead of as a
76 // standalone process.
77 parsed_command_line
->AppendSwitch(switches::kInProcessGPU
);
78 parsed_command_line
->AppendSwitch(switches::kDisableGpuShaderDiskCache
);
80 parsed_command_line
->AppendSwitch(switches::kEnableViewport
);
81 parsed_command_line
->AppendSwitch(switches::kEnableViewportMeta
);
82 parsed_command_line
->AppendSwitch(
83 switches::kMainFrameResizesAreOrientationChanges
);
85 // Disable anti-aliasing.
86 parsed_command_line
->AppendSwitch(
87 cc::switches::kDisableCompositedAntialiasing
);
89 parsed_command_line
->AppendSwitch(switches::kUIPrioritizeInGpuProcess
);
91 parsed_command_line
->AppendSwitch(switches::kEnableDelegatedRenderer
);
93 if (!plugin_descriptor
.empty()) {
94 parsed_command_line
->AppendSwitchNative(
95 switches::kRegisterPepperPlugins
, plugin_descriptor
);
98 // Disable profiler timing by default.
99 if (!parsed_command_line
->HasSwitch(switches::kProfilerTiming
)) {
100 parsed_command_line
->AppendSwitchASCII(
101 switches::kProfilerTiming
, switches::kProfilerTimingDisabledValue
);
105 } // namespace content