Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(363)

Side by Side Diff: content/ppapi_plugin/ppapi_thread.cc

Issue 2755763002: media: Add build flag for CDM host verification (Closed)
Patch Set: fix cdm_host_file_path.cc Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/common/BUILD.gn ('k') | content/zygote/zygote_main_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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) 68 #if BUILDFLAG(ENABLE_CDM_HOST_VERIFICATION)
69 #include "content/common/media/cdm_host_files.h" 69 #include "content/common/media/cdm_host_files.h"
70 #endif 70 #endif
71 71
72 #if defined(OS_WIN) 72 #if defined(OS_WIN)
73 const char kWidevineCdmAdapterFileName[] = "widevinecdmadapter.dll"; 73 const char kWidevineCdmAdapterFileName[] = "widevinecdmadapter.dll";
74 74
75 extern sandbox::TargetServices* g_target_services; 75 extern sandbox::TargetServices* g_target_services;
76 76
77 // Used by EnumSystemLocales for warming up. 77 // Used by EnumSystemLocales for warming up.
78 static BOOL CALLBACK EnumLocalesProc(LPTSTR lpLocaleString) { 78 static BOOL CALLBACK EnumLocalesProc(LPTSTR lpLocaleString) {
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 reinterpret_cast<PP_InitializeModule_Func>( 369 reinterpret_cast<PP_InitializeModule_Func>(
370 library.GetFunctionPointer("PPP_InitializeModule")); 370 library.GetFunctionPointer("PPP_InitializeModule"));
371 if (!plugin_entry_points_.initialize_module) { 371 if (!plugin_entry_points_.initialize_module) {
372 LOG(WARNING) << "No PPP_InitializeModule in plugin library"; 372 LOG(WARNING) << "No PPP_InitializeModule in plugin library";
373 ReportLoadResult(path, ENTRY_POINT_MISSING); 373 ReportLoadResult(path, ENTRY_POINT_MISSING);
374 return; 374 return;
375 } 375 }
376 } 376 }
377 } 377 }
378 378
379 #if BUILDFLAG(ENABLE_PEPPER_CDMS) 379 #if BUILDFLAG(ENABLE_CDM_HOST_VERIFICATION)
380 // Use a local instance of CdmHostFiles so that if we return early for any 380 // Use a local instance of CdmHostFiles so that if we return early for any
381 // error, all files will closed automatically. 381 // error, all files will closed automatically.
382 std::unique_ptr<CdmHostFiles> cdm_host_files; 382 std::unique_ptr<CdmHostFiles> cdm_host_files;
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 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS) 393 #endif // BUILDFLAG(ENABLE_CDM_HOST_VERIFICATION)
394 394
395 #if defined(OS_WIN) 395 #if defined(OS_WIN)
396 // 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
397 // otherwise these would be silent terminations and fly under the radar). 397 // otherwise these would be silent terminations and fly under the radar).
398 base::win::SetAbortBehaviorForCrashReporting(); 398 base::win::SetAbortBehaviorForCrashReporting();
399 399
400 // 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
401 // 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
402 // regular plugins. 402 // regular plugins.
403 if (g_target_services) { 403 if (g_target_services) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 #endif 471 #endif
472 472
473 int32_t init_error = plugin_entry_points_.initialize_module( 473 int32_t init_error = plugin_entry_points_.initialize_module(
474 local_pp_module_, 474 local_pp_module_,
475 &ppapi::proxy::PluginDispatcher::GetBrowserInterface); 475 &ppapi::proxy::PluginDispatcher::GetBrowserInterface);
476 if (init_error != PP_OK) { 476 if (init_error != PP_OK) {
477 LOG(WARNING) << "InitModule failed with error " << init_error; 477 LOG(WARNING) << "InitModule failed with error " << init_error;
478 ReportLoadResult(path, INIT_FAILED); 478 ReportLoadResult(path, INIT_FAILED);
479 return; 479 return;
480 } 480 }
481 #if BUILDFLAG(ENABLE_PEPPER_CDMS) 481 #if BUILDFLAG(ENABLE_CDM_HOST_VERIFICATION)
482 // Now the process is sandboxed. Verify CDM host. 482 // Now the process is sandboxed. Verify CDM host.
483 if (cdm_host_files) { 483 if (cdm_host_files) {
484 DCHECK(IsCdm(path)); 484 DCHECK(IsCdm(path));
485 if (!cdm_host_files->VerifyFiles(library.get(), path)) { 485 if (!cdm_host_files->VerifyFiles(library.get(), path)) {
486 LOG(WARNING) << "CDM host verification failed."; 486 LOG(WARNING) << "CDM host verification failed.";
487 // TODO(xhwang): Add a new load result if needed. 487 // TODO(xhwang): Add a new load result if needed.
488 ReportLoadResult(path, INIT_FAILED); 488 ReportLoadResult(path, INIT_FAILED);
489 return; 489 return;
490 } 490 }
491 } 491 }
492 #endif // BUILDFLAG(ENABLE_PEPPER_CDMS) 492 #endif // BUILDFLAG(ENABLE_CDM_HOST_VERIFICATION)
493 } 493 }
494 494
495 // Initialization succeeded, so keep the plugin DLL loaded. 495 // Initialization succeeded, so keep the plugin DLL loaded.
496 library_.Reset(library.Release()); 496 library_.Reset(library.Release());
497 497
498 ReportLoadResult(path, LOAD_SUCCESS); 498 ReportLoadResult(path, LOAD_SUCCESS);
499 } 499 }
500 500
501 void PpapiThread::OnCreateChannel(base::ProcessId renderer_pid, 501 void PpapiThread::OnCreateChannel(base::ProcessId renderer_pid,
502 int renderer_child_id, 502 int renderer_child_id,
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 GetHistogramName(is_broker_, "LoadTime", path), 637 GetHistogramName(is_broker_, "LoadTime", path),
638 base::TimeDelta::FromMilliseconds(1), 638 base::TimeDelta::FromMilliseconds(1),
639 base::TimeDelta::FromSeconds(10), 639 base::TimeDelta::FromSeconds(10),
640 50, 640 50,
641 base::HistogramBase::kUmaTargetedHistogramFlag); 641 base::HistogramBase::kUmaTargetedHistogramFlag);
642 642
643 histogram->AddTime(load_time); 643 histogram->AddTime(load_time);
644 } 644 }
645 645
646 } // namespace content 646 } // namespace content
OLDNEW
« no previous file with comments | « content/common/BUILD.gn ('k') | content/zygote/zygote_main_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698