Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/ppapi_plugin_process_host.h" | 5 #include "content/browser/ppapi_plugin_process_host.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
| 12 #include "chrome/common/render_messages.h" | 12 #include "chrome/common/render_messages.h" |
| 13 #include "content/browser/plugin_service.h" | 13 #include "content/browser/plugin_service.h" |
| 14 #include "content/browser/renderer_host/render_message_filter.h" | 14 #include "content/browser/renderer_host/render_message_filter.h" |
| 15 #include "content/common/pepper_plugin_registry.h" | 15 #include "content/common/pepper_plugin_registry.h" |
| 16 #include "ipc/ipc_switches.h" | 16 #include "ipc/ipc_switches.h" |
| 17 #include "ppapi/proxy/ppapi_messages.h" | 17 #include "ppapi/proxy/ppapi_messages.h" |
| 18 | 18 |
| 19 PpapiPluginProcessHost::PpapiPluginProcessHost() | 19 PpapiPluginProcessHost::PpapiPluginProcessHost(net::HostResolver* host_resolver) |
| 20 : BrowserChildProcessHost(ChildProcessInfo::PPAPI_PLUGIN_PROCESS) { | 20 : BrowserChildProcessHost(ChildProcessInfo::PPAPI_PLUGIN_PROCESS), |
| 21 filter_(new PepperMessageFilter(host_resolver)) { | |
| 22 AddFilter(filter_.get()); | |
| 21 } | 23 } |
| 22 | 24 |
| 23 PpapiPluginProcessHost::~PpapiPluginProcessHost() { | 25 PpapiPluginProcessHost::~PpapiPluginProcessHost() { |
| 24 CancelRequests(); | 26 CancelRequests(); |
| 25 } | 27 } |
| 26 | 28 |
| 27 bool PpapiPluginProcessHost::Init(const PepperPluginInfo& info) { | 29 bool PpapiPluginProcessHost::Init(const PepperPluginInfo& info) { |
| 28 plugin_path_ = info.path; | 30 plugin_path_ = info.path; |
| 29 set_name(UTF8ToWide(info.name)); | 31 set_name(UTF8ToWide(info.name)); |
| 30 set_version(UTF8ToWide(info.version)); | 32 set_version(UTF8ToWide(info.version)); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 } | 102 } |
| 101 | 103 |
| 102 bool PpapiPluginProcessHost::CanShutdown() { | 104 bool PpapiPluginProcessHost::CanShutdown() { |
| 103 return true; | 105 return true; |
| 104 } | 106 } |
| 105 | 107 |
| 106 void PpapiPluginProcessHost::OnProcessLaunched() { | 108 void PpapiPluginProcessHost::OnProcessLaunched() { |
| 107 } | 109 } |
| 108 | 110 |
| 109 bool PpapiPluginProcessHost::OnMessageReceived(const IPC::Message& msg) { | 111 bool PpapiPluginProcessHost::OnMessageReceived(const IPC::Message& msg) { |
| 112 // Some messages are handled by the filter. | |
| 113 /* | |
|
viettrungluu
2011/05/18 20:40:43
?
| |
| 114 bool message_was_ok = false; | |
| 115 if (filter_.OnMessageReceived(msg, &message_was_ok)) | |
| 116 return true; | |
| 117 */ | |
| 118 | |
| 110 bool handled = true; | 119 bool handled = true; |
| 111 IPC_BEGIN_MESSAGE_MAP(PpapiPluginProcessHost, msg) | 120 IPC_BEGIN_MESSAGE_MAP(PpapiPluginProcessHost, msg) |
| 112 IPC_MESSAGE_HANDLER(PpapiHostMsg_ChannelCreated, | 121 IPC_MESSAGE_HANDLER(PpapiHostMsg_ChannelCreated, |
| 113 OnRendererPluginChannelCreated) | 122 OnRendererPluginChannelCreated) |
| 114 IPC_MESSAGE_UNHANDLED(handled = false) | 123 IPC_MESSAGE_UNHANDLED(handled = false) |
| 115 IPC_END_MESSAGE_MAP() | 124 IPC_END_MESSAGE_MAP() |
| 116 DCHECK(handled); | 125 DCHECK(handled); |
| 117 return handled; | 126 return handled; |
| 118 } | 127 } |
| 119 | 128 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 ::DuplicateHandle(::GetCurrentProcess(), plugin_process, | 185 ::DuplicateHandle(::GetCurrentProcess(), plugin_process, |
| 177 renderer_process, &renderers_plugin_handle, | 186 renderer_process, &renderers_plugin_handle, |
| 178 0, FALSE, DUPLICATE_SAME_ACCESS); | 187 0, FALSE, DUPLICATE_SAME_ACCESS); |
| 179 #elif defined(OS_POSIX) | 188 #elif defined(OS_POSIX) |
| 180 // Don't need to duplicate anything on POSIX since it's just a PID. | 189 // Don't need to duplicate anything on POSIX since it's just a PID. |
| 181 base::ProcessHandle renderers_plugin_handle = plugin_process; | 190 base::ProcessHandle renderers_plugin_handle = plugin_process; |
| 182 #endif | 191 #endif |
| 183 | 192 |
| 184 client->OnChannelOpened(renderers_plugin_handle, channel_handle); | 193 client->OnChannelOpened(renderers_plugin_handle, channel_handle); |
| 185 } | 194 } |
| OLD | NEW |