15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <jni.h>
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/android/chrome_startup_flags.h"
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/android/jni_android.h"
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/android/jni_string.h"
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/android/scoped_java_ref.h"
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/command_line.h"
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/logging.h"
14116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "base/sys_info.h"
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/common/chrome_switches.h"
16a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "chrome/common/chrome_version_info.h"
17c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "content/public/common/content_switches.h"
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "media/base/media_switches.h"
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace {
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void SetCommandLineSwitch(const std::string& switch_string) {
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  CommandLine* command_line = CommandLine::ForCurrentProcess();
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!command_line->HasSwitch(switch_string))
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    command_line->AppendSwitch(switch_string);
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void SetCommandLineSwitchASCII(const std::string& switch_string,
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                               const std::string& value) {
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  CommandLine* command_line = CommandLine::ForCurrentProcess();
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  if (!command_line->HasSwitch(switch_string))
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    command_line->AppendSwitchASCII(switch_string, value);
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)void SetChromeSpecificCommandLineFlags() {
38f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  // Enable prerender with holdback.
39a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  SetCommandLineSwitchASCII(switches::kPrerenderMode,
40f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)                            switches::kPrerenderModeSwitchValueAuto);
41f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)
42f8ee788a64d60abd8f2d742a5fdedde054ecd910Torne (Richard Coles)  // Enable prerender for the omnibox.
43a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  SetCommandLineSwitchASCII(switches::kPrerenderFromOmnibox,
44a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)                            switches::kPrerenderFromOmniboxSwitchValueEnabled);
45a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
46a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // Disable syncing favicons on low end devices.
47116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  if (base::SysInfo::IsLowEndDevice())
4823730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)    SetCommandLineSwitchASCII(switches::kDisableSyncTypes, "Favicon Images");
49a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
501320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // Enable DOM Distiller backend.
511320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  SetCommandLineSwitch(switches::kEnableDomDistiller);
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
53