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

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

Issue 7037027: Fixes Issues #5751 & #22631: NPObject identity (Closed)
Patch Set: hopefully added base url Created 9 years, 7 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
« no previous file with comments | « content/plugin/npobject_proxy.cc ('k') | content/plugin/npobject_util.cc » ('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) 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/plugin/npobject_stub.h" 5 #include "content/plugin/npobject_stub.h"
6 6
7 #include "content/common/content_client.h" 7 #include "content/common/content_client.h"
8 #include "content/common/plugin_messages.h" 8 #include "content/common/plugin_messages.h"
9 #include "content/plugin/npobject_util.h" 9 #include "content/plugin/npobject_util.h"
10 #include "content/plugin/plugin_channel_base.h" 10 #include "content/plugin/plugin_channel_base.h"
11 #include "content/plugin/plugin_thread.h" 11 #include "content/plugin/plugin_thread.h"
12 #include "third_party/npapi/bindings/npapi.h" 12 #include "third_party/npapi/bindings/npapi.h"
13 #include "third_party/npapi/bindings/npruntime.h" 13 #include "third_party/npapi/bindings/npruntime.h"
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h"
15 #include "webkit/plugins/npapi/plugin_constants_win.h" 15 #include "webkit/plugins/npapi/plugin_constants_win.h"
16 16
17 using WebKit::WebBindings; 17 using WebKit::WebBindings;
18 18
19 NPObjectStub::NPObjectStub( 19 NPObjectStub::NPObjectStub(
20 NPObject* npobject, 20 NPObject* npobject,
21 PluginChannelBase* channel, 21 PluginChannelBase* channel,
22 int route_id, 22 int route_id,
23 gfx::NativeViewId containing_window, 23 gfx::NativeViewId containing_window,
24 const GURL& page_url) 24 const GURL& page_url)
25 : npobject_(npobject), 25 : npobject_(npobject),
26 channel_(channel), 26 channel_(channel),
27 route_id_(route_id), 27 route_id_(route_id),
28 containing_window_(containing_window), 28 containing_window_(containing_window),
29 page_url_(page_url) { 29 page_url_(page_url) {
30 channel_->AddMappingForNPObjectStub(route_id, npobject);
30 channel_->AddRoute(route_id, this, this); 31 channel_->AddRoute(route_id, this, this);
31 32
32 // We retain the object just as PluginHost does if everything was in-process. 33 // We retain the object just as PluginHost does if everything was in-process.
33 WebBindings::retainObject(npobject_); 34 WebBindings::retainObject(npobject_);
34 } 35 }
35 36
36 NPObjectStub::~NPObjectStub() { 37 NPObjectStub::~NPObjectStub() {
37 channel_->RemoveRoute(route_id_); 38 channel_->RemoveRoute(route_id_);
38 if (npobject_) 39 if (npobject_) {
40 channel_->RemoveMappingForNPObjectStub(route_id_, npobject_);
39 WebBindings::releaseObject(npobject_); 41 WebBindings::releaseObject(npobject_);
42 }
40 } 43 }
41 44
42 bool NPObjectStub::Send(IPC::Message* msg) { 45 bool NPObjectStub::Send(IPC::Message* msg) {
43 return channel_->Send(msg); 46 return channel_->Send(msg);
44 } 47 }
45 48
46 void NPObjectStub::OnPluginDestroyed() { 49 void NPObjectStub::OnPluginDestroyed() {
50 channel_->RemoveMappingForNPObjectStub(route_id_, npobject_);
47 // We null out the underlying NPObject pointer since it's not valid anymore ( 51 // We null out the underlying NPObject pointer since it's not valid anymore (
48 // ScriptController manually deleted the object). As a result, 52 // ScriptController manually deleted the object). As a result,
49 // OnMessageReceived won't dispatch any more messages. Since this includes 53 // OnMessageReceived won't dispatch any more messages. Since this includes
50 // OnRelease, this object won't get deleted until OnChannelError which might 54 // OnRelease, this object won't get deleted until OnChannelError which might
51 // not happen for a long time if this renderer process has a long lived 55 // not happen for a long time if this renderer process has a long lived
52 // plugin instance to the same process. So we delete this object manually. 56 // plugin instance to the same process. So we delete this object manually.
53 npobject_ = NULL; 57 npobject_ = NULL;
54 MessageLoop::current()->DeleteSoon(FROM_HERE, this); 58 MessageLoop::current()->DeleteSoon(FROM_HERE, this);
55 } 59 }
56 60
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 bool return_value = WebBindings::evaluateHelper(0, popups_allowed, npobject_, 397 bool return_value = WebBindings::evaluateHelper(0, popups_allowed, npobject_,
394 &script_string, &result_var); 398 &script_string, &result_var);
395 399
396 NPVariant_Param result_param; 400 NPVariant_Param result_param;
397 CreateNPVariantParam( 401 CreateNPVariantParam(
398 result_var, local_channel, &result_param, true, containing_window_, 402 result_var, local_channel, &result_param, true, containing_window_,
399 page_url_); 403 page_url_);
400 NPObjectMsg_Evaluate::WriteReplyParams(reply_msg, result_param, return_value); 404 NPObjectMsg_Evaluate::WriteReplyParams(reply_msg, result_param, return_value);
401 local_channel->Send(reply_msg); 405 local_channel->Send(reply_msg);
402 } 406 }
OLDNEW
« no previous file with comments | « content/plugin/npobject_proxy.cc ('k') | content/plugin/npobject_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698