[Mac] Implement Ambient Light API
[chromium-blink-merge.git] / content / browser / android / content_startup_flags.cc
blob7202397494e9366954f521694cd8eb4af1a5e54d
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/base_switches.h"
8 #include "base/command_line.h"
9 #include "base/logging.h"
10 #include "base/strings/string_number_conversions.h"
11 #include "base/sys_info.h"
12 #include "cc/base/switches.h"
13 #include "content/public/browser/render_process_host.h"
14 #include "content/public/common/content_constants.h"
15 #include "content/public/common/content_switches.h"
16 #include "gpu/command_buffer/service/gpu_switches.h"
17 #include "ui/base/ui_base_switches.h"
18 #include "ui/native_theme/native_theme_switches.h"
20 namespace content {
22 void SetContentCommandLineFlags(bool single_process,
23 const std::string& plugin_descriptor) {
24 // May be called multiple times, to cover all possible program entry points.
25 static bool already_initialized = false;
26 if (already_initialized)
27 return;
28 already_initialized = true;
30 base::CommandLine* parsed_command_line =
31 base::CommandLine::ForCurrentProcess();
33 int command_line_renderer_limit = -1;
34 if (parsed_command_line->HasSwitch(switches::kRendererProcessLimit)) {
35 std::string limit = parsed_command_line->GetSwitchValueASCII(
36 switches::kRendererProcessLimit);
37 int value;
38 if (base::StringToInt(limit, &value)) {
39 command_line_renderer_limit = std::max(0, value);
43 if (command_line_renderer_limit > 0) {
44 int limit = std::min(command_line_renderer_limit,
45 static_cast<int>(kMaxRendererProcessCount));
46 RenderProcessHost::SetMaxRendererProcessCount(limit);
49 if (single_process || command_line_renderer_limit == 0) {
50 // Need to ensure the command line flag is consistent as a lot of chrome
51 // internal code checks this directly, but it wouldn't normally get set when
52 // we are implementing an embedded WebView.
53 parsed_command_line->AppendSwitch(switches::kSingleProcess);
56 parsed_command_line->AppendSwitch(switches::kEnableBeginFrameScheduling);
58 parsed_command_line->AppendSwitch(switches::kEnablePinch);
59 parsed_command_line->AppendSwitch(switches::kEnableOverlayFullscreenVideo);
60 parsed_command_line->AppendSwitch(switches::kEnableOverlayScrollbar);
61 parsed_command_line->AppendSwitch(switches::kValidateInputEventStream);
63 // There is no software fallback on Android, so don't limit GPU crashes.
64 parsed_command_line->AppendSwitch(switches::kDisableGpuProcessCrashLimit);
66 // On legacy low-memory devices the behavior has not been studied with regard
67 // to having an extra process with similar priority as the foreground renderer
68 // and given that the system will often be looking for a process to be killed
69 // on such systems.
70 if (base::SysInfo::IsLowEndDevice())
71 parsed_command_line->AppendSwitch(switches::kInProcessGPU);
73 parsed_command_line->AppendSwitch(switches::kDisableGpuShaderDiskCache);
75 parsed_command_line->AppendSwitch(switches::kEnableViewportMeta);
76 parsed_command_line->AppendSwitch(
77 switches::kMainFrameResizesAreOrientationChanges);
79 // Disable anti-aliasing.
80 parsed_command_line->AppendSwitch(
81 cc::switches::kDisableCompositedAntialiasing);
83 parsed_command_line->AppendSwitch(switches::kUIPrioritizeInGpuProcess);
85 parsed_command_line->AppendSwitch(switches::kEnableDelegatedRenderer);
87 if (!plugin_descriptor.empty()) {
88 parsed_command_line->AppendSwitchNative(
89 switches::kRegisterPepperPlugins, plugin_descriptor);
92 // Disable profiler timing by default.
93 if (!parsed_command_line->HasSwitch(switches::kProfilerTiming)) {
94 parsed_command_line->AppendSwitchASCII(
95 switches::kProfilerTiming, switches::kProfilerTimingDisabledValue);
99 } // namespace content