Add ICU message format support
[chromium-blink-merge.git] / content / browser / android / content_startup_flags.cc
blobebd585bcaf3426eb88dcbdcfffadaa9eed7d08b3
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 "cc/trees/layer_tree_settings.h"
15 #include "content/public/browser/android/compositor.h"
16 #include "content/public/browser/render_process_host.h"
17 #include "content/public/common/content_constants.h"
18 #include "content/public/common/content_switches.h"
19 #include "gpu/command_buffer/service/gpu_switches.h"
20 #include "ui/base/ui_base_switches.h"
21 #include "ui/native_theme/native_theme_switches.h"
23 namespace content {
25 void SetContentCommandLineFlags(bool single_process,
26 const std::string& plugin_descriptor) {
27 // May be called multiple times, to cover all possible program entry points.
28 static bool already_initialized = false;
29 if (already_initialized)
30 return;
31 already_initialized = true;
33 base::CommandLine* parsed_command_line =
34 base::CommandLine::ForCurrentProcess();
36 int command_line_renderer_limit = -1;
37 if (parsed_command_line->HasSwitch(switches::kRendererProcessLimit)) {
38 std::string limit = parsed_command_line->GetSwitchValueASCII(
39 switches::kRendererProcessLimit);
40 int value;
41 if (base::StringToInt(limit, &value)) {
42 command_line_renderer_limit = std::max(0, value);
46 if (command_line_renderer_limit > 0) {
47 int limit = std::min(command_line_renderer_limit,
48 static_cast<int>(kMaxRendererProcessCount));
49 RenderProcessHost::SetMaxRendererProcessCount(limit);
52 if (single_process || command_line_renderer_limit == 0) {
53 // Need to ensure the command line flag is consistent as a lot of chrome
54 // internal code checks this directly, but it wouldn't normally get set when
55 // we are implementing an embedded WebView.
56 parsed_command_line->AppendSwitch(switches::kSingleProcess);
59 parsed_command_line->AppendSwitch(cc::switches::kEnableBeginFrameScheduling);
61 parsed_command_line->AppendSwitch(switches::kEnablePinch);
62 parsed_command_line->AppendSwitch(switches::kEnableOverlayFullscreenVideo);
63 parsed_command_line->AppendSwitch(switches::kEnableOverlayScrollbar);
64 parsed_command_line->AppendSwitch(switches::kValidateInputEventStream);
66 // TODO(jdduke): Use the proper SDK version when available, crbug.com/466749.
67 if (base::android::BuildInfo::GetInstance()->sdk_int() >
68 base::android::SDK_VERSION_LOLLIPOP_MR1) {
69 parsed_command_line->AppendSwitch(switches::kEnableLongpressDragSelection);
70 parsed_command_line->AppendSwitchASCII(
71 switches::kTouchTextSelectionStrategy, "direction");
74 // There is no software fallback on Android, so don't limit GPU crashes.
75 parsed_command_line->AppendSwitch(switches::kDisableGpuProcessCrashLimit);
77 // On legacy low-memory devices the behavior has not been studied with regard
78 // to having an extra process with similar priority as the foreground renderer
79 // and given that the system will often be looking for a process to be killed
80 // on such systems.
81 if (base::SysInfo::IsLowEndDevice())
82 parsed_command_line->AppendSwitch(switches::kInProcessGPU);
84 parsed_command_line->AppendSwitch(switches::kEnableViewportMeta);
85 parsed_command_line->AppendSwitch(
86 switches::kMainFrameResizesAreOrientationChanges);
88 // Disable anti-aliasing.
89 parsed_command_line->AppendSwitch(
90 cc::switches::kDisableCompositedAntialiasing);
92 parsed_command_line->AppendSwitch(switches::kUIPrioritizeInGpuProcess);
94 parsed_command_line->AppendSwitch(switches::kEnableDelegatedRenderer);
96 if (!plugin_descriptor.empty()) {
97 parsed_command_line->AppendSwitchNative(
98 switches::kRegisterPepperPlugins, plugin_descriptor);
101 // Disable profiler timing by default.
102 if (!parsed_command_line->HasSwitch(switches::kProfilerTiming)) {
103 parsed_command_line->AppendSwitchASCII(
104 switches::kProfilerTiming, switches::kProfilerTimingDisabledValue);
107 cc::LayerSettings layer_settings;
108 if (parsed_command_line->HasSwitch(
109 switches::kEnableAndroidCompositorAnimationTimelines))
110 layer_settings.use_compositor_animation_timelines = true;
111 Compositor::SetLayerSettings(layer_settings);
114 } // namespace content