Home | History | Annotate | Download | only in android
      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/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"
     16 
     17 namespace content {
     18 
     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)
     24     return;
     25   already_initialized = true;
     26 
     27   CommandLine* parsed_command_line = CommandLine::ForCurrentProcess();
     28 
     29   if (parsed_command_line->HasSwitch(switches::kRendererProcessLimit)) {
     30     std::string limit = parsed_command_line->GetSwitchValueASCII(
     31         switches::kRendererProcessLimit);
     32     int value;
     33     if (base::StringToInt(limit, &value))
     34       max_render_process_count = value;
     35   }
     36 
     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);
     42   } else {
     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);
     48   }
     49 
     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 
     62   parsed_command_line->AppendSwitch(switches::kEnableGestureTapHighlight);
     63   parsed_command_line->AppendSwitch(switches::kEnablePinch);
     64   parsed_command_line->AppendSwitch(switches::kEnableOverscrollNotifications);
     65 
     66   // Run the GPU service as a thread in the browser instead of as a
     67   // standalone process.
     68   parsed_command_line->AppendSwitch(switches::kInProcessGPU);
     69   parsed_command_line->AppendSwitch(switches::kDisableGpuShaderDiskCache);
     70 
     71   // Always use fixed layout and viewport tag.
     72   parsed_command_line->AppendSwitch(switches::kEnableFixedLayout);
     73   parsed_command_line->AppendSwitch(switches::kEnableViewport);
     74 
     75   // Disable anti-aliasing.
     76   parsed_command_line->AppendSwitch(
     77       cc::switches::kDisableCompositedAntialiasing);
     78 
     79   if (!plugin_descriptor.empty()) {
     80     parsed_command_line->AppendSwitchNative(
     81       switches::kRegisterPepperPlugins, plugin_descriptor);
     82   }
     83 }
     84 
     85 }  // namespace content
     86