BlinkGCPlugin: Factor out CheckFieldsVisitor from BlinkGCPlugin.cpp.
[chromium-blink-merge.git] / content / common / content_switches_internal.cc
blob76871e4d4f856fd439f3a5bfaeeb2bb76dbe259c
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 if (g_win32k_renderer_lockdown_disabled)
54 return false;
55 if (base::win::GetVersion() < base::win::VERSION_WIN8)
56 return false;
57 if (!gfx::win::ShouldUseDirectWrite())
58 return false;
59 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
60 if (cmd_line->HasSwitch(switches::kDisableWin32kRendererLockDown))
61 return false;
62 return true;
64 #endif
66 V8CacheOptions GetV8CacheOptions() {
67 const base::CommandLine& command_line =
68 *base::CommandLine::ForCurrentProcess();
69 std::string v8_cache_options =
70 command_line.GetSwitchValueASCII(switches::kV8CacheOptions);
71 if (v8_cache_options.empty())
72 v8_cache_options = base::FieldTrialList::FindFullName("V8CacheOptions");
73 if (v8_cache_options == "none") {
74 return V8_CACHE_OPTIONS_NONE;
75 } else if (v8_cache_options == "parse") {
76 return V8_CACHE_OPTIONS_PARSE;
77 } else if (v8_cache_options == "code") {
78 return V8_CACHE_OPTIONS_CODE;
79 } else {
80 return V8_CACHE_OPTIONS_DEFAULT;
84 } // namespace content