Chromium Code Reviews| 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 <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/cpu.h" | 10 #include "base/cpu.h" |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 #include "ipc/ipc_sync_channel.h" | 35 #include "ipc/ipc_sync_channel.h" |
| 36 #include "ipc/ipc_sync_message_filter.h" | 36 #include "ipc/ipc_sync_message_filter.h" |
| 37 #include "ppapi/c/dev/ppp_network_state_dev.h" | 37 #include "ppapi/c/dev/ppp_network_state_dev.h" |
| 38 #include "ppapi/c/pp_errors.h" | 38 #include "ppapi/c/pp_errors.h" |
| 39 #include "ppapi/c/ppp.h" | 39 #include "ppapi/c/ppp.h" |
| 40 #include "ppapi/proxy/interface_list.h" | 40 #include "ppapi/proxy/interface_list.h" |
| 41 #include "ppapi/proxy/plugin_globals.h" | 41 #include "ppapi/proxy/plugin_globals.h" |
| 42 #include "ppapi/proxy/plugin_message_filter.h" | 42 #include "ppapi/proxy/plugin_message_filter.h" |
| 43 #include "ppapi/proxy/ppapi_messages.h" | 43 #include "ppapi/proxy/ppapi_messages.h" |
| 44 #include "ppapi/proxy/resource_reply_thread_registrar.h" | 44 #include "ppapi/proxy/resource_reply_thread_registrar.h" |
| 45 #include "ppapi/shared_impl/proxy_lock.h" | |
| 45 #include "third_party/WebKit/public/web/WebKit.h" | 46 #include "third_party/WebKit/public/web/WebKit.h" |
| 46 #include "ui/base/ui_base_switches.h" | 47 #include "ui/base/ui_base_switches.h" |
| 47 | 48 |
| 48 #if defined(OS_WIN) | 49 #if defined(OS_WIN) |
| 50 #include "base/win/iat_patch_function.h" | |
| 49 #include "base/win/win_util.h" | 51 #include "base/win/win_util.h" |
| 50 #include "base/win/windows_version.h" | 52 #include "base/win/windows_version.h" |
| 51 #include "sandbox/win/src/sandbox.h" | 53 #include "sandbox/win/src/sandbox.h" |
| 52 #elif defined(OS_MACOSX) | 54 #elif defined(OS_MACOSX) |
| 53 #include "content/common/sandbox_init_mac.h" | 55 #include "content/common/sandbox_init_mac.h" |
| 54 #endif | 56 #endif |
| 55 | 57 |
| 56 #if defined(OS_WIN) | 58 #if defined(OS_WIN) |
| 57 const char kWidevineCdmAdapterFileName[] = "widevinecdmadapter.dll"; | 59 const char kWidevineCdmAdapterFileName[] = "widevinecdmadapter.dll"; |
| 58 | 60 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 84 PfnEnumSystemLocalesEx enum_sys_locales_ex = | 86 PfnEnumSystemLocalesEx enum_sys_locales_ex = |
| 85 reinterpret_cast<PfnEnumSystemLocalesEx> | 87 reinterpret_cast<PfnEnumSystemLocalesEx> |
| 86 (GetProcAddress(handle_kern32, "EnumSystemLocalesEx")); | 88 (GetProcAddress(handle_kern32, "EnumSystemLocalesEx")); |
| 87 | 89 |
| 88 enum_sys_locales_ex(EnumLocalesProcEx, LOCALE_WINDOWS, 0, 0); | 90 enum_sys_locales_ex(EnumLocalesProcEx, LOCALE_WINDOWS, 0, 0); |
| 89 } else { | 91 } else { |
| 90 EnumSystemLocalesW(EnumLocalesProc, LCID_INSTALLED); | 92 EnumSystemLocalesW(EnumLocalesProc, LCID_INSTALLED); |
| 91 } | 93 } |
| 92 } | 94 } |
| 93 } | 95 } |
| 96 | |
| 97 // TODO(scottmg): http://crbug.com/448473. This code should be removed from the | |
| 98 // renderer once PDF is always OOP and/or PDF is made to use Skia instead of GDI | |
|
ananta
2015/01/15 02:31:22
Move the once PDF is always OOP comment portion to
scottmg
2015/01/15 02:35:38
Done.
| |
| 99 // directly. | |
| 100 const wchar_t kPdfFileName[] = L"pdf.dll"; | |
| 101 | |
| 102 static base::win::IATPatchFunction g_iat_patch_createdca; | |
| 103 HDC WINAPI CreateDCAPatch(LPCSTR driver_name, | |
| 104 LPCSTR device_name, | |
| 105 LPCSTR output, | |
| 106 const void* init_data) { | |
| 107 DCHECK(std::string("DISPLAY") == std::string(driver_name)); | |
| 108 DCHECK(!device_name); | |
| 109 DCHECK(!output); | |
| 110 DCHECK(!init_data); | |
| 111 | |
| 112 // CreateDC fails behind the sandbox, but not CreateCompatibleDC. | |
| 113 return CreateCompatibleDC(NULL); | |
| 114 } | |
| 115 | |
| 116 static base::win::IATPatchFunction g_iat_patch_get_font_data; | |
| 117 DWORD WINAPI GetFontDataPatch(HDC hdc, | |
| 118 DWORD table, | |
| 119 DWORD offset, | |
| 120 LPVOID buffer, | |
| 121 DWORD length) { | |
| 122 int rv = GetFontData(hdc, table, offset, buffer, length); | |
| 123 if (rv == GDI_ERROR && hdc) { | |
| 124 HFONT font = static_cast<HFONT>(GetCurrentObject(hdc, OBJ_FONT)); | |
| 125 | |
| 126 LOGFONT logfont; | |
| 127 if (GetObject(font, sizeof(LOGFONT), &logfont)) { | |
| 128 std::vector<char> font_data; | |
| 129 { | |
| 130 ppapi::ProxyAutoLock lock; | |
| 131 ppapi::proxy::PluginGlobals::Get()->PreCacheFontForFlash( | |
| 132 reinterpret_cast<const void*>(&logfont)); | |
| 133 } | |
| 134 rv = GetFontData(hdc, table, offset, buffer, length); | |
| 135 } | |
| 136 } | |
| 137 return rv; | |
| 138 } | |
| 139 | |
| 94 #else | 140 #else |
| 95 extern void* g_target_services; | 141 extern void* g_target_services; |
| 96 #endif | 142 #endif |
| 97 | 143 |
| 98 namespace content { | 144 namespace content { |
| 99 | 145 |
| 100 typedef int32_t (*InitializeBrokerFunc) | 146 typedef int32_t (*InitializeBrokerFunc) |
| 101 (PP_ConnectInstance_Func* connect_instance_func); | 147 (PP_ConnectInstance_Func* connect_instance_func); |
| 102 | 148 |
| 103 PpapiThread::PpapiThread(const base::CommandLine& command_line, bool is_broker) | 149 PpapiThread::PpapiThread(const base::CommandLine& command_line, bool is_broker) |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 318 return; | 364 return; |
| 319 } | 365 } |
| 320 } | 366 } |
| 321 } | 367 } |
| 322 | 368 |
| 323 #if defined(OS_WIN) | 369 #if defined(OS_WIN) |
| 324 // If code subsequently tries to exit using abort(), force a crash (since | 370 // If code subsequently tries to exit using abort(), force a crash (since |
| 325 // otherwise these would be silent terminations and fly under the radar). | 371 // otherwise these would be silent terminations and fly under the radar). |
| 326 base::win::SetAbortBehaviorForCrashReporting(); | 372 base::win::SetAbortBehaviorForCrashReporting(); |
| 327 | 373 |
| 374 // Need to patch a few functions for font loading to work correctly. This can | |
| 375 // be removed once we switch PDF to use Skia. | |
|
ananta
2015/01/15 02:31:22
Some commentary which explains this voodoo to get
scottmg
2015/01/15 02:35:38
Done, above at the PreCache... call.
| |
| 376 if (GetModuleHandle(kPdfFileName)) { | |
| 377 g_iat_patch_createdca.Patch(kPdfFileName, "gdi32.dll", "CreateDCA", | |
| 378 CreateDCAPatch); | |
| 379 g_iat_patch_get_font_data.Patch(kPdfFileName, "gdi32.dll", "GetFontData", | |
| 380 GetFontDataPatch); | |
| 381 } | |
| 382 | |
| 328 // Once we lower the token the sandbox is locked down and no new modules | 383 // Once we lower the token the sandbox is locked down and no new modules |
| 329 // can be loaded. TODO(cpu): consider changing to the loading style of | 384 // can be loaded. TODO(cpu): consider changing to the loading style of |
| 330 // regular plugins. | 385 // regular plugins. |
| 331 if (g_target_services) { | 386 if (g_target_services) { |
| 332 // Let Flash and Widevine CDM adapter load DXVA before lockdown on Vista+. | 387 // Let Flash and Widevine CDM adapter load DXVA before lockdown on Vista+. |
| 333 if (permissions.HasPermission(ppapi::PERMISSION_FLASH) || | 388 if (permissions.HasPermission(ppapi::PERMISSION_FLASH) || |
| 334 path.BaseName().MaybeAsASCII() == kWidevineCdmAdapterFileName) { | 389 path.BaseName().MaybeAsASCII() == kWidevineCdmAdapterFileName) { |
| 335 if (base::win::OSInfo::GetInstance()->version() >= | 390 if (base::win::OSInfo::GetInstance()->version() >= |
| 336 base::win::VERSION_VISTA) { | 391 base::win::VERSION_VISTA) { |
| 337 LoadLibraryA("dxva2.dll"); | 392 LoadLibraryA("dxva2.dll"); |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 542 std::string("Plugin.Ppapi") + (is_broker_ ? "Broker" : "Plugin") + | 597 std::string("Plugin.Ppapi") + (is_broker_ ? "Broker" : "Plugin") + |
| 543 "LoadErrorCode_" + path.BaseName().MaybeAsASCII(); | 598 "LoadErrorCode_" + path.BaseName().MaybeAsASCII(); |
| 544 | 599 |
| 545 // For sparse histograms, we can use the macro, as it does not incorporate a | 600 // For sparse histograms, we can use the macro, as it does not incorporate a |
| 546 // static. | 601 // static. |
| 547 UMA_HISTOGRAM_SPARSE_SLOWLY(histogram_name, error.code); | 602 UMA_HISTOGRAM_SPARSE_SLOWLY(histogram_name, error.code); |
| 548 #endif | 603 #endif |
| 549 } | 604 } |
| 550 | 605 |
| 551 } // namespace content | 606 } // namespace content |
| OLD | NEW |