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/common/npobject_proxy.h" | 5 #include "content/common/npobject_proxy.h" |
6 | 6 |
7 #include "content/common/np_channel_base.h" | 7 #include "content/common/np_channel_base.h" |
8 #include "content/common/npobject_util.h" | 8 #include "content/common/npobject_util.h" |
9 #include "content/common/plugin_messages.h" | 9 #include "content/common/plugin_messages.h" |
10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" | 10 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 int render_view_id, | 63 int render_view_id, |
64 const GURL& page_url) | 64 const GURL& page_url) |
65 : channel_(channel), | 65 : channel_(channel), |
66 route_id_(route_id), | 66 route_id_(route_id), |
67 render_view_id_(render_view_id), | 67 render_view_id_(render_view_id), |
68 page_url_(page_url) { | 68 page_url_(page_url) { |
69 channel_->AddRoute(route_id, this, this); | 69 channel_->AddRoute(route_id, this, this); |
70 } | 70 } |
71 | 71 |
72 NPObjectProxy::~NPObjectProxy() { | 72 NPObjectProxy::~NPObjectProxy() { |
73 if (channel_.get()) { | 73 if (channel_) { |
74 // This NPObjectProxy instance is now invalid and should not be reused for | 74 // This NPObjectProxy instance is now invalid and should not be reused for |
75 // requests initiated by plugins. We may receive requests for the | 75 // requests initiated by plugins. We may receive requests for the |
76 // same NPObject in the context of the outgoing NPObjectMsg_Release call. | 76 // same NPObject in the context of the outgoing NPObjectMsg_Release call. |
77 // We should be creating new NPObjectProxy instances to wrap these | 77 // We should be creating new NPObjectProxy instances to wrap these |
78 // NPObjects. | 78 // NPObjects. |
79 channel_->RemoveMappingForNPObjectProxy(route_id_); | 79 channel_->RemoveMappingForNPObjectProxy(route_id_); |
80 channel_->RemoveRoute(route_id_); | 80 channel_->RemoveRoute(route_id_); |
81 Send(new NPObjectMsg_Release(route_id_)); | 81 Send(new NPObjectMsg_Release(route_id_)); |
82 } | 82 } |
83 } | 83 } |
84 | 84 |
85 NPObject* NPObjectProxy::Create(NPChannelBase* channel, | 85 NPObject* NPObjectProxy::Create(NPChannelBase* channel, |
86 int route_id, | 86 int route_id, |
87 int render_view_id, | 87 int render_view_id, |
88 const GURL& page_url) { | 88 const GURL& page_url) { |
89 NPObjectWrapper* obj = reinterpret_cast<NPObjectWrapper*>( | 89 NPObjectWrapper* obj = reinterpret_cast<NPObjectWrapper*>( |
90 WebBindings::createObject(0, &npclass_proxy_)); | 90 WebBindings::createObject(0, &npclass_proxy_)); |
91 obj->proxy = new NPObjectProxy(channel, route_id, render_view_id, page_url); | 91 obj->proxy = new NPObjectProxy(channel, route_id, render_view_id, page_url); |
92 channel->AddMappingForNPObjectProxy(route_id, &obj->object); | 92 channel->AddMappingForNPObjectProxy(route_id, &obj->object); |
93 return reinterpret_cast<NPObject*>(obj); | 93 return reinterpret_cast<NPObject*>(obj); |
94 } | 94 } |
95 | 95 |
96 bool NPObjectProxy::Send(IPC::Message* msg) { | 96 bool NPObjectProxy::Send(IPC::Message* msg) { |
97 if (channel_.get()) | 97 if (channel_) |
98 return channel_->Send(msg); | 98 return channel_->Send(msg); |
99 | 99 |
100 delete msg; | 100 delete msg; |
101 return false; | 101 return false; |
102 } | 102 } |
103 | 103 |
104 NPObject* NPObjectProxy::NPAllocate(NPP, NPClass*) { | 104 NPObject* NPObjectProxy::NPAllocate(NPP, NPClass*) { |
105 return reinterpret_cast<NPObject*>(new NPObjectWrapper); | 105 return reinterpret_cast<NPObject*>(new NPObjectWrapper); |
106 } | 106 } |
107 | 107 |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 proxy = NULL; | 492 proxy = NULL; |
493 if (!result) | 493 if (!result) |
494 return false; | 494 return false; |
495 | 495 |
496 CreateNPVariant( | 496 CreateNPVariant( |
497 result_param, channel.get(), result_var, render_view_id, page_url); | 497 result_param, channel.get(), result_var, render_view_id, page_url); |
498 return true; | 498 return true; |
499 } | 499 } |
500 | 500 |
501 } // namespace content | 501 } // namespace content |
OLD | NEW |