| 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 ::EnumSystemLocalesEx(EnumLocalesProcEx, LOCALE_WINDOWS, 0, 0); |
| 96 typedef BOOL (WINAPI *PfnEnumSystemLocalesEx) | |
| 97 (LOCALE_ENUMPROCEX, DWORD, LPARAM, LPVOID); | |
| 98 | |
| 99 HMODULE handle_kern32 = GetModuleHandleW(L"Kernel32.dll"); | |
| 100 PfnEnumSystemLocalesEx enum_sys_locales_ex = | |
| 101 reinterpret_cast<PfnEnumSystemLocalesEx> | |
| 102 (GetProcAddress(handle_kern32, "EnumSystemLocalesEx")); | |
| 103 | |
| 104 enum_sys_locales_ex(EnumLocalesProcEx, LOCALE_WINDOWS, 0, 0); | |
| 105 } else { | |
| 106 EnumSystemLocalesW(EnumLocalesProc, LCID_INSTALLED); | |
| 107 } | |
| 108 } | |
| 109 } | 91 } |
| 110 | 92 |
| 111 #endif | 93 #endif |
| 112 | 94 |
| 113 static bool IsRunningInMash() { | 95 static bool IsRunningInMash() { |
| 114 const base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); | 96 const base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); |
| 115 return cmdline->HasSwitch(switches::kIsRunningInMash); | 97 return cmdline->HasSwitch(switches::kIsRunningInMash); |
| 116 } | 98 } |
| 117 | 99 |
| 118 namespace content { | 100 namespace content { |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 | 390 |
| 409 #if defined(OS_WIN) | 391 #if defined(OS_WIN) |
| 410 // If code subsequently tries to exit using abort(), force a crash (since | 392 // If code subsequently tries to exit using abort(), force a crash (since |
| 411 // otherwise these would be silent terminations and fly under the radar). | 393 // otherwise these would be silent terminations and fly under the radar). |
| 412 base::win::SetAbortBehaviorForCrashReporting(); | 394 base::win::SetAbortBehaviorForCrashReporting(); |
| 413 | 395 |
| 414 // Once we lower the token the sandbox is locked down and no new modules | 396 // 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 | 397 // can be loaded. TODO(cpu): consider changing to the loading style of |
| 416 // regular plugins. | 398 // regular plugins. |
| 417 if (g_target_services) { | 399 if (g_target_services) { |
| 418 // Let Flash and Widevine CDM adapter load DXVA before lockdown on Vista+. | 400 // Let Flash and Widevine CDM adapter load DXVA before lockdown. |
| 419 if (permissions.HasPermission(ppapi::PERMISSION_FLASH) || | 401 if (permissions.HasPermission(ppapi::PERMISSION_FLASH) || |
| 420 path.BaseName().MaybeAsASCII() == kWidevineCdmAdapterFileName) { | 402 path.BaseName().MaybeAsASCII() == kWidevineCdmAdapterFileName) { |
| 421 if (base::win::OSInfo::GetInstance()->version() >= | 403 LoadLibraryA("dxva2.dll"); |
| 422 base::win::VERSION_VISTA) { | |
| 423 LoadLibraryA("dxva2.dll"); | |
| 424 } | |
| 425 } | 404 } |
| 426 | 405 |
| 427 if (permissions.HasPermission(ppapi::PERMISSION_FLASH)) { | 406 if (permissions.HasPermission(ppapi::PERMISSION_FLASH)) { |
| 428 if (base::win::OSInfo::GetInstance()->version() >= | 407 base::CPU cpu; |
| 429 base::win::VERSION_WIN7) { | 408 if (cpu.vendor_name() == "AuthenticAMD") { |
| 430 base::CPU cpu; | 409 // 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) | 410 #if defined(_WIN64) |
| 434 LoadLibraryA("amdhcp64.dll"); | 411 LoadLibraryA("amdhcp64.dll"); |
| 435 #else | 412 #else |
| 436 LoadLibraryA("amdhcp32.dll"); | 413 LoadLibraryA("amdhcp32.dll"); |
| 437 #endif | 414 #endif |
| 438 } | 415 } |
| 439 } | |
| 440 } | 416 } |
| 441 | 417 |
| 442 // Cause advapi32 to load before the sandbox is turned on. | 418 // Cause advapi32 to load before the sandbox is turned on. |
| 443 unsigned int dummy_rand; | 419 unsigned int dummy_rand; |
| 444 rand_s(&dummy_rand); | 420 rand_s(&dummy_rand); |
| 445 | 421 |
| 446 WarmupWindowsLocales(permissions); | 422 WarmupWindowsLocales(permissions); |
| 447 | 423 |
| 448 if (!base::win::IsUser32AndGdi32Available() && | 424 if (!base::win::IsUser32AndGdi32Available() && |
| 449 permissions.HasPermission(ppapi::PERMISSION_FLASH)) { | 425 permissions.HasPermission(ppapi::PERMISSION_FLASH)) { |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 GetHistogramName(is_broker_, "LoadTime", path), | 627 GetHistogramName(is_broker_, "LoadTime", path), |
| 652 base::TimeDelta::FromMilliseconds(1), | 628 base::TimeDelta::FromMilliseconds(1), |
| 653 base::TimeDelta::FromSeconds(10), | 629 base::TimeDelta::FromSeconds(10), |
| 654 50, | 630 50, |
| 655 base::HistogramBase::kUmaTargetedHistogramFlag); | 631 base::HistogramBase::kUmaTargetedHistogramFlag); |
| 656 | 632 |
| 657 histogram->AddTime(load_time); | 633 histogram->AddTime(load_time); |
| 658 } | 634 } |
| 659 | 635 |
| 660 } // namespace content | 636 } // namespace content |
| OLD | NEW |