chrome_startup_flags.cc revision effb81e5f8246d0db0270817048dc992db66e9fb
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 <jni.h>
6
7#include "chrome/browser/android/chrome_startup_flags.h"
8
9#include "base/android/jni_android.h"
10#include "base/android/jni_string.h"
11#include "base/android/scoped_java_ref.h"
12#include "base/android/sys_utils.h"
13#include "base/command_line.h"
14#include "base/logging.h"
15#include "chrome/common/chrome_switches.h"
16#include "chrome/common/chrome_version_info.h"
17#include "content/public/common/content_switches.h"
18#include "media/base/media_switches.h"
19
20namespace {
21
22void SetCommandLineSwitch(const std::string& switch_string) {
23  CommandLine* command_line = CommandLine::ForCurrentProcess();
24  if (!command_line->HasSwitch(switch_string))
25    command_line->AppendSwitch(switch_string);
26}
27
28void SetCommandLineSwitchASCII(const std::string& switch_string,
29                               const std::string& value) {
30  CommandLine* command_line = CommandLine::ForCurrentProcess();
31  if (!command_line->HasSwitch(switch_string))
32    command_line->AppendSwitchASCII(switch_string, value);
33}
34
35}  // namespace
36
37void SetChromeSpecificCommandLineFlags() {
38  // Turn on autologin.
39  SetCommandLineSwitch(switches::kEnableAutologin);
40
41  // Enable prerender for the omnibox.
42  SetCommandLineSwitchASCII(switches::kPrerenderMode,
43                            switches::kPrerenderModeSwitchValueEnabled);
44  SetCommandLineSwitchASCII(switches::kPrerenderFromOmnibox,
45                            switches::kPrerenderFromOmniboxSwitchValueEnabled);
46
47  // Disable syncing favicons on low end devices.
48  if (base::android::SysUtils::IsLowEndDevice())
49    SetCommandLineSwitchASCII(switches::kDisableSyncTypes, "Favicon Images");
50
51  // Enable DOM Distiller on local builds, canary and dev-channel.
52  chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
53  if (channel == chrome::VersionInfo::CHANNEL_UNKNOWN ||
54      channel == chrome::VersionInfo::CHANNEL_CANARY ||
55      channel == chrome::VersionInfo::CHANNEL_DEV) {
56    SetCommandLineSwitch(switches::kEnableDomDistiller);
57  }
58
59  // Enable the Fast Text Autosizer on local builds, canary and dev-channel.
60  if (channel == chrome::VersionInfo::CHANNEL_UNKNOWN ||
61      channel == chrome::VersionInfo::CHANNEL_CANARY ||
62      channel == chrome::VersionInfo::CHANNEL_DEV) {
63    SetCommandLineSwitch(switches::kEnableFastTextAutosizing);
64  }
65}
66