| 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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 pp_process_type < PP_NUM_NACL_PROCESS_TYPES); | 351 pp_process_type < PP_NUM_NACL_PROCESS_TYPES); |
| 352 return static_cast<NaClAppProcessType>(pp_process_type); | 352 return static_cast<NaClAppProcessType>(pp_process_type); |
| 353 } | 353 } |
| 354 | 354 |
| 355 // Launch NaCl's sel_ldr process. | 355 // Launch NaCl's sel_ldr process. |
| 356 void LaunchSelLdr(PP_Instance instance, | 356 void LaunchSelLdr(PP_Instance instance, |
| 357 PP_Bool main_service_runtime, | 357 PP_Bool main_service_runtime, |
| 358 const char* alleged_url, | 358 const char* alleged_url, |
| 359 const PP_NaClFileInfo* nexe_file_info, | 359 const PP_NaClFileInfo* nexe_file_info, |
| 360 PP_Bool uses_nonsfi_mode, | 360 PP_Bool uses_nonsfi_mode, |
| 361 PP_Bool enable_ppapi_dev, | |
| 362 PP_NaClAppProcessType pp_process_type, | 361 PP_NaClAppProcessType pp_process_type, |
| 363 void* imc_handle, | 362 void* imc_handle, |
| 364 PP_CompletionCallback callback) { | 363 PP_CompletionCallback callback) { |
| 365 CHECK(ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()-> | 364 CHECK(ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()-> |
| 366 BelongsToCurrentThread()); | 365 BelongsToCurrentThread()); |
| 367 NaClAppProcessType process_type = PP_ToNaClAppProcessType(pp_process_type); | 366 NaClAppProcessType process_type = PP_ToNaClAppProcessType(pp_process_type); |
| 368 // Create the manifest service proxy here, so on error case, it will be | 367 // Create the manifest service proxy here, so on error case, it will be |
| 369 // destructed (without passing it to ManifestServiceChannel). | 368 // destructed (without passing it to ManifestServiceChannel). |
| 370 scoped_ptr<ManifestServiceChannel::Delegate> manifest_service_proxy( | 369 scoped_ptr<ManifestServiceChannel::Delegate> manifest_service_proxy( |
| 371 new ManifestServiceProxy(instance, process_type)); | 370 new ManifestServiceProxy(instance, process_type)); |
| 372 | 371 |
| 373 FileDescriptor result_socket; | 372 FileDescriptor result_socket; |
| 374 IPC::Sender* sender = content::RenderThread::Get(); | 373 IPC::Sender* sender = content::RenderThread::Get(); |
| 375 DCHECK(sender); | 374 DCHECK(sender); |
| 376 int routing_id = GetRoutingID(instance); | 375 int routing_id = GetRoutingID(instance); |
| 377 if (!routing_id) { | 376 NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
| 377 DCHECK(load_manager); |
| 378 if (!routing_id || !load_manager) { |
| 378 if (nexe_file_info->handle != PP_kInvalidFileHandle) { | 379 if (nexe_file_info->handle != PP_kInvalidFileHandle) { |
| 379 base::File closer(nexe_file_info->handle); | 380 base::File closer(nexe_file_info->handle); |
| 380 } | 381 } |
| 381 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 382 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( |
| 382 FROM_HERE, base::Bind(callback.func, callback.user_data, | 383 FROM_HERE, base::Bind(callback.func, callback.user_data, |
| 383 static_cast<int32_t>(PP_ERROR_FAILED))); | 384 static_cast<int32_t>(PP_ERROR_FAILED))); |
| 384 return; | 385 return; |
| 385 } | 386 } |
| 386 | 387 |
| 387 InstanceInfo instance_info; | 388 InstanceInfo instance_info; |
| 388 instance_info.url = GURL(alleged_url); | 389 instance_info.url = GURL(alleged_url); |
| 389 | 390 |
| 390 uint32_t perm_bits = ppapi::PERMISSION_NONE; | 391 uint32_t perm_bits = ppapi::PERMISSION_NONE; |
| 391 // Conditionally block 'Dev' interfaces. We do this for the NaCl process, so | 392 // Conditionally block 'Dev' interfaces. We do this for the NaCl process, so |
| 392 // it's clearer to developers when they are using 'Dev' inappropriately. We | 393 // it's clearer to developers when they are using 'Dev' inappropriately. We |
| 393 // must also check on the trusted side of the proxy. | 394 // must also check on the trusted side of the proxy. |
| 394 if (enable_ppapi_dev) | 395 if (load_manager->DevInterfacesEnabled()) |
| 395 perm_bits |= ppapi::PERMISSION_DEV; | 396 perm_bits |= ppapi::PERMISSION_DEV; |
| 396 instance_info.permissions = | 397 instance_info.permissions = |
| 397 ppapi::PpapiPermissions::GetForCommandLine(perm_bits); | 398 ppapi::PpapiPermissions::GetForCommandLine(perm_bits); |
| 398 std::string error_message_string; | 399 std::string error_message_string; |
| 399 NaClLaunchResult launch_result; | 400 NaClLaunchResult launch_result; |
| 400 | 401 |
| 401 IPC::PlatformFileForTransit nexe_for_transit = | 402 IPC::PlatformFileForTransit nexe_for_transit = |
| 402 IPC::InvalidPlatformFileForTransit(); | 403 IPC::InvalidPlatformFileForTransit(); |
| 403 #if defined(OS_POSIX) | 404 #if defined(OS_POSIX) |
| 404 if (nexe_file_info->handle != PP_kInvalidFileHandle) | 405 if (nexe_file_info->handle != PP_kInvalidFileHandle) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 423 process_type), | 424 process_type), |
| 424 &launch_result, | 425 &launch_result, |
| 425 &error_message_string))) { | 426 &error_message_string))) { |
| 426 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 427 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( |
| 427 FROM_HERE, | 428 FROM_HERE, |
| 428 base::Bind(callback.func, callback.user_data, | 429 base::Bind(callback.func, callback.user_data, |
| 429 static_cast<int32_t>(PP_ERROR_FAILED))); | 430 static_cast<int32_t>(PP_ERROR_FAILED))); |
| 430 return; | 431 return; |
| 431 } | 432 } |
| 432 | 433 |
| 433 NexeLoadManager* load_manager = GetNexeLoadManager(instance); | |
| 434 DCHECK(load_manager); | |
| 435 if (!load_manager) { | |
| 436 PostPPCompletionCallback(callback, PP_ERROR_FAILED); | |
| 437 base::SharedMemory::CloseHandle(launch_result.crash_info_shmem_handle); | |
| 438 return; | |
| 439 } | |
| 440 load_manager->set_nonsfi(PP_ToBool(uses_nonsfi_mode)); | 434 load_manager->set_nonsfi(PP_ToBool(uses_nonsfi_mode)); |
| 441 | 435 |
| 442 if (!error_message_string.empty()) { | 436 if (!error_message_string.empty()) { |
| 443 if (PP_ToBool(main_service_runtime)) { | 437 if (PP_ToBool(main_service_runtime)) { |
| 444 load_manager->ReportLoadError(PP_NACL_ERROR_SEL_LDR_LAUNCH, | 438 load_manager->ReportLoadError(PP_NACL_ERROR_SEL_LDR_LAUNCH, |
| 445 "ServiceRuntime: failed to start", | 439 "ServiceRuntime: failed to start", |
| 446 error_message_string); | 440 error_message_string); |
| 447 } | 441 } |
| 448 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 442 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( |
| 449 FROM_HERE, | 443 FROM_HERE, |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 896 return PP_MakeUndefined(); | 890 return PP_MakeUndefined(); |
| 897 return ppapi::StringVar::StringToPPVar(gurl.spec()); | 891 return ppapi::StringVar::StringToPPVar(gurl.spec()); |
| 898 } | 892 } |
| 899 | 893 |
| 900 void ProcessNaClManifest(PP_Instance instance, const char* program_url) { | 894 void ProcessNaClManifest(PP_Instance instance, const char* program_url) { |
| 901 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); | 895 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
| 902 if (load_manager) | 896 if (load_manager) |
| 903 load_manager->ProcessNaClManifest(program_url); | 897 load_manager->ProcessNaClManifest(program_url); |
| 904 } | 898 } |
| 905 | 899 |
| 906 PP_Bool DevInterfacesEnabled(PP_Instance instance) { | |
| 907 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); | |
| 908 if (load_manager) | |
| 909 return PP_FromBool(load_manager->DevInterfacesEnabled()); | |
| 910 return PP_FALSE; | |
| 911 } | |
| 912 | |
| 913 void DownloadManifestToBufferCompletion(PP_Instance instance, | 900 void DownloadManifestToBufferCompletion(PP_Instance instance, |
| 914 struct PP_CompletionCallback callback, | 901 struct PP_CompletionCallback callback, |
| 915 base::Time start_time, | 902 base::Time start_time, |
| 916 PP_NaClError pp_nacl_error, | 903 PP_NaClError pp_nacl_error, |
| 917 const std::string& data); | 904 const std::string& data); |
| 918 | 905 |
| 919 void DownloadManifestToBuffer(PP_Instance instance, | 906 void DownloadManifestToBuffer(PP_Instance instance, |
| 920 struct PP_CompletionCallback callback) { | 907 struct PP_CompletionCallback callback) { |
| 921 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); | 908 nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
| 922 DCHECK(load_manager); | 909 DCHECK(load_manager); |
| (...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1647 &DispatchEvent, | 1634 &DispatchEvent, |
| 1648 &ReportLoadError, | 1635 &ReportLoadError, |
| 1649 &InstanceCreated, | 1636 &InstanceCreated, |
| 1650 &InstanceDestroyed, | 1637 &InstanceDestroyed, |
| 1651 &GetSandboxArch, | 1638 &GetSandboxArch, |
| 1652 &Vlog, | 1639 &Vlog, |
| 1653 &InitializePlugin, | 1640 &InitializePlugin, |
| 1654 &RequestNaClManifest, | 1641 &RequestNaClManifest, |
| 1655 &GetManifestBaseURL, | 1642 &GetManifestBaseURL, |
| 1656 &ProcessNaClManifest, | 1643 &ProcessNaClManifest, |
| 1657 &DevInterfacesEnabled, | |
| 1658 &ManifestGetProgramURL, | 1644 &ManifestGetProgramURL, |
| 1659 &GetPNaClResourceInfo, | 1645 &GetPNaClResourceInfo, |
| 1660 &GetCpuFeatureAttrs, | 1646 &GetCpuFeatureAttrs, |
| 1661 &DownloadNexe, | 1647 &DownloadNexe, |
| 1662 &ReportSelLdrStatus, | 1648 &ReportSelLdrStatus, |
| 1663 &LogTranslateTime, | 1649 &LogTranslateTime, |
| 1664 &SetPNaClStartTime, | 1650 &SetPNaClStartTime, |
| 1665 &StreamPexe | 1651 &StreamPexe |
| 1666 }; | 1652 }; |
| 1667 | 1653 |
| 1668 } // namespace | 1654 } // namespace |
| 1669 | 1655 |
| 1670 const PPB_NaCl_Private* GetNaClPrivateInterface() { | 1656 const PPB_NaCl_Private* GetNaClPrivateInterface() { |
| 1671 return &nacl_interface; | 1657 return &nacl_interface; |
| 1672 } | 1658 } |
| 1673 | 1659 |
| 1674 } // namespace nacl | 1660 } // namespace nacl |
| OLD | NEW |