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/strings/string_tokenizer.h"
15 #include "base/win/windows_version.h"
16 #include "ui/gfx/win/direct_write.h"
24 static bool g_win32k_renderer_lockdown_disabled
= false;
29 bool IsPinchToZoomEnabled() {
30 const base::CommandLine
& command_line
=
31 *base::CommandLine::ForCurrentProcess();
33 // --disable-pinch should always disable pinch
34 if (command_line
.HasSwitch(switches::kDisablePinch
))
38 return base::win::GetVersion() >= base::win::VERSION_WIN8
;
39 #elif defined(OS_CHROMEOS)
42 return command_line
.HasSwitch(switches::kEnableViewport
) ||
43 command_line
.HasSwitch(switches::kEnablePinch
);
49 void DisableWin32kRendererLockdown() {
50 g_win32k_renderer_lockdown_disabled
= true;
53 bool IsWin32kRendererLockdownEnabled() {
54 if (g_win32k_renderer_lockdown_disabled
)
56 if (base::win::GetVersion() < base::win::VERSION_WIN8
)
58 if (!gfx::win::ShouldUseDirectWrite())
60 const base::CommandLine
* cmd_line
= base::CommandLine::ForCurrentProcess();
61 if (cmd_line
->HasSwitch(switches::kDisableWin32kRendererLockDown
))
66 bool IsWin32kLockdownEnabledForMimeType(const std::string
& mime_type
) {
67 // Consider PPAPI lockdown a superset of renderer lockdown.
68 if (!IsWin32kRendererLockdownEnabled())
70 const base::CommandLine
* cmd_line
= base::CommandLine::ForCurrentProcess();
72 std::string mime_types
=
73 cmd_line
->GetSwitchValueASCII(switches::kEnableWin32kLockDownMimeTypes
);
75 if (mime_types
.empty()) {
77 base::FieldTrialList::FindFullName("EnableWin32kLockDownMimeTypes");
80 // Consider the value * to enable all mime types for lockdown.
81 if (mime_types
== "*")
84 base::StringTokenizer
tokenizer(mime_types
, ",");
85 tokenizer
.set_quote_chars("\"");
86 while (tokenizer
.GetNext()) {
87 if (tokenizer
.token() == mime_type
)
95 V8CacheOptions
GetV8CacheOptions() {
96 const base::CommandLine
& command_line
=
97 *base::CommandLine::ForCurrentProcess();
98 std::string v8_cache_options
=
99 command_line
.GetSwitchValueASCII(switches::kV8CacheOptions
);
100 if (v8_cache_options
.empty())
101 v8_cache_options
= base::FieldTrialList::FindFullName("V8CacheOptions");
102 if (v8_cache_options
== "none") {
103 return V8_CACHE_OPTIONS_NONE
;
104 } else if (v8_cache_options
== "parse") {
105 return V8_CACHE_OPTIONS_PARSE
;
106 } else if (v8_cache_options
== "code") {
107 return V8_CACHE_OPTIONS_CODE
;
109 return V8_CACHE_OPTIONS_DEFAULT
;
113 } // namespace content