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/android/build_info.h"
8 #include "base/base_switches.h"
9 #include "base/command_line.h"
10 #include "base/logging.h"
11 #include "base/strings/string_number_conversions.h"
12 #include "base/sys_info.h"
13 #include "cc/base/switches.h"
14 #include "content/public/browser/render_process_host.h"
15 #include "content/public/common/content_constants.h"
16 #include "content/public/common/content_switches.h"
17 #include "gpu/command_buffer/service/gpu_switches.h"
18 #include "ui/base/ui_base_switches.h"
19 #include "ui/native_theme/native_theme_switches.h"
23 void SetContentCommandLineFlags(bool single_process
,
24 const std::string
& plugin_descriptor
) {
25 // May be called multiple times, to cover all possible program entry points.
26 static bool already_initialized
= false;
27 if (already_initialized
)
29 already_initialized
= true;
31 base::CommandLine
* parsed_command_line
=
32 base::CommandLine::ForCurrentProcess();
34 int command_line_renderer_limit
= -1;
35 if (parsed_command_line
->HasSwitch(switches::kRendererProcessLimit
)) {
36 std::string limit
= parsed_command_line
->GetSwitchValueASCII(
37 switches::kRendererProcessLimit
);
39 if (base::StringToInt(limit
, &value
)) {
40 command_line_renderer_limit
= std::max(0, value
);
44 if (command_line_renderer_limit
> 0) {
45 int limit
= std::min(command_line_renderer_limit
,
46 static_cast<int>(kMaxRendererProcessCount
));
47 RenderProcessHost::SetMaxRendererProcessCount(limit
);
50 if (single_process
|| command_line_renderer_limit
== 0) {
51 // Need to ensure the command line flag is consistent as a lot of chrome
52 // internal code checks this directly, but it wouldn't normally get set when
53 // we are implementing an embedded WebView.
54 parsed_command_line
->AppendSwitch(switches::kSingleProcess
);
57 parsed_command_line
->AppendSwitch(switches::kEnableBeginFrameScheduling
);
59 parsed_command_line
->AppendSwitch(switches::kEnablePinch
);
60 parsed_command_line
->AppendSwitch(switches::kEnableOverlayFullscreenVideo
);
61 parsed_command_line
->AppendSwitch(switches::kEnableOverlayScrollbar
);
62 parsed_command_line
->AppendSwitch(switches::kValidateInputEventStream
);
64 // There is no software fallback on Android, so don't limit GPU crashes.
65 parsed_command_line
->AppendSwitch(switches::kDisableGpuProcessCrashLimit
);
67 // On legacy low-memory devices the behavior has not been studied with regard
68 // to having an extra process with similar priority as the foreground renderer
69 // and given that the system will often be looking for a process to be killed
71 if (base::SysInfo::IsLowEndDevice())
72 parsed_command_line
->AppendSwitch(switches::kInProcessGPU
);
74 // Web Notifications are only supported on Android JellyBean and beyond.
75 if (base::android::BuildInfo::GetInstance()->sdk_int() <
76 base::android::SDK_VERSION_JELLY_BEAN
) {
77 parsed_command_line
->AppendSwitch(switches::kDisableNotifications
);
80 parsed_command_line
->AppendSwitch(switches::kEnableViewportMeta
);
81 parsed_command_line
->AppendSwitch(
82 switches::kMainFrameResizesAreOrientationChanges
);
84 // Disable anti-aliasing.
85 parsed_command_line
->AppendSwitch(
86 cc::switches::kDisableCompositedAntialiasing
);
88 parsed_command_line
->AppendSwitch(switches::kUIPrioritizeInGpuProcess
);
90 parsed_command_line
->AppendSwitch(switches::kEnableDelegatedRenderer
);
92 if (!plugin_descriptor
.empty()) {
93 parsed_command_line
->AppendSwitchNative(
94 switches::kRegisterPepperPlugins
, plugin_descriptor
);
97 // Disable profiler timing by default.
98 if (!parsed_command_line
->HasSwitch(switches::kProfilerTiming
)) {
99 parsed_command_line
->AppendSwitchASCII(
100 switches::kProfilerTiming
, switches::kProfilerTimingDisabledValue
);
104 } // namespace content