OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/nacl/renderer/ppb_nacl_private_impl.h" | 5 #include "components/nacl/renderer/ppb_nacl_private_impl.h" |
6 | 6 |
7 #include <numeric> | 7 #include <numeric> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 process_type), | 369 process_type), |
370 &launch_result, | 370 &launch_result, |
371 &error_message_string))) { | 371 &error_message_string))) { |
372 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 372 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( |
373 FROM_HERE, | 373 FROM_HERE, |
374 base::Bind(callback.func, callback.user_data, | 374 base::Bind(callback.func, callback.user_data, |
375 static_cast<int32_t>(PP_ERROR_FAILED))); | 375 static_cast<int32_t>(PP_ERROR_FAILED))); |
376 return; | 376 return; |
377 } | 377 } |
378 | 378 |
| 379 NexeLoadManager* load_manager = NexeLoadManager::Get(instance); |
| 380 DCHECK(load_manager); |
| 381 if (!load_manager) { |
| 382 PostPPCompletionCallback(callback, PP_ERROR_FAILED); |
| 383 base::SharedMemory::CloseHandle(launch_result.crash_info_shmem_handle); |
| 384 return; |
| 385 } |
| 386 load_manager->set_nonsfi(PP_ToBool(uses_nonsfi_mode)); |
| 387 |
379 if (!error_message_string.empty()) { | 388 if (!error_message_string.empty()) { |
380 if (PP_ToBool(main_service_runtime)) { | 389 if (PP_ToBool(main_service_runtime)) { |
381 NexeLoadManager* load_manager = NexeLoadManager::Get(instance); | 390 load_manager->ReportLoadError(PP_NACL_ERROR_SEL_LDR_LAUNCH, |
382 if (load_manager) { | 391 "ServiceRuntime: failed to start", |
383 load_manager->ReportLoadError(PP_NACL_ERROR_SEL_LDR_LAUNCH, | 392 error_message_string); |
384 "ServiceRuntime: failed to start", | |
385 error_message_string); | |
386 } | |
387 } | 393 } |
388 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 394 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( |
389 FROM_HERE, | 395 FROM_HERE, |
390 base::Bind(callback.func, callback.user_data, | 396 base::Bind(callback.func, callback.user_data, |
391 static_cast<int32_t>(PP_ERROR_FAILED))); | 397 static_cast<int32_t>(PP_ERROR_FAILED))); |
392 return; | 398 return; |
393 } | 399 } |
394 result_socket = launch_result.imc_channel_handle; | 400 result_socket = launch_result.imc_channel_handle; |
395 instance_info.channel_handle = launch_result.ppapi_ipc_channel_handle; | 401 instance_info.channel_handle = launch_result.ppapi_ipc_channel_handle; |
396 instance_info.plugin_pid = launch_result.plugin_pid; | 402 instance_info.plugin_pid = launch_result.plugin_pid; |
397 instance_info.plugin_child_id = launch_result.plugin_child_id; | 403 instance_info.plugin_child_id = launch_result.plugin_child_id; |
398 | 404 |
399 // Don't save instance_info if channel handle is invalid. | 405 // Don't save instance_info if channel handle is invalid. |
400 if (IsValidChannelHandle(instance_info.channel_handle)) | 406 if (IsValidChannelHandle(instance_info.channel_handle)) |
401 g_instance_info.Get()[instance] = instance_info; | 407 g_instance_info.Get()[instance] = instance_info; |
402 | 408 |
403 *(static_cast<NaClHandle*>(imc_handle)) = ToNativeHandle(result_socket); | 409 *(static_cast<NaClHandle*>(imc_handle)) = ToNativeHandle(result_socket); |
404 | 410 |
405 NexeLoadManager* load_manager = NexeLoadManager::Get(instance); | |
406 DCHECK(load_manager); | |
407 if (!load_manager) { | |
408 PostPPCompletionCallback(callback, PP_ERROR_FAILED); | |
409 base::SharedMemory::CloseHandle(launch_result.crash_info_shmem_handle); | |
410 return; | |
411 } | |
412 | |
413 // Store the crash information shared memory handle. | 411 // Store the crash information shared memory handle. |
414 load_manager->set_crash_info_shmem_handle( | 412 load_manager->set_crash_info_shmem_handle( |
415 launch_result.crash_info_shmem_handle); | 413 launch_result.crash_info_shmem_handle); |
416 | 414 |
417 // Create the trusted plugin channel. | 415 // Create the trusted plugin channel. |
418 if (IsValidChannelHandle(launch_result.trusted_ipc_channel_handle)) { | 416 if (IsValidChannelHandle(launch_result.trusted_ipc_channel_handle)) { |
419 bool report_exit_status = PP_ToBool(main_service_runtime); | 417 bool report_exit_status = PP_ToBool(main_service_runtime); |
420 scoped_ptr<TrustedPluginChannel> trusted_plugin_channel( | 418 scoped_ptr<TrustedPluginChannel> trusted_plugin_channel( |
421 new TrustedPluginChannel( | 419 new TrustedPluginChannel( |
422 load_manager, | 420 load_manager, |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 | 674 |
677 PP_FileHandle OpenNaClExecutable(PP_Instance instance, | 675 PP_FileHandle OpenNaClExecutable(PP_Instance instance, |
678 const char* file_url, | 676 const char* file_url, |
679 uint64_t* nonce_lo, | 677 uint64_t* nonce_lo, |
680 uint64_t* nonce_hi) { | 678 uint64_t* nonce_hi) { |
681 // Fast path only works for installed file URLs. | 679 // Fast path only works for installed file URLs. |
682 GURL gurl(file_url); | 680 GURL gurl(file_url); |
683 if (!gurl.SchemeIs("chrome-extension")) | 681 if (!gurl.SchemeIs("chrome-extension")) |
684 return PP_kInvalidFileHandle; | 682 return PP_kInvalidFileHandle; |
685 | 683 |
| 684 NexeLoadManager* load_manager = NexeLoadManager::Get(instance); |
| 685 DCHECK(load_manager); |
| 686 if (!load_manager) |
| 687 return PP_kInvalidFileHandle; |
| 688 |
686 content::PepperPluginInstance* plugin_instance = | 689 content::PepperPluginInstance* plugin_instance = |
687 content::PepperPluginInstance::Get(instance); | 690 content::PepperPluginInstance::Get(instance); |
688 if (!plugin_instance) | 691 if (!plugin_instance) |
689 return PP_kInvalidFileHandle; | 692 return PP_kInvalidFileHandle; |
690 // IMPORTANT: Make sure the document can request the given URL. If we don't | 693 // IMPORTANT: Make sure the document can request the given URL. If we don't |
691 // check, a malicious app could probe the extension system. This enforces a | 694 // check, a malicious app could probe the extension system. This enforces a |
692 // same-origin policy which prevents the app from requesting resources from | 695 // same-origin policy which prevents the app from requesting resources from |
693 // another app. | 696 // another app. |
694 blink::WebSecurityOrigin security_origin = | 697 blink::WebSecurityOrigin security_origin = |
695 plugin_instance->GetContainer()->element().document().securityOrigin(); | 698 plugin_instance->GetContainer()->element().document().securityOrigin(); |
696 if (!security_origin.canRequest(gurl)) | 699 if (!security_origin.canRequest(gurl)) |
697 return PP_kInvalidFileHandle; | 700 return PP_kInvalidFileHandle; |
698 | 701 |
699 IPC::PlatformFileForTransit out_fd = IPC::InvalidPlatformFileForTransit(); | 702 IPC::PlatformFileForTransit out_fd = IPC::InvalidPlatformFileForTransit(); |
700 IPC::Sender* sender = content::RenderThread::Get(); | 703 IPC::Sender* sender = content::RenderThread::Get(); |
701 DCHECK(sender); | 704 DCHECK(sender); |
702 *nonce_lo = 0; | 705 *nonce_lo = 0; |
703 *nonce_hi = 0; | 706 *nonce_hi = 0; |
704 base::FilePath file_path; | 707 base::FilePath file_path; |
705 if (!sender->Send( | 708 if (!sender->Send( |
706 new NaClHostMsg_OpenNaClExecutable(GetRoutingID(instance), | 709 new NaClHostMsg_OpenNaClExecutable(GetRoutingID(instance), |
707 GURL(file_url), | 710 GURL(file_url), |
| 711 !load_manager->nonsfi(), |
708 &out_fd, | 712 &out_fd, |
709 nonce_lo, | 713 nonce_lo, |
710 nonce_hi))) { | 714 nonce_hi))) { |
711 return PP_kInvalidFileHandle; | 715 return PP_kInvalidFileHandle; |
712 } | 716 } |
713 | 717 |
714 if (out_fd == IPC::InvalidPlatformFileForTransit()) | 718 if (out_fd == IPC::InvalidPlatformFileForTransit()) |
715 return PP_kInvalidFileHandle; | 719 return PP_kInvalidFileHandle; |
716 | 720 |
717 return IPC::PlatformFileForTransitToPlatformFile(out_fd); | 721 return IPC::PlatformFileForTransitToPlatformFile(out_fd); |
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1692 &StreamPexe | 1696 &StreamPexe |
1693 }; | 1697 }; |
1694 | 1698 |
1695 } // namespace | 1699 } // namespace |
1696 | 1700 |
1697 const PPB_NaCl_Private* GetNaClPrivateInterface() { | 1701 const PPB_NaCl_Private* GetNaClPrivateInterface() { |
1698 return &nacl_interface; | 1702 return &nacl_interface; |
1699 } | 1703 } |
1700 | 1704 |
1701 } // namespace nacl | 1705 } // namespace nacl |
OLD | NEW |