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"
9 #include "base/command_line.h"
10 #include "base/metrics/field_trial.h"
11 #include "content/public/common/content_switches.h"
14 #include "base/win/windows_version.h"
15 #include "ui/gfx/win/direct_write.h"
23 static bool g_win32k_renderer_lockdown_disabled
= false;
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
))
37 return base::win::GetVersion() >= base::win::VERSION_WIN8
;
38 #elif defined(OS_CHROMEOS)
41 return command_line
.HasSwitch(switches::kEnableViewport
) ||
42 command_line
.HasSwitch(switches::kEnablePinch
);
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
)
57 if (base::win::GetVersion() < base::win::VERSION_WIN8
)
59 if (!gfx::win::ShouldUseDirectWrite())
61 const base::CommandLine
* cmd_line
= base::CommandLine::ForCurrentProcess();
62 if (cmd_line
->HasSwitch(switches::kEnableWin32kRendererLockDown
))
64 if (cmd_line
->HasSwitch(switches::kDisableWin32kRendererLockDown
))
67 return group_name
!= "Disabled";
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
;
101 return V8_CACHE_OPTIONS_DEFAULT
;
105 } // namespace content