| 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 if (!error_message_string.empty()) { |
| 380 if (PP_ToBool(main_service_runtime)) { |
| 381 NexeLoadManager* load_manager = NexeLoadManager::Get(instance); |
| 382 if (load_manager) { |
| 383 load_manager->ReportLoadError(PP_NACL_ERROR_SEL_LDR_LAUNCH, |
| 384 "ServiceRuntime: failed to start", |
| 385 error_message_string); |
| 386 } |
| 387 } |
| 388 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( |
| 389 FROM_HERE, |
| 390 base::Bind(callback.func, callback.user_data, |
| 391 static_cast<int32_t>(PP_ERROR_FAILED))); |
| 392 return; |
| 393 } |
| 394 result_socket = launch_result.imc_channel_handle; |
| 395 instance_info.channel_handle = launch_result.ppapi_ipc_channel_handle; |
| 396 instance_info.plugin_pid = launch_result.plugin_pid; |
| 397 instance_info.plugin_child_id = launch_result.plugin_child_id; |
| 398 |
| 399 // Don't save instance_info if channel handle is invalid. |
| 400 if (IsValidChannelHandle(instance_info.channel_handle)) |
| 401 g_instance_info.Get()[instance] = instance_info; |
| 402 |
| 403 *(static_cast<NaClHandle*>(imc_handle)) = ToNativeHandle(result_socket); |
| 404 |
| 379 NexeLoadManager* load_manager = NexeLoadManager::Get(instance); | 405 NexeLoadManager* load_manager = NexeLoadManager::Get(instance); |
| 380 DCHECK(load_manager); | 406 DCHECK(load_manager); |
| 381 if (!load_manager) { | 407 if (!load_manager) { |
| 382 PostPPCompletionCallback(callback, PP_ERROR_FAILED); | 408 PostPPCompletionCallback(callback, PP_ERROR_FAILED); |
| 383 base::SharedMemory::CloseHandle(launch_result.crash_info_shmem_handle); | 409 base::SharedMemory::CloseHandle(launch_result.crash_info_shmem_handle); |
| 384 return; | 410 return; |
| 385 } | 411 } |
| 386 load_manager->set_nonsfi(PP_ToBool(uses_nonsfi_mode)); | |
| 387 | |
| 388 if (!error_message_string.empty()) { | |
| 389 if (PP_ToBool(main_service_runtime)) { | |
| 390 load_manager->ReportLoadError(PP_NACL_ERROR_SEL_LDR_LAUNCH, | |
| 391 "ServiceRuntime: failed to start", | |
| 392 error_message_string); | |
| 393 } | |
| 394 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | |
| 395 FROM_HERE, | |
| 396 base::Bind(callback.func, callback.user_data, | |
| 397 static_cast<int32_t>(PP_ERROR_FAILED))); | |
| 398 return; | |
| 399 } | |
| 400 result_socket = launch_result.imc_channel_handle; | |
| 401 instance_info.channel_handle = launch_result.ppapi_ipc_channel_handle; | |
| 402 instance_info.plugin_pid = launch_result.plugin_pid; | |
| 403 instance_info.plugin_child_id = launch_result.plugin_child_id; | |
| 404 | |
| 405 // Don't save instance_info if channel handle is invalid. | |
| 406 if (IsValidChannelHandle(instance_info.channel_handle)) | |
| 407 g_instance_info.Get()[instance] = instance_info; | |
| 408 | |
| 409 *(static_cast<NaClHandle*>(imc_handle)) = ToNativeHandle(result_socket); | |
| 410 | 412 |
| 411 // Store the crash information shared memory handle. | 413 // Store the crash information shared memory handle. |
| 412 load_manager->set_crash_info_shmem_handle( | 414 load_manager->set_crash_info_shmem_handle( |
| 413 launch_result.crash_info_shmem_handle); | 415 launch_result.crash_info_shmem_handle); |
| 414 | 416 |
| 415 // Create the trusted plugin channel. | 417 // Create the trusted plugin channel. |
| 416 if (IsValidChannelHandle(launch_result.trusted_ipc_channel_handle)) { | 418 if (IsValidChannelHandle(launch_result.trusted_ipc_channel_handle)) { |
| 417 bool report_exit_status = PP_ToBool(main_service_runtime); | 419 bool report_exit_status = PP_ToBool(main_service_runtime); |
| 418 scoped_ptr<TrustedPluginChannel> trusted_plugin_channel( | 420 scoped_ptr<TrustedPluginChannel> trusted_plugin_channel( |
| 419 new TrustedPluginChannel( | 421 new TrustedPluginChannel( |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 | 676 |
| 675 PP_FileHandle OpenNaClExecutable(PP_Instance instance, | 677 PP_FileHandle OpenNaClExecutable(PP_Instance instance, |
| 676 const char* file_url, | 678 const char* file_url, |
| 677 uint64_t* nonce_lo, | 679 uint64_t* nonce_lo, |
| 678 uint64_t* nonce_hi) { | 680 uint64_t* nonce_hi) { |
| 679 // Fast path only works for installed file URLs. | 681 // Fast path only works for installed file URLs. |
| 680 GURL gurl(file_url); | 682 GURL gurl(file_url); |
| 681 if (!gurl.SchemeIs("chrome-extension")) | 683 if (!gurl.SchemeIs("chrome-extension")) |
| 682 return PP_kInvalidFileHandle; | 684 return PP_kInvalidFileHandle; |
| 683 | 685 |
| 684 NexeLoadManager* load_manager = NexeLoadManager::Get(instance); | |
| 685 DCHECK(load_manager); | |
| 686 if (!load_manager) | |
| 687 return PP_kInvalidFileHandle; | |
| 688 if (load_manager->nonsfi()) | |
| 689 return PP_kInvalidFileHandle; | |
| 690 | |
| 691 content::PepperPluginInstance* plugin_instance = | 686 content::PepperPluginInstance* plugin_instance = |
| 692 content::PepperPluginInstance::Get(instance); | 687 content::PepperPluginInstance::Get(instance); |
| 693 if (!plugin_instance) | 688 if (!plugin_instance) |
| 694 return PP_kInvalidFileHandle; | 689 return PP_kInvalidFileHandle; |
| 695 // IMPORTANT: Make sure the document can request the given URL. If we don't | 690 // IMPORTANT: Make sure the document can request the given URL. If we don't |
| 696 // check, a malicious app could probe the extension system. This enforces a | 691 // check, a malicious app could probe the extension system. This enforces a |
| 697 // same-origin policy which prevents the app from requesting resources from | 692 // same-origin policy which prevents the app from requesting resources from |
| 698 // another app. | 693 // another app. |
| 699 blink::WebSecurityOrigin security_origin = | 694 blink::WebSecurityOrigin security_origin = |
| 700 plugin_instance->GetContainer()->element().document().securityOrigin(); | 695 plugin_instance->GetContainer()->element().document().securityOrigin(); |
| (...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1697 &StreamPexe | 1692 &StreamPexe |
| 1698 }; | 1693 }; |
| 1699 | 1694 |
| 1700 } // namespace | 1695 } // namespace |
| 1701 | 1696 |
| 1702 const PPB_NaCl_Private* GetNaClPrivateInterface() { | 1697 const PPB_NaCl_Private* GetNaClPrivateInterface() { |
| 1703 return &nacl_interface; | 1698 return &nacl_interface; |
| 1704 } | 1699 } |
| 1705 | 1700 |
| 1706 } // namespace nacl | 1701 } // namespace nacl |
| OLD | NEW |