Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1636)

Side by Side Diff: content/plugin/webplugin_delegate_stub.cc

Issue 11231016: Move content's a plugin, ppapi_plugin, utility, and worker subdirectories to the content namespace. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix mac Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/plugin/webplugin_delegate_stub.h ('k') | content/plugin/webplugin_proxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/webplugin_delegate_stub.h" 5 #include "content/plugin/webplugin_delegate_stub.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 11 matching lines...) Expand all
22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h"
23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h"
24 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" 24 #include "webkit/plugins/npapi/webplugin_delegate_impl.h"
25 #include "webkit/glue/webcursor.h" 25 #include "webkit/glue/webcursor.h"
26 26
27 using WebKit::WebBindings; 27 using WebKit::WebBindings;
28 using WebKit::WebCursorInfo; 28 using WebKit::WebCursorInfo;
29 using webkit::npapi::WebPlugin; 29 using webkit::npapi::WebPlugin;
30 using webkit::npapi::WebPluginResourceClient; 30 using webkit::npapi::WebPluginResourceClient;
31 31
32 namespace content {
33
32 static void DestroyWebPluginAndDelegate( 34 static void DestroyWebPluginAndDelegate(
33 base::WeakPtr<NPObjectStub> scriptable_object, 35 base::WeakPtr<NPObjectStub> scriptable_object,
34 webkit::npapi::WebPluginDelegateImpl* delegate, 36 webkit::npapi::WebPluginDelegateImpl* delegate,
35 WebPlugin* webplugin) { 37 WebPlugin* webplugin) {
36 // The plugin may not expect us to try to release the scriptable object 38 // The plugin may not expect us to try to release the scriptable object
37 // after calling NPP_Destroy on the instance, so delete the stub now. 39 // after calling NPP_Destroy on the instance, so delete the stub now.
38 if (scriptable_object.get()) 40 if (scriptable_object.get())
39 scriptable_object->DeleteSoon(); 41 scriptable_object->DeleteSoon();
40 // WebPlugin must outlive WebPluginDelegate. 42 // WebPlugin must outlive WebPluginDelegate.
41 if (delegate) 43 if (delegate)
42 delegate->PluginDestroyed(); 44 delegate->PluginDestroyed();
43 45
44 delete webplugin; 46 delete webplugin;
45 } 47 }
46 48
47 WebPluginDelegateStub::WebPluginDelegateStub( 49 WebPluginDelegateStub::WebPluginDelegateStub(
48 const std::string& mime_type, int instance_id, PluginChannel* channel) : 50 const std::string& mime_type, int instance_id, PluginChannel* channel) :
49 mime_type_(mime_type), 51 mime_type_(mime_type),
50 instance_id_(instance_id), 52 instance_id_(instance_id),
51 channel_(channel), 53 channel_(channel),
52 delegate_(NULL), 54 delegate_(NULL),
53 webplugin_(NULL), 55 webplugin_(NULL),
54 in_destructor_(false) { 56 in_destructor_(false) {
55 DCHECK(channel); 57 DCHECK(channel);
56 } 58 }
57 59
58 WebPluginDelegateStub::~WebPluginDelegateStub() { 60 WebPluginDelegateStub::~WebPluginDelegateStub() {
59 in_destructor_ = true; 61 in_destructor_ = true;
60 content::GetContentClient()->SetActiveURL(page_url_); 62 GetContentClient()->SetActiveURL(page_url_);
61 63
62 if (channel_->in_send()) { 64 if (channel_->in_send()) {
63 // The delegate or an npobject is in the callstack, so don't delete it 65 // The delegate or an npobject is in the callstack, so don't delete it
64 // right away. 66 // right away.
65 MessageLoop::current()->PostNonNestableTask(FROM_HERE, 67 MessageLoop::current()->PostNonNestableTask(FROM_HERE,
66 base::Bind(&DestroyWebPluginAndDelegate, plugin_scriptable_object_, 68 base::Bind(&DestroyWebPluginAndDelegate, plugin_scriptable_object_,
67 delegate_, webplugin_)); 69 delegate_, webplugin_));
68 } else { 70 } else {
69 // Safe to delete right away. 71 // Safe to delete right away.
70 DestroyWebPluginAndDelegate( 72 DestroyWebPluginAndDelegate(
71 plugin_scriptable_object_, delegate_, webplugin_); 73 plugin_scriptable_object_, delegate_, webplugin_);
72 } 74 }
73 } 75 }
74 76
75 bool WebPluginDelegateStub::OnMessageReceived(const IPC::Message& msg) { 77 bool WebPluginDelegateStub::OnMessageReceived(const IPC::Message& msg) {
76 content::GetContentClient()->SetActiveURL(page_url_); 78 GetContentClient()->SetActiveURL(page_url_);
77 79
78 // A plugin can execute a script to delete itself in any of its NPP methods. 80 // A plugin can execute a script to delete itself in any of its NPP methods.
79 // Hold an extra reference to ourself so that if this does occur and we're 81 // Hold an extra reference to ourself so that if this does occur and we're
80 // handling a sync message, we don't crash when attempting to send a reply. 82 // handling a sync message, we don't crash when attempting to send a reply.
81 // The exception to this is when we're already in the destructor. 83 // The exception to this is when we're already in the destructor.
82 if (!in_destructor_) 84 if (!in_destructor_)
83 AddRef(); 85 AddRef();
84 86
85 bool handled = true; 87 bool handled = true;
86 IPC_BEGIN_MESSAGE_MAP(WebPluginDelegateStub, msg) 88 IPC_BEGIN_MESSAGE_MAP(WebPluginDelegateStub, msg)
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 return handled; 144 return handled;
143 } 145 }
144 146
145 bool WebPluginDelegateStub::Send(IPC::Message* msg) { 147 bool WebPluginDelegateStub::Send(IPC::Message* msg) {
146 return channel_->Send(msg); 148 return channel_->Send(msg);
147 } 149 }
148 150
149 void WebPluginDelegateStub::OnInit(const PluginMsg_Init_Params& params, 151 void WebPluginDelegateStub::OnInit(const PluginMsg_Init_Params& params,
150 bool* result) { 152 bool* result) {
151 page_url_ = params.page_url; 153 page_url_ = params.page_url;
152 content::GetContentClient()->SetActiveURL(page_url_); 154 GetContentClient()->SetActiveURL(page_url_);
153 155
154 *result = false; 156 *result = false;
155 if (params.arg_names.size() != params.arg_values.size()) { 157 if (params.arg_names.size() != params.arg_values.size()) {
156 NOTREACHED(); 158 NOTREACHED();
157 return; 159 return;
158 } 160 }
159 161
160 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 162 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
161 FilePath path = 163 FilePath path =
162 command_line.GetSwitchValuePath(switches::kPluginPath); 164 command_line.GetSwitchValuePath(switches::kPluginPath);
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 delegate_->CreateSeekableResourceClient(resource_id, range_request_id); 414 delegate_->CreateSeekableResourceClient(resource_id, range_request_id);
413 webplugin_->OnResourceCreated(resource_id, resource_client); 415 webplugin_->OnResourceCreated(resource_id, resource_client);
414 } 416 }
415 417
416 #if defined(OS_MACOSX) 418 #if defined(OS_MACOSX)
417 void WebPluginDelegateStub::OnSetFakeAcceleratedSurfaceWindowHandle( 419 void WebPluginDelegateStub::OnSetFakeAcceleratedSurfaceWindowHandle(
418 gfx::PluginWindowHandle window) { 420 gfx::PluginWindowHandle window) {
419 delegate_->set_windowed_handle(window); 421 delegate_->set_windowed_handle(window);
420 } 422 }
421 #endif 423 #endif
424
425 } // namespace content
OLDNEW
« no previous file with comments | « content/plugin/webplugin_delegate_stub.h ('k') | content/plugin/webplugin_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698