Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / content / browser / android / content_startup_flags.cc
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.
4
5 #include "content/browser/android/content_startup_flags.h"
6
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"
18
19 namespace content {
20
21 void SetContentCommandLineFlags(bool single_process,
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)
26     return;
27   already_initialized = true;
28
29   base::CommandLine* parsed_command_line =
30       base::CommandLine::ForCurrentProcess();
31
32   int command_line_renderer_limit = -1;
33   if (parsed_command_line->HasSwitch(switches::kRendererProcessLimit)) {
34     std::string limit = parsed_command_line->GetSwitchValueASCII(
35         switches::kRendererProcessLimit);
36     int value;
37     if (base::StringToInt(limit, &value)) {
38       command_line_renderer_limit = std::max(0, value);
39     }
40   }
41
42   if (command_line_renderer_limit > 0) {
43     int limit = std::min(command_line_renderer_limit,
44                          static_cast<int>(kMaxRendererProcessCount));
45     RenderProcessHost::SetMaxRendererProcessCount(limit);
46   }
47
48   if (single_process || command_line_renderer_limit == 0) {
49     // Need to ensure the command line flag is consistent as a lot of chrome
50     // internal code checks this directly, but it wouldn't normally get set when
51     // we are implementing an embedded WebView.
52     parsed_command_line->AppendSwitch(switches::kSingleProcess);
53   }
54
55   parsed_command_line->AppendSwitch(
56       switches::kEnableCompositingForFixedPosition);
57   parsed_command_line->AppendSwitch(switches::kEnableAcceleratedOverflowScroll);
58   parsed_command_line->AppendSwitch(switches::kEnableBeginFrameScheduling);
59
60   parsed_command_line->AppendSwitch(switches::kEnablePinch);
61   parsed_command_line->AppendSwitch(switches::kEnableOverlayFullscreenVideo);
62   parsed_command_line->AppendSwitch(switches::kEnableOverlayScrollbar);
63   parsed_command_line->AppendSwitch(switches::kEnableOverscrollNotifications);
64
65   // Run the GPU service as a thread in the browser instead of as a
66   // standalone process.
67   parsed_command_line->AppendSwitch(switches::kInProcessGPU);
68   parsed_command_line->AppendSwitch(switches::kDisableGpuShaderDiskCache);
69
70   parsed_command_line->AppendSwitch(switches::kEnableViewport);
71   parsed_command_line->AppendSwitch(switches::kEnableViewportMeta);
72   parsed_command_line->AppendSwitch(
73       switches::kMainFrameResizesAreOrientationChanges);
74
75   // Disable anti-aliasing.
76   parsed_command_line->AppendSwitch(
77       cc::switches::kDisableCompositedAntialiasing);
78
79   parsed_command_line->AppendSwitch(switches::kUIPrioritizeInGpuProcess);
80
81   parsed_command_line->AppendSwitch(switches::kEnableDelegatedRenderer);
82
83   if (!plugin_descriptor.empty()) {
84     parsed_command_line->AppendSwitchNative(
85       switches::kRegisterPepperPlugins, plugin_descriptor);
86   }
87
88   // Disable profiler timing by default.
89   if (!parsed_command_line->HasSwitch(switches::kProfilerTiming)) {
90     parsed_command_line->AppendSwitchASCII(
91         switches::kProfilerTiming, switches::kProfilerTimingDisabledValue);
92   }
93 }
94
95 }  // namespace content