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

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

Issue 15941006: Track NPObject ownership by the originating plugins' NPP identifier. [2/3] (Chrome) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix CppBoundClass. 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 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 RespondPermissionIfRequestIsPending(request_id, allow); 1131 RespondPermissionIfRequestIsPending(request_id, allow);
1132 } 1132 }
1133 1133
1134 bool BrowserPlugin::initialize(WebPluginContainer* container) { 1134 bool BrowserPlugin::initialize(WebPluginContainer* container) {
1135 if (!container) 1135 if (!container)
1136 return false; 1136 return false;
1137 1137
1138 if (!GetContentClient()->renderer()->AllowBrowserPlugin(container)) 1138 if (!GetContentClient()->renderer()->AllowBrowserPlugin(container))
1139 return false; 1139 return false;
1140 1140
1141 // Tell |container| to allow this plugin to use script objects.
1142 npp_.reset(new NPP_t);
1143 container->allowScriptObjects();
1144
1141 bindings_.reset(new BrowserPluginBindings(this)); 1145 bindings_.reset(new BrowserPluginBindings(this));
1142 container_ = container; 1146 container_ = container;
1143 container_->setWantsWheelEvents(true); 1147 container_->setWantsWheelEvents(true);
1144 ParseAttributes(); 1148 ParseAttributes();
1145 g_plugin_container_map.Get().insert(std::make_pair(container_, this)); 1149 g_plugin_container_map.Get().insert(std::make_pair(container_, this));
1146 return true; 1150 return true;
1147 } 1151 }
1148 1152
1149 void BrowserPlugin::EnableCompositing(bool enable) { 1153 void BrowserPlugin::EnableCompositing(bool enable) {
1150 if (compositing_enabled_ == enable) 1154 if (compositing_enabled_ == enable)
(...skipping 23 matching lines...) Expand all
1174 resize_ack_received_ = false; 1178 resize_ack_received_ = false;
1175 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ResizeGuest( 1179 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ResizeGuest(
1176 render_view_routing_id_, 1180 render_view_routing_id_,
1177 instance_id_, 1181 instance_id_,
1178 params)); 1182 params));
1179 } 1183 }
1180 compositing_helper_->EnableCompositing(enable); 1184 compositing_helper_->EnableCompositing(enable);
1181 } 1185 }
1182 1186
1183 void BrowserPlugin::destroy() { 1187 void BrowserPlugin::destroy() {
1188 // If the plugin was initialized then it has a valid |npp_| identifier, and
1189 // the |container_| must clear references to the plugin's script objects.
1190 DCHECK(!npp_ || container_);
1191 if (container_)
1192 container_->clearScriptObjects();
1193
1184 // The BrowserPlugin's WebPluginContainer is deleted immediately after this 1194 // The BrowserPlugin's WebPluginContainer is deleted immediately after this
1185 // call returns, so let's not keep a reference to it around. 1195 // call returns, so let's not keep a reference to it around.
1186 g_plugin_container_map.Get().erase(container_); 1196 g_plugin_container_map.Get().erase(container_);
1187 container_ = NULL; 1197 container_ = NULL;
1188 if (compositing_helper_) 1198 if (compositing_helper_)
1189 compositing_helper_->OnContainerDestroy(); 1199 compositing_helper_->OnContainerDestroy();
1190 // Will be a no-op if the mouse is not currently locked. 1200 // Will be a no-op if the mouse is not currently locked.
1191 if (render_view_) 1201 if (render_view_)
1192 render_view_->mouse_lock_dispatcher()->OnLockTargetDestroyed(this); 1202 render_view_->mouse_lock_dispatcher()->OnLockTargetDestroyed(this);
1193 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); 1203 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
1194 } 1204 }
1195 1205
1196 NPObject* BrowserPlugin::scriptableObject() { 1206 NPObject* BrowserPlugin::scriptableObject() {
1197 if (!bindings_) 1207 if (!bindings_)
1198 return NULL; 1208 return NULL;
1199 1209
1200 NPObject* browser_plugin_np_object(bindings_->np_object()); 1210 NPObject* browser_plugin_np_object(bindings_->np_object());
1201 // The object is expected to be retained before it is returned. 1211 // The object is expected to be retained before it is returned.
1202 WebKit::WebBindings::retainObject(browser_plugin_np_object); 1212 WebKit::WebBindings::retainObject(browser_plugin_np_object);
1203 return browser_plugin_np_object; 1213 return browser_plugin_np_object;
1204 } 1214 }
1205 1215
1216 NPP BrowserPlugin::pluginNPP() {
1217 return npp_.get();
1218 }
1219
1206 bool BrowserPlugin::supportsKeyboardFocus() const { 1220 bool BrowserPlugin::supportsKeyboardFocus() const {
1207 return true; 1221 return true;
1208 } 1222 }
1209 1223
1210 bool BrowserPlugin::canProcessDrag() const { 1224 bool BrowserPlugin::canProcessDrag() const {
1211 return true; 1225 return true;
1212 } 1226 }
1213 1227
1214 void BrowserPlugin::paint(WebCanvas* canvas, const WebRect& rect) { 1228 void BrowserPlugin::paint(WebCanvas* canvas, const WebRect& rect) {
1215 if (guest_crashed_) { 1229 if (guest_crashed_) {
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
1560 const WebKit::WebMouseEvent& event) { 1574 const WebKit::WebMouseEvent& event) {
1561 browser_plugin_manager()->Send( 1575 browser_plugin_manager()->Send(
1562 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, 1576 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_,
1563 instance_id_, 1577 instance_id_,
1564 plugin_rect_, 1578 plugin_rect_,
1565 &event)); 1579 &event));
1566 return true; 1580 return true;
1567 } 1581 }
1568 1582
1569 } // namespace content 1583 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/browser_plugin/browser_plugin.h ('k') | content/renderer/browser_plugin/browser_plugin_bindings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698