Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / content / common / content_switches_internal.cc
blob07d064e98eee7876b8839608bf515eba152fcff8
1 // Copyright (c) 2014 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/common/content_switches_internal.h"
7 #include <string>
9 #include "base/command_line.h"
10 #include "base/metrics/field_trial.h"
11 #include "content/public/common/content_switches.h"
13 #if defined(OS_WIN)
14 #include "base/win/windows_version.h"
15 #include "ui/gfx/win/direct_write.h"
16 #endif
18 namespace content {
20 namespace {
22 #if defined(OS_WIN)
23 static bool g_win32k_renderer_lockdown_disabled = false;
24 #endif
26 } // namespace
28 bool IsPinchToZoomEnabled() {
29 const base::CommandLine& command_line =
30 *base::CommandLine::ForCurrentProcess();
32 // --disable-pinch should always disable pinch
33 if (command_line.HasSwitch(switches::kDisablePinch))
34 return false;
36 #if defined(OS_WIN)
37 return base::win::GetVersion() >= base::win::VERSION_WIN8;
38 #elif defined(OS_CHROMEOS)
39 return true;
40 #else
41 return command_line.HasSwitch(switches::kEnableViewport) ||
42 command_line.HasSwitch(switches::kEnablePinch);
43 #endif
46 #if defined(OS_WIN)
48 void DisableWin32kRendererLockdown() {
49 g_win32k_renderer_lockdown_disabled = true;
52 bool IsWin32kRendererLockdownEnabled() {
53 const std::string group_name =
54 base::FieldTrialList::FindFullName("Win32kLockdown");
55 if (g_win32k_renderer_lockdown_disabled)
56 return false;
57 if (base::win::GetVersion() < base::win::VERSION_WIN8)
58 return false;
59 if (!gfx::win::ShouldUseDirectWrite())
60 return false;
61 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
62 if (cmd_line->HasSwitch(switches::kEnableWin32kRendererLockDown))
63 return true;
64 if (cmd_line->HasSwitch(switches::kDisableWin32kRendererLockDown))
65 return false;
66 // Default.
67 return group_name != "Disabled";
69 #endif
71 V8CacheOptions GetV8CacheOptions() {
72 const base::CommandLine& command_line =
73 *base::CommandLine::ForCurrentProcess();
74 std::string v8_cache_options =
75 command_line.GetSwitchValueASCII(switches::kV8CacheOptions);
76 if (v8_cache_options.empty())
77 v8_cache_options = base::FieldTrialList::FindFullName("V8CacheOptions");
78 if (v8_cache_options == "parse") {
79 return V8_CACHE_OPTIONS_PARSE;
80 } else if (v8_cache_options == "code") {
81 return V8_CACHE_OPTIONS_CODE;
82 } else if (v8_cache_options == "code-compressed") {
83 return V8_CACHE_OPTIONS_CODE_COMPRESSED;
84 } else if (v8_cache_options == "none") {
85 return V8_CACHE_OPTIONS_NONE;
86 } else if (v8_cache_options == "parse-memory") {
87 return V8_CACHE_OPTIONS_PARSE_MEMORY;
88 } else if (v8_cache_options == "heuristics") {
89 return V8_CACHE_OPTIONS_HEURISTICS;
90 } else if (v8_cache_options == "heuristics-mobile") {
91 return V8_CACHE_OPTIONS_HEURISTICS_MOBILE;
92 } else if (v8_cache_options == "heuristics-default") {
93 return V8_CACHE_OPTIONS_HEURISTICS_DEFAULT;
94 } else if (v8_cache_options == "heuristics-default-mobile") {
95 return V8_CACHE_OPTIONS_HEURISTICS_DEFAULT_MOBILE;
96 } else if (v8_cache_options == "recent") {
97 return V8_CACHE_OPTIONS_RECENT;
98 } else if (v8_cache_options == "recent-small") {
99 return V8_CACHE_OPTIONS_RECENT_SMALL;
100 } else {
101 return V8_CACHE_OPTIONS_DEFAULT;
105 } // namespace content