OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ppapi_plugin/ppapi_thread.h" | 5 #include "content/ppapi_plugin/ppapi_thread.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <limits> | 9 #include <limits> |
10 | 10 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 #include "ppapi/proxy/plugin_message_filter.h" | 51 #include "ppapi/proxy/plugin_message_filter.h" |
52 #include "ppapi/proxy/ppapi_messages.h" | 52 #include "ppapi/proxy/ppapi_messages.h" |
53 #include "ppapi/proxy/resource_reply_thread_registrar.h" | 53 #include "ppapi/proxy/resource_reply_thread_registrar.h" |
54 #include "services/service_manager/public/cpp/connector.h" | 54 #include "services/service_manager/public/cpp/connector.h" |
55 #include "services/ui/public/interfaces/constants.mojom.h" | 55 #include "services/ui/public/interfaces/constants.mojom.h" |
56 #include "third_party/WebKit/public/web/WebKit.h" | 56 #include "third_party/WebKit/public/web/WebKit.h" |
57 #include "ui/base/ui_base_switches.h" | 57 #include "ui/base/ui_base_switches.h" |
58 | 58 |
59 #if defined(OS_WIN) | 59 #if defined(OS_WIN) |
60 #include "base/win/win_util.h" | 60 #include "base/win/win_util.h" |
61 #include "base/win/windows_version.h" | |
62 #include "content/child/font_warmup_win.h" | 61 #include "content/child/font_warmup_win.h" |
63 #include "sandbox/win/src/sandbox.h" | 62 #include "sandbox/win/src/sandbox.h" |
64 #elif defined(OS_MACOSX) | 63 #elif defined(OS_MACOSX) |
65 #include "content/common/sandbox_init_mac.h" | 64 #include "content/common/sandbox_init_mac.h" |
66 #endif | 65 #endif |
67 | 66 |
68 #if BUILDFLAG(ENABLE_CDM_HOST_VERIFICATION) | 67 #if BUILDFLAG(ENABLE_CDM_HOST_VERIFICATION) |
69 #include "content/common/media/cdm_host_files.h" | 68 #include "content/common/media/cdm_host_files.h" |
70 #endif | 69 #endif |
71 | 70 |
72 #if defined(OS_WIN) | 71 #if defined(OS_WIN) |
73 const char kWidevineCdmAdapterFileName[] = "widevinecdmadapter.dll"; | 72 const char kWidevineCdmAdapterFileName[] = "widevinecdmadapter.dll"; |
74 | 73 |
75 extern sandbox::TargetServices* g_target_services; | 74 extern sandbox::TargetServices* g_target_services; |
76 | 75 |
77 // Used by EnumSystemLocales for warming up. | 76 // Used by EnumSystemLocales for warming up. |
78 static BOOL CALLBACK EnumLocalesProc(LPTSTR lpLocaleString) { | |
79 return TRUE; | |
80 } | |
81 | |
82 static BOOL CALLBACK EnumLocalesProcEx( | 77 static BOOL CALLBACK EnumLocalesProcEx( |
83 LPWSTR lpLocaleString, | 78 LPWSTR lpLocaleString, |
84 DWORD dwFlags, | 79 DWORD dwFlags, |
85 LPARAM lParam) { | 80 LPARAM lParam) { |
86 return TRUE; | 81 return TRUE; |
87 } | 82 } |
88 | 83 |
89 // Warm up language subsystems before the sandbox is turned on. | 84 // Warm up language subsystems before the sandbox is turned on. |
90 static void WarmupWindowsLocales(const ppapi::PpapiPermissions& permissions) { | 85 static void WarmupWindowsLocales(const ppapi::PpapiPermissions& permissions) { |
91 ::GetUserDefaultLangID(); | 86 ::GetUserDefaultLangID(); |
92 ::GetUserDefaultLCID(); | 87 ::GetUserDefaultLCID(); |
93 | 88 |
94 if (permissions.HasPermission(ppapi::PERMISSION_FLASH)) { | 89 if (permissions.HasPermission(ppapi::PERMISSION_FLASH)) { |
95 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { | 90 typedef BOOL (WINAPI *PfnEnumSystemLocalesEx) |
jam
2017/06/01 23:55:19
just call EnumSystemLocalesEx directly?
Patrick Monette
2017/06/02 00:34:04
Done
| |
96 typedef BOOL (WINAPI *PfnEnumSystemLocalesEx) | 91 (LOCALE_ENUMPROCEX, DWORD, LPARAM, LPVOID); |
97 (LOCALE_ENUMPROCEX, DWORD, LPARAM, LPVOID); | |
98 | 92 |
99 HMODULE handle_kern32 = GetModuleHandleW(L"Kernel32.dll"); | 93 HMODULE handle_kern32 = GetModuleHandleW(L"Kernel32.dll"); |
100 PfnEnumSystemLocalesEx enum_sys_locales_ex = | 94 PfnEnumSystemLocalesEx enum_sys_locales_ex = |
101 reinterpret_cast<PfnEnumSystemLocalesEx> | 95 reinterpret_cast<PfnEnumSystemLocalesEx> |
102 (GetProcAddress(handle_kern32, "EnumSystemLocalesEx")); | 96 (GetProcAddress(handle_kern32, "EnumSystemLocalesEx")); |
103 | 97 |
104 enum_sys_locales_ex(EnumLocalesProcEx, LOCALE_WINDOWS, 0, 0); | 98 enum_sys_locales_ex(EnumLocalesProcEx, LOCALE_WINDOWS, 0, 0); |
105 } else { | |
106 EnumSystemLocalesW(EnumLocalesProc, LCID_INSTALLED); | |
107 } | |
108 } | 99 } |
109 } | 100 } |
110 | 101 |
111 #endif | 102 #endif |
112 | 103 |
113 static bool IsRunningInMash() { | 104 static bool IsRunningInMash() { |
114 const base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); | 105 const base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); |
115 return cmdline->HasSwitch(switches::kIsRunningInMash); | 106 return cmdline->HasSwitch(switches::kIsRunningInMash); |
116 } | 107 } |
117 | 108 |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
408 | 399 |
409 #if defined(OS_WIN) | 400 #if defined(OS_WIN) |
410 // If code subsequently tries to exit using abort(), force a crash (since | 401 // If code subsequently tries to exit using abort(), force a crash (since |
411 // otherwise these would be silent terminations and fly under the radar). | 402 // otherwise these would be silent terminations and fly under the radar). |
412 base::win::SetAbortBehaviorForCrashReporting(); | 403 base::win::SetAbortBehaviorForCrashReporting(); |
413 | 404 |
414 // Once we lower the token the sandbox is locked down and no new modules | 405 // Once we lower the token the sandbox is locked down and no new modules |
415 // can be loaded. TODO(cpu): consider changing to the loading style of | 406 // can be loaded. TODO(cpu): consider changing to the loading style of |
416 // regular plugins. | 407 // regular plugins. |
417 if (g_target_services) { | 408 if (g_target_services) { |
418 // Let Flash and Widevine CDM adapter load DXVA before lockdown on Vista+. | 409 // Let Flash and Widevine CDM adapter load DXVA before lockdown. |
419 if (permissions.HasPermission(ppapi::PERMISSION_FLASH) || | 410 if (permissions.HasPermission(ppapi::PERMISSION_FLASH) || |
420 path.BaseName().MaybeAsASCII() == kWidevineCdmAdapterFileName) { | 411 path.BaseName().MaybeAsASCII() == kWidevineCdmAdapterFileName) { |
421 if (base::win::OSInfo::GetInstance()->version() >= | 412 LoadLibraryA("dxva2.dll"); |
422 base::win::VERSION_VISTA) { | |
423 LoadLibraryA("dxva2.dll"); | |
424 } | |
425 } | 413 } |
426 | 414 |
427 if (permissions.HasPermission(ppapi::PERMISSION_FLASH)) { | 415 if (permissions.HasPermission(ppapi::PERMISSION_FLASH)) { |
428 if (base::win::OSInfo::GetInstance()->version() >= | 416 base::CPU cpu; |
429 base::win::VERSION_WIN7) { | 417 if (cpu.vendor_name() == "AuthenticAMD") { |
430 base::CPU cpu; | 418 // The AMD crypto acceleration is only AMD Bulldozer and above. |
431 if (cpu.vendor_name() == "AuthenticAMD") { | |
432 // The AMD crypto acceleration is only AMD Bulldozer and above. | |
433 #if defined(_WIN64) | 419 #if defined(_WIN64) |
434 LoadLibraryA("amdhcp64.dll"); | 420 LoadLibraryA("amdhcp64.dll"); |
435 #else | 421 #else |
436 LoadLibraryA("amdhcp32.dll"); | 422 LoadLibraryA("amdhcp32.dll"); |
437 #endif | 423 #endif |
438 } | 424 } |
439 } | |
440 } | 425 } |
441 | 426 |
442 // Cause advapi32 to load before the sandbox is turned on. | 427 // Cause advapi32 to load before the sandbox is turned on. |
443 unsigned int dummy_rand; | 428 unsigned int dummy_rand; |
444 rand_s(&dummy_rand); | 429 rand_s(&dummy_rand); |
445 | 430 |
446 WarmupWindowsLocales(permissions); | 431 WarmupWindowsLocales(permissions); |
447 | 432 |
448 if (!base::win::IsUser32AndGdi32Available() && | 433 if (!base::win::IsUser32AndGdi32Available() && |
449 permissions.HasPermission(ppapi::PERMISSION_FLASH)) { | 434 permissions.HasPermission(ppapi::PERMISSION_FLASH)) { |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
651 GetHistogramName(is_broker_, "LoadTime", path), | 636 GetHistogramName(is_broker_, "LoadTime", path), |
652 base::TimeDelta::FromMilliseconds(1), | 637 base::TimeDelta::FromMilliseconds(1), |
653 base::TimeDelta::FromSeconds(10), | 638 base::TimeDelta::FromSeconds(10), |
654 50, | 639 50, |
655 base::HistogramBase::kUmaTargetedHistogramFlag); | 640 base::HistogramBase::kUmaTargetedHistogramFlag); |
656 | 641 |
657 histogram->AddTime(load_time); | 642 histogram->AddTime(load_time); |
658 } | 643 } |
659 | 644 |
660 } // namespace content | 645 } // namespace content |
OLD | NEW |