Chromium Code Reviews| 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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 368 // destructed (without passing it to ManifestServiceChannel). | 368 // destructed (without passing it to ManifestServiceChannel). |
| 369 scoped_ptr<ManifestServiceChannel::Delegate> manifest_service_proxy( | 369 scoped_ptr<ManifestServiceChannel::Delegate> manifest_service_proxy( |
| 370 new ManifestServiceProxy(instance, process_type)); | 370 new ManifestServiceProxy(instance, process_type)); |
| 371 | 371 |
| 372 FileDescriptor result_socket; | 372 FileDescriptor result_socket; |
| 373 IPC::Sender* sender = content::RenderThread::Get(); | 373 IPC::Sender* sender = content::RenderThread::Get(); |
| 374 DCHECK(sender); | 374 DCHECK(sender); |
| 375 int routing_id = GetRoutingID(instance); | 375 int routing_id = GetRoutingID(instance); |
| 376 NexeLoadManager* load_manager = GetNexeLoadManager(instance); | 376 NexeLoadManager* load_manager = GetNexeLoadManager(instance); |
| 377 DCHECK(load_manager); | 377 DCHECK(load_manager); |
| 378 if (!routing_id || !load_manager) { | 378 content::PepperPluginInstance* plugin_instance = |
| 379 content::PepperPluginInstance::Get(instance); | |
| 380 DCHECK(plugin_instance); | |
| 381 if (!routing_id || !load_manager || !plugin_instance) { | |
| 379 if (nexe_file_info->handle != PP_kInvalidFileHandle) { | 382 if (nexe_file_info->handle != PP_kInvalidFileHandle) { |
| 380 base::File closer(nexe_file_info->handle); | 383 base::File closer(nexe_file_info->handle); |
| 381 } | 384 } |
| 382 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 385 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( |
| 383 FROM_HERE, base::Bind(callback.func, callback.user_data, | 386 FROM_HERE, base::Bind(callback.func, callback.user_data, |
| 384 static_cast<int32_t>(PP_ERROR_FAILED))); | 387 static_cast<int32_t>(PP_ERROR_FAILED))); |
| 385 return; | 388 return; |
| 386 } | 389 } |
| 387 | 390 |
| 388 InstanceInfo instance_info; | 391 InstanceInfo instance_info; |
| 389 instance_info.url = GURL(alleged_url); | 392 instance_info.url = GURL(alleged_url); |
| 390 | 393 |
| 391 uint32_t perm_bits = ppapi::PERMISSION_NONE; | 394 uint32_t perm_bits = ppapi::PERMISSION_NONE; |
| 392 // Conditionally block 'Dev' interfaces. We do this for the NaCl process, so | 395 // Conditionally block 'Dev' interfaces. We do this for the NaCl process, so |
| 393 // it's clearer to developers when they are using 'Dev' inappropriately. We | 396 // it's clearer to developers when they are using 'Dev' inappropriately. We |
| 394 // must also check on the trusted side of the proxy. | 397 // must also check on the trusted side of the proxy. |
| 395 if (load_manager->DevInterfacesEnabled()) | 398 if (load_manager->DevInterfacesEnabled()) |
| 396 perm_bits |= ppapi::PERMISSION_DEV; | 399 perm_bits |= ppapi::PERMISSION_DEV; |
| 397 instance_info.permissions = | 400 instance_info.permissions = |
| 398 ppapi::PpapiPermissions::GetForCommandLine(perm_bits); | 401 ppapi::PpapiPermissions::GetForCommandLine(perm_bits); |
| 399 std::string error_message_string; | 402 std::string error_message_string; |
| 400 NaClLaunchResult launch_result; | 403 NaClLaunchResult launch_result; |
| 401 | 404 |
| 402 IPC::PlatformFileForTransit nexe_for_transit = | 405 IPC::PlatformFileForTransit nexe_for_transit = |
| 403 IPC::InvalidPlatformFileForTransit(); | 406 IPC::InvalidPlatformFileForTransit(); |
| 407 | |
| 408 std::vector<std::pair< | |
| 409 std::string /*url*/, std::string /*key*/> > prefetched_resource_files; | |
|
Mark Seaborn
2015/02/25 20:01:24
How about "resource_files_to_prefetch", since they
Yusuke Sato
2015/03/01 06:59:37
Done.
| |
| 410 if (process_type == kNativeNaClProcessType) { | |
| 411 JsonManifest* manifest = GetJsonManifest(instance); | |
| 412 if (manifest) | |
| 413 manifest->GetPrefetchableFiles(&prefetched_resource_files); | |
| 414 blink::WebSecurityOrigin security_origin = | |
| 415 plugin_instance->GetContainer()->element().document().securityOrigin(); | |
| 416 for (size_t i = 0; i < prefetched_resource_files.size(); ++i) { | |
| 417 const GURL gurl(prefetched_resource_files[i].first); | |
| 418 DCHECK(gurl.SchemeIs("chrome-extension")); | |
| 419 // IMPORTANT SECURITY CHECK: See the comment in OpenNaClResources(). | |
|
Mark Seaborn
2015/02/25 20:01:24
OpenNaClResources() no longer exists, I think.
Yusuke Sato
2015/03/01 06:59:37
Removed the comment
| |
| 420 if (!security_origin.canRequest(gurl)) { | |
|
Mark Seaborn
2015/02/25 20:01:24
Duplicating the two checks that OpenNaClExecutable
Yusuke Sato
2015/03/01 06:59:37
Done.
| |
| 421 prefetched_resource_files.clear(); | |
| 422 break; | |
| 423 } | |
| 424 } | |
| 425 } | |
| 426 | |
| 404 #if defined(OS_POSIX) | 427 #if defined(OS_POSIX) |
| 405 if (nexe_file_info->handle != PP_kInvalidFileHandle) | 428 if (nexe_file_info->handle != PP_kInvalidFileHandle) |
| 406 nexe_for_transit = base::FileDescriptor(nexe_file_info->handle, true); | 429 nexe_for_transit = base::FileDescriptor(nexe_file_info->handle, true); |
| 407 #elif defined(OS_WIN) | 430 #elif defined(OS_WIN) |
| 408 // Duplicate the handle on the browser side instead of the renderer. | 431 // Duplicate the handle on the browser side instead of the renderer. |
| 409 // This is because BrokerGetFileForProcess isn't part of content/public, and | 432 // This is because BrokerGetFileForProcess isn't part of content/public, and |
| 410 // it's simpler to do the duplication in the browser anyway. | 433 // it's simpler to do the duplication in the browser anyway. |
| 411 nexe_for_transit = nexe_file_info->handle; | 434 nexe_for_transit = nexe_file_info->handle; |
| 412 #else | 435 #else |
| 413 #error Unsupported target platform. | 436 #error Unsupported target platform. |
| 414 #endif | 437 #endif |
| 415 if (!sender->Send(new NaClHostMsg_LaunchNaCl( | 438 if (!sender->Send(new NaClHostMsg_LaunchNaCl( |
| 416 NaClLaunchParams( | 439 NaClLaunchParams( |
| 417 instance_info.url.spec(), | 440 instance_info.url.spec(), |
| 418 nexe_for_transit, | 441 nexe_for_transit, |
| 419 nexe_file_info->token_lo, | 442 nexe_file_info->token_lo, |
| 420 nexe_file_info->token_hi, | 443 nexe_file_info->token_hi, |
| 444 prefetched_resource_files, | |
| 421 routing_id, | 445 routing_id, |
| 422 perm_bits, | 446 perm_bits, |
| 423 PP_ToBool(uses_nonsfi_mode), | 447 PP_ToBool(uses_nonsfi_mode), |
| 424 process_type), | 448 process_type), |
| 425 &launch_result, | 449 &launch_result, |
| 426 &error_message_string))) { | 450 &error_message_string))) { |
| 427 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( | 451 ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( |
| 428 FROM_HERE, | 452 FROM_HERE, |
| 429 base::Bind(callback.func, callback.user_data, | 453 base::Bind(callback.func, callback.user_data, |
| 430 static_cast<int32_t>(PP_ERROR_FAILED))); | 454 static_cast<int32_t>(PP_ERROR_FAILED))); |
| (...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1651 &StreamPexe | 1675 &StreamPexe |
| 1652 }; | 1676 }; |
| 1653 | 1677 |
| 1654 } // namespace | 1678 } // namespace |
| 1655 | 1679 |
| 1656 const PPB_NaCl_Private* GetNaClPrivateInterface() { | 1680 const PPB_NaCl_Private* GetNaClPrivateInterface() { |
| 1657 return &nacl_interface; | 1681 return &nacl_interface; |
| 1658 } | 1682 } |
| 1659 | 1683 |
| 1660 } // namespace nacl | 1684 } // namespace nacl |
| OLD | NEW |