| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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" | 61 #include "base/win/windows_version.h" |
| 62 #include "content/child/font_warmup_win.h" | 62 #include "content/child/font_warmup_win.h" |
| 63 #include "sandbox/win/src/sandbox.h" | 63 #include "sandbox/win/src/sandbox.h" |
| 64 #elif defined(OS_MACOSX) | 64 #elif defined(OS_MACOSX) |
| 65 #include "content/common/sandbox_init_mac.h" | 65 #include "content/common/sandbox_init_mac.h" |
| 66 #endif | 66 #endif |
| 67 | 67 |
| 68 #if BUILDFLAG(ENABLE_PEPPER_CDMS) |
| 69 #include "content/common/media/cdm_host_files.h" |
| 70 #endif |
| 71 |
| 68 #if defined(OS_WIN) | 72 #if defined(OS_WIN) |
| 69 const char kWidevineCdmAdapterFileName[] = "widevinecdmadapter.dll"; | 73 const char kWidevineCdmAdapterFileName[] = "widevinecdmadapter.dll"; |
| 70 | 74 |
| 71 extern sandbox::TargetServices* g_target_services; | 75 extern sandbox::TargetServices* g_target_services; |
| 72 | 76 |
| 73 // Used by EnumSystemLocales for warming up. | 77 // Used by EnumSystemLocales for warming up. |
| 74 static BOOL CALLBACK EnumLocalesProc(LPTSTR lpLocaleString) { | 78 static BOOL CALLBACK EnumLocalesProc(LPTSTR lpLocaleString) { |
| 75 return TRUE; | 79 return TRUE; |
| 76 } | 80 } |
| 77 | 81 |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 reinterpret_cast<PP_InitializeModule_Func>( | 369 reinterpret_cast<PP_InitializeModule_Func>( |
| 366 library.GetFunctionPointer("PPP_InitializeModule")); | 370 library.GetFunctionPointer("PPP_InitializeModule")); |
| 367 if (!plugin_entry_points_.initialize_module) { | 371 if (!plugin_entry_points_.initialize_module) { |
| 368 LOG(WARNING) << "No PPP_InitializeModule in plugin library"; | 372 LOG(WARNING) << "No PPP_InitializeModule in plugin library"; |
| 369 ReportLoadResult(path, ENTRY_POINT_MISSING); | 373 ReportLoadResult(path, ENTRY_POINT_MISSING); |
| 370 return; | 374 return; |
| 371 } | 375 } |
| 372 } | 376 } |
| 373 } | 377 } |
| 374 | 378 |
| 379 #if BUILDFLAG(ENABLE_PEPPER_CDMS) |
| 380 // Use a local instance of CdmHostFiles so that if we return early for any |
| 381 // error, all files will closed automatically. |
| 382 std::unique_ptr<CdmHostFiles> cdm_host_files; |
| 383 |
| 384 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 385 // Open CDM host files before the process is sandboxed. |
| 386 if (!is_broker_ && IsCdm(path)) |
| 387 cdm_host_files = CdmHostFiles::Create(path); |
| 388 #elif defined(OS_LINUX) |
| 389 cdm_host_files = CdmHostFiles::TakeGlobalInstance(); |
| 390 if (is_broker_ || !IsCdm(path)) |
| 391 cdm_host_files.reset(); // Close all opened files. |
| 392 #endif // defined(OS_WIN) || defined(OS_MACOSX) |
| 393 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS) |
| 394 |
| 375 #if defined(OS_WIN) | 395 #if defined(OS_WIN) |
| 376 // If code subsequently tries to exit using abort(), force a crash (since | 396 // If code subsequently tries to exit using abort(), force a crash (since |
| 377 // otherwise these would be silent terminations and fly under the radar). | 397 // otherwise these would be silent terminations and fly under the radar). |
| 378 base::win::SetAbortBehaviorForCrashReporting(); | 398 base::win::SetAbortBehaviorForCrashReporting(); |
| 379 | 399 |
| 380 // Once we lower the token the sandbox is locked down and no new modules | 400 // Once we lower the token the sandbox is locked down and no new modules |
| 381 // can be loaded. TODO(cpu): consider changing to the loading style of | 401 // can be loaded. TODO(cpu): consider changing to the loading style of |
| 382 // regular plugins. | 402 // regular plugins. |
| 383 if (g_target_services) { | 403 if (g_target_services) { |
| 384 // Let Flash and Widevine CDM adapter load DXVA before lockdown on Vista+. | 404 // Let Flash and Widevine CDM adapter load DXVA before lockdown on Vista+. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 #endif | 471 #endif |
| 452 | 472 |
| 453 int32_t init_error = plugin_entry_points_.initialize_module( | 473 int32_t init_error = plugin_entry_points_.initialize_module( |
| 454 local_pp_module_, | 474 local_pp_module_, |
| 455 &ppapi::proxy::PluginDispatcher::GetBrowserInterface); | 475 &ppapi::proxy::PluginDispatcher::GetBrowserInterface); |
| 456 if (init_error != PP_OK) { | 476 if (init_error != PP_OK) { |
| 457 LOG(WARNING) << "InitModule failed with error " << init_error; | 477 LOG(WARNING) << "InitModule failed with error " << init_error; |
| 458 ReportLoadResult(path, INIT_FAILED); | 478 ReportLoadResult(path, INIT_FAILED); |
| 459 return; | 479 return; |
| 460 } | 480 } |
| 481 #if BUILDFLAG(ENABLE_PEPPER_CDMS) |
| 482 // Now the process is sandboxed. Verify CDM host. |
| 483 if (cdm_host_files) { |
| 484 DCHECK(IsCdm(path)); |
| 485 if (!cdm_host_files->VerifyFiles(library.get(), path)) { |
| 486 LOG(WARNING) << "CDM host verification failed."; |
| 487 // TODO(xhwang): Add a new load result if needed. |
| 488 ReportLoadResult(path, INIT_FAILED); |
| 489 return; |
| 490 } |
| 491 } |
| 492 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS) |
| 461 } | 493 } |
| 462 | 494 |
| 463 // Initialization succeeded, so keep the plugin DLL loaded. | 495 // Initialization succeeded, so keep the plugin DLL loaded. |
| 464 library_.Reset(library.Release()); | 496 library_.Reset(library.Release()); |
| 465 | 497 |
| 466 ReportLoadResult(path, LOAD_SUCCESS); | 498 ReportLoadResult(path, LOAD_SUCCESS); |
| 467 } | 499 } |
| 468 | 500 |
| 469 void PpapiThread::OnCreateChannel(base::ProcessId renderer_pid, | 501 void PpapiThread::OnCreateChannel(base::ProcessId renderer_pid, |
| 470 int renderer_child_id, | 502 int renderer_child_id, |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 GetHistogramName(is_broker_, "LoadTime", path), | 637 GetHistogramName(is_broker_, "LoadTime", path), |
| 606 base::TimeDelta::FromMilliseconds(1), | 638 base::TimeDelta::FromMilliseconds(1), |
| 607 base::TimeDelta::FromSeconds(10), | 639 base::TimeDelta::FromSeconds(10), |
| 608 50, | 640 50, |
| 609 base::HistogramBase::kUmaTargetedHistogramFlag); | 641 base::HistogramBase::kUmaTargetedHistogramFlag); |
| 610 | 642 |
| 611 histogram->AddTime(load_time); | 643 histogram->AddTime(load_time); |
| 612 } | 644 } |
| 613 | 645 |
| 614 } // namespace content | 646 } // namespace content |
| OLD | NEW |