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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
383 | 383 |
384 #if defined(OS_WIN) || defined(OS_MACOSX) | 384 #if defined(OS_WIN) || defined(OS_MACOSX) |
385 // Open CDM host files before the process is sandboxed. | 385 // Open CDM host files before the process is sandboxed. |
386 if (!is_broker_ && IsCdm(path)) | 386 if (!is_broker_ && IsCdm(path)) |
387 cdm_host_files = CdmHostFiles::Create(path); | 387 cdm_host_files = CdmHostFiles::Create(path); |
388 #elif defined(OS_LINUX) | 388 #elif defined(OS_LINUX) |
389 cdm_host_files = CdmHostFiles::TakeGlobalInstance(); | 389 cdm_host_files = CdmHostFiles::TakeGlobalInstance(); |
390 if (is_broker_ || !IsCdm(path)) | 390 if (is_broker_ || !IsCdm(path)) |
391 cdm_host_files.reset(); // Close all opened files. | 391 cdm_host_files.reset(); // Close all opened files. |
392 #endif // defined(OS_WIN) || defined(OS_MACOSX) | 392 #endif // defined(OS_WIN) || defined(OS_MACOSX) |
393 | |
394 #if defined(OS_WIN) | |
395 // On Windows, initialize CDM host verification unsandboxed. On other | |
396 // platforms, this is called sandboxed below. | |
397 if (cdm_host_files) { | |
398 DCHECK(IsCdm(path)); | |
399 if (!cdm_host_files->InitVerification(library.get(), path)) { | |
400 LOG(WARNING) << "CDM host verification failed."; | |
401 // TODO(xhwang): Add a new load result if needed. | |
402 ReportLoadResult(path, INIT_FAILED); | |
403 return; | |
404 } | |
405 } | |
406 #endif // defined(OS_WIN) | |
393 #endif // BUILDFLAG(ENABLE_CDM_HOST_VERIFICATION) | 407 #endif // BUILDFLAG(ENABLE_CDM_HOST_VERIFICATION) |
394 | 408 |
395 #if defined(OS_WIN) | 409 #if defined(OS_WIN) |
396 // If code subsequently tries to exit using abort(), force a crash (since | 410 // If code subsequently tries to exit using abort(), force a crash (since |
397 // otherwise these would be silent terminations and fly under the radar). | 411 // otherwise these would be silent terminations and fly under the radar). |
398 base::win::SetAbortBehaviorForCrashReporting(); | 412 base::win::SetAbortBehaviorForCrashReporting(); |
399 | 413 |
400 // Once we lower the token the sandbox is locked down and no new modules | 414 // Once we lower the token the sandbox is locked down and no new modules |
401 // can be loaded. TODO(cpu): consider changing to the loading style of | 415 // can be loaded. TODO(cpu): consider changing to the loading style of |
402 // regular plugins. | 416 // regular plugins. |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
463 return; | 477 return; |
464 } | 478 } |
465 } else { | 479 } else { |
466 #if defined(OS_MACOSX) | 480 #if defined(OS_MACOSX) |
467 // We need to do this after getting |PPP_GetInterface()| (or presumably | 481 // We need to do this after getting |PPP_GetInterface()| (or presumably |
468 // doing something nontrivial with the library), else the sandbox | 482 // doing something nontrivial with the library), else the sandbox |
469 // intercedes. | 483 // intercedes. |
470 CHECK(InitializeSandbox()); | 484 CHECK(InitializeSandbox()); |
471 #endif | 485 #endif |
472 | 486 |
473 int32_t init_error = plugin_entry_points_.initialize_module( | 487 #if BUILDFLAG(ENABLE_CDM_HOST_VERIFICATION) && !defined(OS_WIN) |
474 local_pp_module_, | 488 // Now we are sandboxed, initialize CDM host verification. |
475 &ppapi::proxy::PluginDispatcher::GetBrowserInterface); | |
476 if (init_error != PP_OK) { | |
477 LOG(WARNING) << "InitModule failed with error " << init_error; | |
478 ReportLoadResult(path, INIT_FAILED); | |
479 return; | |
480 } | |
481 #if BUILDFLAG(ENABLE_CDM_HOST_VERIFICATION) | |
482 // Now the process is sandboxed. Verify CDM host. | |
483 if (cdm_host_files) { | 489 if (cdm_host_files) { |
484 DCHECK(IsCdm(path)); | 490 DCHECK(IsCdm(path)); |
485 if (!cdm_host_files->VerifyFiles(library.get(), path)) { | 491 if (!cdm_host_files->InitVerification(library.get(), path)) { |
486 LOG(WARNING) << "CDM host verification failed."; | 492 LOG(WARNING) << "CDM host verification failed."; |
487 // TODO(xhwang): Add a new load result if needed. | 493 // TODO(xhwang): Add a new load result if needed. |
488 ReportLoadResult(path, INIT_FAILED); | 494 ReportLoadResult(path, INIT_FAILED); |
489 return; | 495 return; |
490 } | 496 } |
491 } | 497 } |
492 #endif // BUILDFLAG(ENABLE_CDM_HOST_VERIFICATION) | 498 #endif // BUILDFLAG(ENABLE_CDM_HOST_VERIFICATION) && !defined(OS_WIN) |
xhwang
2017/05/01 23:57:00
Move this to be above "initialize_module" to be co
| |
499 | |
500 int32_t init_error = plugin_entry_points_.initialize_module( | |
501 local_pp_module_, &ppapi::proxy::PluginDispatcher::GetBrowserInterface); | |
502 if (init_error != PP_OK) { | |
503 LOG(WARNING) << "InitModule failed with error " << init_error; | |
504 ReportLoadResult(path, INIT_FAILED); | |
505 return; | |
506 } | |
493 } | 507 } |
494 | 508 |
495 // Initialization succeeded, so keep the plugin DLL loaded. | 509 // Initialization succeeded, so keep the plugin DLL loaded. |
496 library_.Reset(library.Release()); | 510 library_.Reset(library.Release()); |
497 | 511 |
498 ReportLoadResult(path, LOAD_SUCCESS); | 512 ReportLoadResult(path, LOAD_SUCCESS); |
499 } | 513 } |
500 | 514 |
501 void PpapiThread::OnCreateChannel(base::ProcessId renderer_pid, | 515 void PpapiThread::OnCreateChannel(base::ProcessId renderer_pid, |
502 int renderer_child_id, | 516 int renderer_child_id, |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
637 GetHistogramName(is_broker_, "LoadTime", path), | 651 GetHistogramName(is_broker_, "LoadTime", path), |
638 base::TimeDelta::FromMilliseconds(1), | 652 base::TimeDelta::FromMilliseconds(1), |
639 base::TimeDelta::FromSeconds(10), | 653 base::TimeDelta::FromSeconds(10), |
640 50, | 654 50, |
641 base::HistogramBase::kUmaTargetedHistogramFlag); | 655 base::HistogramBase::kUmaTargetedHistogramFlag); |
642 | 656 |
643 histogram->AddTime(load_time); | 657 histogram->AddTime(load_time); |
644 } | 658 } |
645 | 659 |
646 } // namespace content | 660 } // namespace content |
OLD | NEW |