| 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 "chrome/plugin/webplugin_delegate_stub.h" | 5 #include "chrome/plugin/webplugin_delegate_stub.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "chrome/common/child_process_logging.h" | |
| 11 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
| 12 #include "chrome/plugin/npobject_stub.h" | 11 #include "chrome/plugin/npobject_stub.h" |
| 13 #include "chrome/plugin/plugin_channel.h" | 12 #include "chrome/plugin/plugin_channel.h" |
| 14 #include "chrome/plugin/plugin_thread.h" | 13 #include "chrome/plugin/plugin_thread.h" |
| 15 #include "chrome/plugin/webplugin_proxy.h" | 14 #include "chrome/plugin/webplugin_proxy.h" |
| 15 #include "content/common/content_client.h" |
| 16 #include "content/common/plugin_messages.h" | 16 #include "content/common/plugin_messages.h" |
| 17 #include "third_party/npapi/bindings/npapi.h" | 17 #include "third_party/npapi/bindings/npapi.h" |
| 18 #include "third_party/npapi/bindings/npruntime.h" | 18 #include "third_party/npapi/bindings/npruntime.h" |
| 19 #include "skia/ext/platform_device.h" | 19 #include "skia/ext/platform_device.h" |
| 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" |
| 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" |
| 22 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" | 22 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" |
| 23 #include "webkit/glue/webcursor.h" | 23 #include "webkit/glue/webcursor.h" |
| 24 | 24 |
| 25 #if defined(OS_WIN) | 25 #if defined(OS_WIN) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 instance_id_(instance_id), | 59 instance_id_(instance_id), |
| 60 channel_(channel), | 60 channel_(channel), |
| 61 delegate_(NULL), | 61 delegate_(NULL), |
| 62 webplugin_(NULL), | 62 webplugin_(NULL), |
| 63 in_destructor_(false) { | 63 in_destructor_(false) { |
| 64 DCHECK(channel); | 64 DCHECK(channel); |
| 65 } | 65 } |
| 66 | 66 |
| 67 WebPluginDelegateStub::~WebPluginDelegateStub() { | 67 WebPluginDelegateStub::~WebPluginDelegateStub() { |
| 68 in_destructor_ = true; | 68 in_destructor_ = true; |
| 69 child_process_logging::SetActiveURL(page_url_); | 69 content::GetContentClient()->SetActiveURL(page_url_); |
| 70 | 70 |
| 71 if (channel_->in_send()) { | 71 if (channel_->in_send()) { |
| 72 // The delegate or an npobject is in the callstack, so don't delete it | 72 // The delegate or an npobject is in the callstack, so don't delete it |
| 73 // right away. | 73 // right away. |
| 74 MessageLoop::current()->PostNonNestableTask(FROM_HERE, | 74 MessageLoop::current()->PostNonNestableTask(FROM_HERE, |
| 75 new FinishDestructionTask(delegate_, webplugin_)); | 75 new FinishDestructionTask(delegate_, webplugin_)); |
| 76 } else { | 76 } else { |
| 77 // Safe to delete right away. | 77 // Safe to delete right away. |
| 78 if (delegate_) | 78 if (delegate_) |
| 79 delegate_->PluginDestroyed(); | 79 delegate_->PluginDestroyed(); |
| 80 | 80 |
| 81 delete webplugin_; | 81 delete webplugin_; |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 | 84 |
| 85 bool WebPluginDelegateStub::OnMessageReceived(const IPC::Message& msg) { | 85 bool WebPluginDelegateStub::OnMessageReceived(const IPC::Message& msg) { |
| 86 child_process_logging::SetActiveURL(page_url_); | 86 content::GetContentClient()->SetActiveURL(page_url_); |
| 87 | 87 |
| 88 // A plugin can execute a script to delete itself in any of its NPP methods. | 88 // A plugin can execute a script to delete itself in any of its NPP methods. |
| 89 // Hold an extra reference to ourself so that if this does occur and we're | 89 // Hold an extra reference to ourself so that if this does occur and we're |
| 90 // handling a sync message, we don't crash when attempting to send a reply. | 90 // handling a sync message, we don't crash when attempting to send a reply. |
| 91 // The exception to this is when we're already in the destructor. | 91 // The exception to this is when we're already in the destructor. |
| 92 if (!in_destructor_) | 92 if (!in_destructor_) |
| 93 AddRef(); | 93 AddRef(); |
| 94 | 94 |
| 95 bool handled = true; | 95 bool handled = true; |
| 96 IPC_BEGIN_MESSAGE_MAP(WebPluginDelegateStub, msg) | 96 IPC_BEGIN_MESSAGE_MAP(WebPluginDelegateStub, msg) |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 return handled; | 147 return handled; |
| 148 } | 148 } |
| 149 | 149 |
| 150 bool WebPluginDelegateStub::Send(IPC::Message* msg) { | 150 bool WebPluginDelegateStub::Send(IPC::Message* msg) { |
| 151 return channel_->Send(msg); | 151 return channel_->Send(msg); |
| 152 } | 152 } |
| 153 | 153 |
| 154 void WebPluginDelegateStub::OnInit(const PluginMsg_Init_Params& params, | 154 void WebPluginDelegateStub::OnInit(const PluginMsg_Init_Params& params, |
| 155 bool* result) { | 155 bool* result) { |
| 156 page_url_ = params.page_url; | 156 page_url_ = params.page_url; |
| 157 child_process_logging::SetActiveURL(page_url_); | 157 content::GetContentClient()->SetActiveURL(page_url_); |
| 158 | 158 |
| 159 *result = false; | 159 *result = false; |
| 160 if (params.arg_names.size() != params.arg_values.size()) { | 160 if (params.arg_names.size() != params.arg_values.size()) { |
| 161 NOTREACHED(); | 161 NOTREACHED(); |
| 162 return; | 162 return; |
| 163 } | 163 } |
| 164 | 164 |
| 165 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 165 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 166 FilePath path = | 166 FilePath path = |
| 167 command_line.GetSwitchValuePath(switches::kPluginPath); | 167 command_line.GetSwitchValuePath(switches::kPluginPath); |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 webplugin_->OnResourceCreated(resource_id, resource_client); | 442 webplugin_->OnResourceCreated(resource_id, resource_client); |
| 443 } | 443 } |
| 444 | 444 |
| 445 #if defined(OS_MACOSX) | 445 #if defined(OS_MACOSX) |
| 446 void WebPluginDelegateStub::OnSetFakeAcceleratedSurfaceWindowHandle( | 446 void WebPluginDelegateStub::OnSetFakeAcceleratedSurfaceWindowHandle( |
| 447 gfx::PluginWindowHandle window) { | 447 gfx::PluginWindowHandle window) { |
| 448 delegate_->set_windowed_handle(window); | 448 delegate_->set_windowed_handle(window); |
| 449 } | 449 } |
| 450 #endif | 450 #endif |
| 451 | 451 |
| OLD | NEW |