| 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 "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
| 13 | 13 |
| 14 #if defined(OS_WIN) | 14 #if defined(OS_WIN) |
| 15 #include "base/strings/string_tokenizer.h" | |
| 16 #include "base/win/windows_version.h" | 15 #include "base/win/windows_version.h" |
| 17 #include "ui/gfx/win/direct_write.h" | 16 #include "ui/gfx/win/direct_write.h" |
| 18 #endif | 17 #endif |
| 19 | 18 |
| 20 namespace content { | 19 namespace content { |
| 21 | 20 |
| 22 namespace { | 21 namespace { |
| 23 | 22 |
| 24 #if defined(OS_WIN) | 23 #if defined(OS_WIN) |
| 25 static bool g_win32k_renderer_lockdown_disabled = false; | 24 static bool g_win32k_renderer_lockdown_disabled = false; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 if (base::win::GetVersion() < base::win::VERSION_WIN8) | 56 if (base::win::GetVersion() < base::win::VERSION_WIN8) |
| 58 return false; | 57 return false; |
| 59 if (!gfx::win::ShouldUseDirectWrite()) | 58 if (!gfx::win::ShouldUseDirectWrite()) |
| 60 return false; | 59 return false; |
| 61 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 60 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
| 62 if (cmd_line->HasSwitch(switches::kDisableWin32kRendererLockDown)) | 61 if (cmd_line->HasSwitch(switches::kDisableWin32kRendererLockDown)) |
| 63 return false; | 62 return false; |
| 64 return true; | 63 return true; |
| 65 } | 64 } |
| 66 | 65 |
| 67 bool IsWin32kLockdownEnabledForMimeType(const std::string& mime_type) { | |
| 68 // Consider PPAPI lockdown a superset of renderer lockdown. | |
| 69 if (!IsWin32kRendererLockdownEnabled()) | |
| 70 return false; | |
| 71 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | |
| 72 | |
| 73 std::string mime_types = | |
| 74 base::FieldTrialList::FindFullName("EnableWin32kLockDownMimeTypes"); | |
| 75 if (cmd_line->HasSwitch(switches::kEnableWin32kLockDownMimeTypes)) { | |
| 76 mime_types = | |
| 77 cmd_line->GetSwitchValueASCII(switches::kEnableWin32kLockDownMimeTypes); | |
| 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 } | |
| 93 #endif | 66 #endif |
| 94 | 67 |
| 95 V8CacheOptions GetV8CacheOptions() { | 68 V8CacheOptions GetV8CacheOptions() { |
| 96 const base::CommandLine& command_line = | 69 const base::CommandLine& command_line = |
| 97 *base::CommandLine::ForCurrentProcess(); | 70 *base::CommandLine::ForCurrentProcess(); |
| 98 std::string v8_cache_options = | 71 std::string v8_cache_options = |
| 99 command_line.GetSwitchValueASCII(switches::kV8CacheOptions); | 72 command_line.GetSwitchValueASCII(switches::kV8CacheOptions); |
| 100 if (v8_cache_options.empty()) | 73 if (v8_cache_options.empty()) |
| 101 v8_cache_options = base::FieldTrialList::FindFullName("V8CacheOptions"); | 74 v8_cache_options = base::FieldTrialList::FindFullName("V8CacheOptions"); |
| 102 if (v8_cache_options == "none") { | 75 if (v8_cache_options == "none") { |
| 103 return V8_CACHE_OPTIONS_NONE; | 76 return V8_CACHE_OPTIONS_NONE; |
| 104 } else if (v8_cache_options == "parse") { | 77 } else if (v8_cache_options == "parse") { |
| 105 return V8_CACHE_OPTIONS_PARSE; | 78 return V8_CACHE_OPTIONS_PARSE; |
| 106 } else if (v8_cache_options == "code") { | 79 } else if (v8_cache_options == "code") { |
| 107 return V8_CACHE_OPTIONS_CODE; | 80 return V8_CACHE_OPTIONS_CODE; |
| 108 } else { | 81 } else { |
| 109 return V8_CACHE_OPTIONS_DEFAULT; | 82 return V8_CACHE_OPTIONS_DEFAULT; |
| 110 } | 83 } |
| 111 } | 84 } |
| 112 | 85 |
| 113 bool IsUseZoomForDSFEnabled() { | 86 bool IsUseZoomForDSFEnabled() { |
| 114 static bool enabled = base::CommandLine::ForCurrentProcess()->HasSwitch( | 87 static bool enabled = base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 115 switches::kEnableUseZoomForDSF); | 88 switches::kEnableUseZoomForDSF); |
| 116 return enabled; | 89 return enabled; |
| 117 } | 90 } |
| 118 | 91 |
| 119 } // namespace content | 92 } // namespace content |
| OLD | NEW |