OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/android/content_startup_flags.h" | 5 #include "content/browser/android/content_startup_flags.h" |
6 | 6 |
7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
8 #include "base/string_split.h" | |
9 #include "base/command_line.h" | 8 #include "base/command_line.h" |
10 #include "base/logging.h" | 9 #include "base/logging.h" |
11 #include "content/public/browser/render_process_host.h" | 10 #include "content/public/browser/render_process_host.h" |
12 #include "content/public/common/content_constants.h" | 11 #include "content/public/common/content_constants.h" |
13 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
14 #include "ui/base/ui_base_switches.h" | 13 #include "ui/base/ui_base_switches.h" |
15 | 14 |
16 namespace { | |
17 | |
18 void SetCommandLineSwitch(const std::string& switch_string) { | |
19 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
20 if (!command_line->HasSwitch(switch_string)) | |
21 command_line->AppendSwitch(switch_string); | |
22 } | |
23 | |
24 void SetPepperCommandLineFlags(std::string plugin_descriptor) { | |
25 CommandLine* parsed_command_line = CommandLine::ForCurrentProcess(); | |
26 | |
27 // Get the plugin info from the Java side. kRegisterPepperPlugins needs to be | |
28 // added to the CommandLine before either PluginService::GetInstance() or | |
29 // BrowserRenderProcessHost::AppendRendererCommandLine() is called to ensure | |
30 // the plugin is available. | |
31 // TODO(klobag) with the current implementation, the plugin can only be added | |
32 // in the process start up time. Need to look into whether we can add the | |
33 // plugin when the process is running. | |
34 if (!plugin_descriptor.empty()) { | |
35 parsed_command_line->AppendSwitchNative(switches::kRegisterPepperPlugins, | |
36 plugin_descriptor); | |
37 } | |
38 } | |
39 | |
40 } // namespace | |
41 | |
42 namespace content { | 15 namespace content { |
43 | 16 |
44 void SetContentCommandLineFlags(int max_render_process_count, | 17 void SetContentCommandLineFlags(int max_render_process_count) { |
45 const std::string& plugin_descriptor) { | |
46 // May be called multiple times, to cover all possible program entry points. | 18 // May be called multiple times, to cover all possible program entry points. |
47 static bool already_initialized = false; | 19 static bool already_initialized = false; |
48 if (already_initialized) return; | 20 if (already_initialized) |
| 21 return; |
49 already_initialized = true; | 22 already_initialized = true; |
50 | 23 |
51 CommandLine* parsed_command_line = CommandLine::ForCurrentProcess(); | 24 CommandLine* parsed_command_line = CommandLine::ForCurrentProcess(); |
52 | 25 |
53 | |
54 // TODO(yfriedman): Upstream this when bringing up rendering code and | |
55 // rendering modes. b/6668088 | |
56 // Set subflags for the --graphics-mode=XYZ omnibus flag. | |
57 std::string graphics_mode; | |
58 if (parsed_command_line->HasSwitch(switches::kGraphicsMode)) { | |
59 graphics_mode = parsed_command_line->GetSwitchValueASCII( | |
60 switches::kGraphicsMode); | |
61 } else { | |
62 // Default mode is threaded compositor mode | |
63 graphics_mode = switches::kGraphicsModeValueCompositor; | |
64 parsed_command_line->AppendSwitchNative( | |
65 switches::kGraphicsMode, graphics_mode.c_str()); | |
66 } | |
67 | |
68 if (graphics_mode == switches::kGraphicsModeValueBasic) { | |
69 // Intentionally blank. | |
70 } else if (graphics_mode == switches::kGraphicsModeValueCompositor) { | |
71 SetCommandLineSwitch(switches::kForceCompositingMode); | |
72 SetCommandLineSwitch(switches::kEnableAcceleratedPlugins); | |
73 SetCommandLineSwitch(switches::kEnableCompositingForFixedPosition); | |
74 SetCommandLineSwitch(switches::kEnableThreadedCompositing); | |
75 // Per tile painting saves memory in background tabs (http://b/5669228). | |
76 // ...but it now fails an SkAssert(), so disable it. b/6819634 | |
77 // SetCommandLineSwitch(switches::kEnablePerTilePainting); | |
78 } else { | |
79 LOG(FATAL) << "Invalid --graphics-mode flag: " << graphics_mode; | |
80 } | |
81 | |
82 if (parsed_command_line->HasSwitch(switches::kRendererProcessLimit)) { | 26 if (parsed_command_line->HasSwitch(switches::kRendererProcessLimit)) { |
83 std::string limit = parsed_command_line->GetSwitchValueASCII( | 27 std::string limit = parsed_command_line->GetSwitchValueASCII( |
84 switches::kRendererProcessLimit); | 28 switches::kRendererProcessLimit); |
85 int value; | 29 int value; |
86 if (base::StringToInt(limit, &value)) | 30 if (base::StringToInt(limit, &value)) |
87 max_render_process_count = value; | 31 max_render_process_count = value; |
88 } | 32 } |
89 | 33 |
90 if (max_render_process_count <= 0) { | 34 if (max_render_process_count <= 0) { |
91 // Need to ensure the command line flag is consistent as a lot of chrome | 35 // Need to ensure the command line flag is consistent as a lot of chrome |
92 // internal code checks this directly, but it wouldn't normally get set when | 36 // internal code checks this directly, but it wouldn't normally get set when |
93 // we are implementing an embedded WebView. | 37 // we are implementing an embedded WebView. |
94 SetCommandLineSwitch(switches::kSingleProcess); | 38 parsed_command_line->AppendSwitch(switches::kSingleProcess); |
95 } else { | 39 } else { |
96 max_render_process_count = | 40 max_render_process_count = |
97 std::min(max_render_process_count, | 41 std::min(max_render_process_count, |
98 static_cast<int>(content::kMaxRendererProcessCount)); | 42 static_cast<int>(content::kMaxRendererProcessCount)); |
99 content::RenderProcessHost::SetMaxRendererProcessCount( | 43 content::RenderProcessHost::SetMaxRendererProcessCount( |
100 max_render_process_count); | 44 max_render_process_count); |
101 } | 45 } |
102 | 46 |
103 // Load plugins out-of-process by default. | 47 parsed_command_line->AppendSwitch(switches::kForceCompositingMode); |
104 // We always want flash out-of-process. | 48 parsed_command_line->AppendSwitch(switches::kEnableThreadedCompositing); |
105 parsed_command_line->AppendSwitch(switches::kPpapiOutOfProcess); | 49 parsed_command_line->AppendSwitch( |
| 50 switches::kEnableCompositingForFixedPosition); |
| 51 |
| 52 parsed_command_line->AppendSwitch(switches::kEnableGestureTapHighlight); |
| 53 parsed_command_line->AppendSwitch(switches::kEnableTouchEvents); |
| 54 parsed_command_line->AppendSwitch(switches::kEnablePinch); |
106 | 55 |
107 // Run the GPU service as a thread in the browser instead of as a | 56 // Run the GPU service as a thread in the browser instead of as a |
108 // standalone process. | 57 // standalone process. |
109 parsed_command_line->AppendSwitch(switches::kInProcessGPU); | 58 parsed_command_line->AppendSwitch(switches::kInProcessGPU); |
110 | 59 |
111 // Always use fixed layout and viewport tag. | 60 // Always use fixed layout and viewport tag. |
112 parsed_command_line->AppendSwitch(switches::kEnableFixedLayout); | 61 parsed_command_line->AppendSwitch(switches::kEnableFixedLayout); |
113 parsed_command_line->AppendSwitch(switches::kEnableViewport); | 62 parsed_command_line->AppendSwitch(switches::kEnableViewport); |
114 | |
115 // TODO(aelias): switch this to true value of deviceScaleFactor once floats | |
116 // are supported | |
117 parsed_command_line->AppendSwitchASCII(switches::kForceDeviceScaleFactor, | |
118 "1"); | |
119 | |
120 // TODO(aelias): Enable these flags once they're merged in from upstream. | |
121 // parsed_command_line->AppendSwitch(switches::kEnableTouchEvents); | |
122 // parsed_command_line->AppendSwitch(switches::kEnablePinch); | |
123 | |
124 SetPepperCommandLineFlags(plugin_descriptor); | |
125 } | 63 } |
126 | 64 |
127 } // namespace content | 65 } // namespace content |
OLD | NEW |