OLD | NEW |
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 "chrome/browser/nacl_host/nacl_process_host.h" | 5 #include "chrome/browser/nacl_host/nacl_process_host.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
| 10 #include "base/base_switches.h" |
10 #include "base/bind.h" | 11 #include "base/bind.h" |
11 #include "base/command_line.h" | 12 #include "base/command_line.h" |
12 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
13 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
14 #include "base/path_service.h" | 15 #include "base/path_service.h" |
15 #include "base/process_util.h" | 16 #include "base/process_util.h" |
16 #include "base/string_util.h" | 17 #include "base/string_util.h" |
17 #include "base/stringprintf.h" | 18 #include "base/stringprintf.h" |
18 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
19 #include "base/strings/string_split.h" | 20 #include "base/strings/string_split.h" |
(...skipping 21 matching lines...) Expand all Loading... |
41 #include "content/public/common/child_process_host.h" | 42 #include "content/public/common/child_process_host.h" |
42 #include "content/public/common/process_type.h" | 43 #include "content/public/common/process_type.h" |
43 #include "extensions/common/constants.h" | 44 #include "extensions/common/constants.h" |
44 #include "extensions/common/url_pattern.h" | 45 #include "extensions/common/url_pattern.h" |
45 #include "ipc/ipc_channel.h" | 46 #include "ipc/ipc_channel.h" |
46 #include "ipc/ipc_switches.h" | 47 #include "ipc/ipc_switches.h" |
47 #include "native_client/src/shared/imc/nacl_imc_c.h" | 48 #include "native_client/src/shared/imc/nacl_imc_c.h" |
48 #include "net/base/net_util.h" | 49 #include "net/base/net_util.h" |
49 #include "net/socket/tcp_listen_socket.h" | 50 #include "net/socket/tcp_listen_socket.h" |
50 #include "ppapi/proxy/ppapi_messages.h" | 51 #include "ppapi/proxy/ppapi_messages.h" |
| 52 #include "ppapi/shared_impl/ppapi_nacl_channel_args.h" |
51 | 53 |
52 #if defined(OS_POSIX) | 54 #if defined(OS_POSIX) |
53 #include <fcntl.h> | 55 #include <fcntl.h> |
54 | 56 |
55 #include "ipc/ipc_channel_posix.h" | 57 #include "ipc/ipc_channel_posix.h" |
56 #elif defined(OS_WIN) | 58 #elif defined(OS_WIN) |
57 #include <windows.h> | 59 #include <windows.h> |
58 | 60 |
59 #include "base/process_util.h" | 61 #include "base/process_util.h" |
60 #include "base/threading/thread.h" | 62 #include "base/threading/thread.h" |
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 // browser process. | 828 // browser process. |
827 ppapi_host_.reset(content::BrowserPpapiHost::CreateExternalPluginProcess( | 829 ppapi_host_.reset(content::BrowserPpapiHost::CreateExternalPluginProcess( |
828 ipc_proxy_channel_.get(), // sender | 830 ipc_proxy_channel_.get(), // sender |
829 permissions_, | 831 permissions_, |
830 process_->GetData().handle, | 832 process_->GetData().handle, |
831 ipc_proxy_channel_.get(), | 833 ipc_proxy_channel_.get(), |
832 chrome_render_message_filter_->GetHostResolver(), | 834 chrome_render_message_filter_->GetHostResolver(), |
833 chrome_render_message_filter_->render_process_id(), | 835 chrome_render_message_filter_->render_process_id(), |
834 render_view_id_)); | 836 render_view_id_)); |
835 | 837 |
| 838 ppapi::PpapiNaClChannelArgs args; |
| 839 args.off_the_record = chrome_render_message_filter_->off_the_record(); |
| 840 args.permissions = permissions_; |
| 841 CommandLine* cmdline = CommandLine::ForCurrentProcess(); |
| 842 DCHECK(cmdline); |
| 843 std::string flag_whitelist[] = {switches::kV, switches::kVModule}; |
| 844 for (size_t i = 0; i < arraysize(flag_whitelist); ++i) { |
| 845 std::string value = cmdline->GetSwitchValueASCII(flag_whitelist[i]); |
| 846 if (!value.empty()) { |
| 847 args.switch_names.push_back(flag_whitelist[i]); |
| 848 args.switch_values.push_back(value); |
| 849 } |
| 850 } |
| 851 |
836 // Send a message to create the NaCl-Renderer channel. The handle is just | 852 // Send a message to create the NaCl-Renderer channel. The handle is just |
837 // a place holder. | 853 // a place holder. |
838 ipc_proxy_channel_->Send( | 854 ipc_proxy_channel_->Send( |
839 new PpapiMsg_CreateNaClChannel( | 855 new PpapiMsg_CreateNaClChannel( |
840 chrome_render_message_filter_->render_process_id(), | 856 chrome_render_message_filter_->render_process_id(), |
841 permissions_, | 857 args, |
842 chrome_render_message_filter_->off_the_record(), | |
843 SerializedHandle(SerializedHandle::CHANNEL_HANDLE, | 858 SerializedHandle(SerializedHandle::CHANNEL_HANDLE, |
844 IPC::InvalidPlatformFileForTransit()))); | 859 IPC::InvalidPlatformFileForTransit()))); |
845 } else if (reply_msg_) { | 860 } else if (reply_msg_) { |
846 // Otherwise, this must be a renderer channel. | 861 // Otherwise, this must be a renderer channel. |
847 ReplyToRenderer(channel_handle); | 862 ReplyToRenderer(channel_handle); |
848 } else { | 863 } else { |
849 // Attempt to open more than 1 renderer channel is not supported. | 864 // Attempt to open more than 1 renderer channel is not supported. |
850 // Shut down the NaCl process. | 865 // Shut down the NaCl process. |
851 process_->GetHost()->ForceShutdown(); | 866 process_->GetHost()->ForceShutdown(); |
852 } | 867 } |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 } else { | 979 } else { |
965 NaClStartDebugExceptionHandlerThread( | 980 NaClStartDebugExceptionHandlerThread( |
966 process_handle.Take(), info, | 981 process_handle.Take(), info, |
967 base::MessageLoopProxy::current(), | 982 base::MessageLoopProxy::current(), |
968 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, | 983 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, |
969 weak_factory_.GetWeakPtr())); | 984 weak_factory_.GetWeakPtr())); |
970 return true; | 985 return true; |
971 } | 986 } |
972 } | 987 } |
973 #endif | 988 #endif |
OLD | NEW |