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/command_line.h"
8 #include "base/logging.h"
9 #include "base/strings/string_number_conversions.h"
10 #include "cc/base/switches.h"
11 #include "content/public/browser/render_process_host.h"
12 #include "content/public/common/content_constants.h"
13 #include "content/public/common/content_switches.h"
14 #include "gpu/command_buffer/service/gpu_switches.h"
15 #include "ui/base/ui_base_switches.h"
19 void SetContentCommandLineFlags(int max_render_process_count,
20 const std::string& plugin_descriptor) {
21 // May be called multiple times, to cover all possible program entry points.
22 static bool already_initialized = false;
23 if (already_initialized)
25 already_initialized = true;
27 CommandLine* parsed_command_line = CommandLine::ForCurrentProcess();
29 if (parsed_command_line->HasSwitch(switches::kRendererProcessLimit)) {
30 std::string limit = parsed_command_line->GetSwitchValueASCII(
31 switches::kRendererProcessLimit);
33 if (base::StringToInt(limit, &value))
34 max_render_process_count = value;
37 if (max_render_process_count <= 0) {
38 // Need to ensure the command line flag is consistent as a lot of chrome
39 // internal code checks this directly, but it wouldn't normally get set when
40 // we are implementing an embedded WebView.
41 parsed_command_line->AppendSwitch(switches::kSingleProcess);
43 max_render_process_count =
44 std::min(max_render_process_count,
45 static_cast<int>(content::kMaxRendererProcessCount));
46 content::RenderProcessHost::SetMaxRendererProcessCount(
47 max_render_process_count);
50 parsed_command_line->AppendSwitch(switches::kForceCompositingMode);
51 parsed_command_line->AppendSwitch(switches::kAllowWebUICompositing);
52 parsed_command_line->AppendSwitch(switches::kEnableThreadedCompositing);
53 parsed_command_line->AppendSwitch(
54 switches::kEnableCompositingForFixedPosition);
55 parsed_command_line->AppendSwitch(switches::kEnableAcceleratedOverflowScroll);
56 parsed_command_line->AppendSwitch(
57 switches::kEnableAcceleratedScrollableFrames);
58 parsed_command_line->AppendSwitch(
59 switches::kEnableCompositedScrollingForFrames);
60 parsed_command_line->AppendSwitch(switches::kEnableBeginFrameScheduling);
61 parsed_command_line->AppendSwitch(switches::kEnableDeadlineScheduling);
63 parsed_command_line->AppendSwitch(switches::kEnableGestureTapHighlight);
64 parsed_command_line->AppendSwitch(switches::kEnablePinch);
65 parsed_command_line->AppendSwitch(switches::kEnableOverlayFullscreenVideo);
66 parsed_command_line->AppendSwitch(switches::kEnableOverlayScrollbars);
67 parsed_command_line->AppendSwitch(switches::kEnableOverscrollNotifications);
69 // Run the GPU service as a thread in the browser instead of as a
70 // standalone process.
71 parsed_command_line->AppendSwitch(switches::kInProcessGPU);
72 parsed_command_line->AppendSwitch(switches::kDisableGpuShaderDiskCache);
74 parsed_command_line->AppendSwitch(switches::kEnableViewport);
76 // Disable anti-aliasing.
77 parsed_command_line->AppendSwitch(
78 cc::switches::kDisableCompositedAntialiasing);
80 if (!plugin_descriptor.empty()) {
81 parsed_command_line->AppendSwitchNative(
82 switches::kRegisterPepperPlugins, plugin_descriptor);
86 } // namespace content