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

Side by Side Diff: content/renderer/browser_plugin/browser_plugin.cc

Issue 15007012: Track NPObject ownership by the originating plugins' NPP identifier. [2/3] (Chrome) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add missing includes. Created 7 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 | Annotate | Revision Log
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/renderer/browser_plugin/browser_plugin.h" 5 #include "content/renderer/browser_plugin/browser_plugin.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/json/json_string_value_serializer.h" 8 #include "base/json/json_string_value_serializer.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1130 RespondPermissionIfRequestIsPending(request_id, allow); 1130 RespondPermissionIfRequestIsPending(request_id, allow);
1131 } 1131 }
1132 1132
1133 bool BrowserPlugin::initialize(WebPluginContainer* container) { 1133 bool BrowserPlugin::initialize(WebPluginContainer* container) {
1134 if (!container) 1134 if (!container)
1135 return false; 1135 return false;
1136 1136
1137 if (!GetContentClient()->renderer()->AllowBrowserPlugin(container)) 1137 if (!GetContentClient()->renderer()->AllowBrowserPlugin(container))
1138 return false; 1138 return false;
1139 1139
1140 // Tell |container| to allow this plugin to use script objects.
Fady Samuel 2013/05/15 23:21:15 Does webview.contentWindow work without this worka
Wez 2013/05/16 18:27:16 It will do once patch [3/3] has landed in Blink, y
1141 container->allowScriptObjects();
1142
1140 bindings_.reset(new BrowserPluginBindings(this)); 1143 bindings_.reset(new BrowserPluginBindings(this));
1141 container_ = container; 1144 container_ = container;
1142 container_->setWantsWheelEvents(true); 1145 container_->setWantsWheelEvents(true);
1143 ParseAttributes(); 1146 ParseAttributes();
1144 g_plugin_container_map.Get().insert(std::make_pair(container_, this)); 1147 g_plugin_container_map.Get().insert(std::make_pair(container_, this));
1145 return true; 1148 return true;
1146 } 1149 }
1147 1150
1148 void BrowserPlugin::EnableCompositing(bool enable) { 1151 void BrowserPlugin::EnableCompositing(bool enable) {
1149 if (compositing_enabled_ == enable) 1152 if (compositing_enabled_ == enable)
(...skipping 23 matching lines...) Expand all
1173 resize_ack_received_ = false; 1176 resize_ack_received_ = false;
1174 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ResizeGuest( 1177 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ResizeGuest(
1175 render_view_routing_id_, 1178 render_view_routing_id_,
1176 instance_id_, 1179 instance_id_,
1177 params)); 1180 params));
1178 } 1181 }
1179 compositing_helper_->EnableCompositing(enable); 1182 compositing_helper_->EnableCompositing(enable);
1180 } 1183 }
1181 1184
1182 void BrowserPlugin::destroy() { 1185 void BrowserPlugin::destroy() {
1186 // Tell |container_| to clear references to this plugin's script objects.
1187 container_->clearScriptObjects();
1188
1183 // The BrowserPlugin's WebPluginContainer is deleted immediately after this 1189 // The BrowserPlugin's WebPluginContainer is deleted immediately after this
1184 // call returns, so let's not keep a reference to it around. 1190 // call returns, so let's not keep a reference to it around.
1185 g_plugin_container_map.Get().erase(container_); 1191 g_plugin_container_map.Get().erase(container_);
1186 container_ = NULL; 1192 container_ = NULL;
1187 if (compositing_helper_) 1193 if (compositing_helper_)
1188 compositing_helper_->OnContainerDestroy(); 1194 compositing_helper_->OnContainerDestroy();
1189 // Will be a no-op if the mouse is not currently locked. 1195 // Will be a no-op if the mouse is not currently locked.
1190 if (render_view_) 1196 if (render_view_)
1191 render_view_->mouse_lock_dispatcher()->OnLockTargetDestroyed(this); 1197 render_view_->mouse_lock_dispatcher()->OnLockTargetDestroyed(this);
1192 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); 1198 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
1193 } 1199 }
1194 1200
1195 NPObject* BrowserPlugin::scriptableObject() { 1201 NPObject* BrowserPlugin::scriptableObject() {
1196 if (!bindings_) 1202 if (!bindings_)
1197 return NULL; 1203 return NULL;
1198 1204
1199 NPObject* browser_plugin_np_object(bindings_->np_object()); 1205 NPObject* browser_plugin_np_object(bindings_->np_object());
1200 // The object is expected to be retained before it is returned. 1206 // The object is expected to be retained before it is returned.
1201 WebKit::WebBindings::retainObject(browser_plugin_np_object); 1207 WebKit::WebBindings::retainObject(browser_plugin_np_object);
1202 return browser_plugin_np_object; 1208 return browser_plugin_np_object;
1203 } 1209 }
1204 1210
1211 NPP BrowserPlugin::pluginNPP() {
1212 // We must return the same pointer that the NPP parameter to NPObject binding
1213 // calls will contain. WebKit will treat it as opaque, though, so it needn't
1214 // be an actual NPP_t instance.
1215 return reinterpret_cast<NPP>(this);
1216 }
1217
1205 bool BrowserPlugin::supportsKeyboardFocus() const { 1218 bool BrowserPlugin::supportsKeyboardFocus() const {
1206 return true; 1219 return true;
1207 } 1220 }
1208 1221
1209 bool BrowserPlugin::canProcessDrag() const { 1222 bool BrowserPlugin::canProcessDrag() const {
1210 return true; 1223 return true;
1211 } 1224 }
1212 1225
1213 void BrowserPlugin::paint(WebCanvas* canvas, const WebRect& rect) { 1226 void BrowserPlugin::paint(WebCanvas* canvas, const WebRect& rect) {
1214 if (guest_crashed_) { 1227 if (guest_crashed_) {
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
1553 const WebKit::WebMouseEvent& event) { 1566 const WebKit::WebMouseEvent& event) {
1554 browser_plugin_manager()->Send( 1567 browser_plugin_manager()->Send(
1555 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, 1568 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_,
1556 instance_id_, 1569 instance_id_,
1557 plugin_rect_, 1570 plugin_rect_,
1558 &event)); 1571 &event));
1559 return true; 1572 return true;
1560 } 1573 }
1561 1574
1562 } // namespace content 1575 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698