OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/common/content_switches_internal.h" | 5 #include "content/common/content_switches_internal.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
11 #include "content/public/common/content_switches.h" | 11 #include "content/public/common/content_switches.h" |
12 | 12 |
13 #if defined(OS_WIN) | 13 #if defined(OS_WIN) |
| 14 #include "base/strings/string_tokenizer.h" |
14 #include "base/win/windows_version.h" | 15 #include "base/win/windows_version.h" |
15 #include "ui/gfx/win/direct_write.h" | 16 #include "ui/gfx/win/direct_write.h" |
16 #endif | 17 #endif |
17 | 18 |
18 namespace content { | 19 namespace content { |
19 | 20 |
20 namespace { | 21 namespace { |
21 | 22 |
22 #if defined(OS_WIN) | 23 #if defined(OS_WIN) |
23 static bool g_win32k_renderer_lockdown_disabled = false; | 24 static bool g_win32k_renderer_lockdown_disabled = false; |
(...skipping 30 matching lines...) Expand all Loading... |
54 return false; | 55 return false; |
55 if (base::win::GetVersion() < base::win::VERSION_WIN8) | 56 if (base::win::GetVersion() < base::win::VERSION_WIN8) |
56 return false; | 57 return false; |
57 if (!gfx::win::ShouldUseDirectWrite()) | 58 if (!gfx::win::ShouldUseDirectWrite()) |
58 return false; | 59 return false; |
59 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 60 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
60 if (cmd_line->HasSwitch(switches::kDisableWin32kRendererLockDown)) | 61 if (cmd_line->HasSwitch(switches::kDisableWin32kRendererLockDown)) |
61 return false; | 62 return false; |
62 return true; | 63 return true; |
63 } | 64 } |
| 65 |
| 66 bool IsWin32kLockdownEnabledForMimeType(const std::string& mime_type) { |
| 67 // Consider PPAPI lockdown a superset of renderer lockdown. |
| 68 if (!IsWin32kRendererLockdownEnabled()) |
| 69 return false; |
| 70 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
| 71 |
| 72 std::string mime_types = |
| 73 cmd_line->GetSwitchValueASCII(switches::kEnableWin32kLockDownMimeTypes); |
| 74 |
| 75 if (mime_types.empty()) { |
| 76 mime_types = |
| 77 base::FieldTrialList::FindFullName("EnableWin32kLockDownMimeTypes"); |
| 78 } |
| 79 |
| 80 // Consider the value * to enable all mime types for lockdown. |
| 81 if (mime_types == "*") |
| 82 return true; |
| 83 |
| 84 base::StringTokenizer tokenizer(mime_types, ","); |
| 85 tokenizer.set_quote_chars("\""); |
| 86 while (tokenizer.GetNext()) { |
| 87 if (tokenizer.token() == mime_type) |
| 88 return true; |
| 89 } |
| 90 |
| 91 return false; |
| 92 } |
64 #endif | 93 #endif |
65 | 94 |
66 V8CacheOptions GetV8CacheOptions() { | 95 V8CacheOptions GetV8CacheOptions() { |
67 const base::CommandLine& command_line = | 96 const base::CommandLine& command_line = |
68 *base::CommandLine::ForCurrentProcess(); | 97 *base::CommandLine::ForCurrentProcess(); |
69 std::string v8_cache_options = | 98 std::string v8_cache_options = |
70 command_line.GetSwitchValueASCII(switches::kV8CacheOptions); | 99 command_line.GetSwitchValueASCII(switches::kV8CacheOptions); |
71 if (v8_cache_options.empty()) | 100 if (v8_cache_options.empty()) |
72 v8_cache_options = base::FieldTrialList::FindFullName("V8CacheOptions"); | 101 v8_cache_options = base::FieldTrialList::FindFullName("V8CacheOptions"); |
73 if (v8_cache_options == "none") { | 102 if (v8_cache_options == "none") { |
74 return V8_CACHE_OPTIONS_NONE; | 103 return V8_CACHE_OPTIONS_NONE; |
75 } else if (v8_cache_options == "parse") { | 104 } else if (v8_cache_options == "parse") { |
76 return V8_CACHE_OPTIONS_PARSE; | 105 return V8_CACHE_OPTIONS_PARSE; |
77 } else if (v8_cache_options == "code") { | 106 } else if (v8_cache_options == "code") { |
78 return V8_CACHE_OPTIONS_CODE; | 107 return V8_CACHE_OPTIONS_CODE; |
79 } else { | 108 } else { |
80 return V8_CACHE_OPTIONS_DEFAULT; | 109 return V8_CACHE_OPTIONS_DEFAULT; |
81 } | 110 } |
82 } | 111 } |
83 | 112 |
84 } // namespace content | 113 } // namespace content |
OLD | NEW |