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 "content/plugin/plugin_channel.h" | 5 #include "content/plugin/plugin_channel.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
11 #include "base/synchronization/lock.h" | 11 #include "base/synchronization/lock.h" |
12 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 #include "content/child/child_process.h" | 14 #include "content/child/child_process.h" |
15 #include "content/child/plugin_messages.h" | 15 #include "content/child/plugin_messages.h" |
16 #include "content/common/plugin_process_messages.h" | 16 #include "content/common/plugin_process_messages.h" |
17 #include "content/plugin/plugin_thread.h" | 17 #include "content/plugin/plugin_thread.h" |
18 #include "content/plugin/webplugin_delegate_stub.h" | 18 #include "content/plugin/webplugin_delegate_stub.h" |
19 #include "content/plugin/webplugin_proxy.h" | 19 #include "content/plugin/webplugin_proxy.h" |
20 #include "content/public/common/content_switches.h" | 20 #include "content/public/common/content_switches.h" |
| 21 #include "third_party/WebKit/public/web/WebBindings.h" |
21 #include "webkit/plugins/npapi/plugin_instance.h" | 22 #include "webkit/plugins/npapi/plugin_instance.h" |
22 | 23 |
23 #if defined(OS_POSIX) | 24 #if defined(OS_POSIX) |
24 #include "base/posix/eintr_wrapper.h" | 25 #include "base/posix/eintr_wrapper.h" |
25 #include "ipc/ipc_channel_posix.h" | 26 #include "ipc/ipc_channel_posix.h" |
26 #endif | 27 #endif |
27 | 28 |
| 29 using WebKit::WebBindings; |
| 30 |
28 namespace content { | 31 namespace content { |
29 | 32 |
30 namespace { | 33 namespace { |
31 | 34 |
32 void PluginReleaseCallback() { | 35 void PluginReleaseCallback() { |
33 ChildProcess::current()->ReleaseProcess(); | 36 ChildProcess::current()->ReleaseProcess(); |
34 } | 37 } |
35 | 38 |
36 // How long we wait before releasing the plugin process. | 39 // How long we wait before releasing the plugin process. |
37 const int kPluginReleaseTimeMinutes = 5; | 40 const int kPluginReleaseTimeMinutes = 5; |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 return false; | 233 return false; |
231 | 234 |
232 channel_->AddFilter(filter_.get()); | 235 channel_->AddFilter(filter_.get()); |
233 return true; | 236 return true; |
234 } | 237 } |
235 | 238 |
236 PluginChannel::PluginChannel() | 239 PluginChannel::PluginChannel() |
237 : renderer_id_(-1), | 240 : renderer_id_(-1), |
238 in_send_(0), | 241 in_send_(0), |
239 incognito_(false), | 242 incognito_(false), |
240 filter_(new MessageFilter()) { | 243 filter_(new MessageFilter()), |
| 244 npp_(new struct _NPP) { |
241 set_send_unblocking_only_during_unblock_dispatch(); | 245 set_send_unblocking_only_during_unblock_dispatch(); |
242 ChildProcess::current()->AddRefProcess(); | 246 ChildProcess::current()->AddRefProcess(); |
243 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 247 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
244 log_messages_ = command_line->HasSwitch(switches::kLogPluginMessages); | 248 log_messages_ = command_line->HasSwitch(switches::kLogPluginMessages); |
| 249 |
| 250 // Register |npp_| as the default owner for any object we receive via IPC, |
| 251 // and register it with WebBindings as a valid owner. |
| 252 SetDefaultNPObjectOwner(npp_.get()); |
| 253 WebBindings::registerObjectOwner(npp_.get()); |
245 } | 254 } |
246 | 255 |
247 bool PluginChannel::OnControlMessageReceived(const IPC::Message& msg) { | 256 bool PluginChannel::OnControlMessageReceived(const IPC::Message& msg) { |
248 bool handled = true; | 257 bool handled = true; |
249 IPC_BEGIN_MESSAGE_MAP(PluginChannel, msg) | 258 IPC_BEGIN_MESSAGE_MAP(PluginChannel, msg) |
250 IPC_MESSAGE_HANDLER(PluginMsg_CreateInstance, OnCreateInstance) | 259 IPC_MESSAGE_HANDLER(PluginMsg_CreateInstance, OnCreateInstance) |
251 IPC_MESSAGE_HANDLER_DELAY_REPLY(PluginMsg_DestroyInstance, | 260 IPC_MESSAGE_HANDLER_DELAY_REPLY(PluginMsg_DestroyInstance, |
252 OnDestroyInstance) | 261 OnDestroyInstance) |
253 IPC_MESSAGE_HANDLER(PluginMsg_GenerateRouteID, OnGenerateRouteID) | 262 IPC_MESSAGE_HANDLER(PluginMsg_GenerateRouteID, OnGenerateRouteID) |
254 IPC_MESSAGE_HANDLER(PluginProcessMsg_ClearSiteData, OnClearSiteData) | 263 IPC_MESSAGE_HANDLER(PluginProcessMsg_ClearSiteData, OnClearSiteData) |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 : base::StringPrintf("\"%s\"", site_str); | 324 : base::StringPrintf("\"%s\"", site_str); |
316 VLOG(1) << "NPP_ClearSiteData(" << site_name << ", " << flags << ", " | 325 VLOG(1) << "NPP_ClearSiteData(" << site_name << ", " << flags << ", " |
317 << max_age << ") returned " << err; | 326 << max_age << ") returned " << err; |
318 success = (err == NPERR_NO_ERROR); | 327 success = (err == NPERR_NO_ERROR); |
319 } | 328 } |
320 } | 329 } |
321 Send(new PluginProcessHostMsg_ClearSiteDataResult(success)); | 330 Send(new PluginProcessHostMsg_ClearSiteDataResult(success)); |
322 } | 331 } |
323 | 332 |
324 } // namespace content | 333 } // namespace content |
OLD | NEW |