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

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

Issue 15757007: Revert 202364 "Track NPObject ownership by the originating plugi..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 6 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
1145 bindings_.reset(new BrowserPluginBindings(this)); 1141 bindings_.reset(new BrowserPluginBindings(this));
1146 container_ = container; 1142 container_ = container;
1147 container_->setWantsWheelEvents(true); 1143 container_->setWantsWheelEvents(true);
1148 ParseAttributes(); 1144 ParseAttributes();
1149 g_plugin_container_map.Get().insert(std::make_pair(container_, this)); 1145 g_plugin_container_map.Get().insert(std::make_pair(container_, this));
1150 return true; 1146 return true;
1151 } 1147 }
1152 1148
1153 void BrowserPlugin::EnableCompositing(bool enable) { 1149 void BrowserPlugin::EnableCompositing(bool enable) {
1154 if (compositing_enabled_ == enable) 1150 if (compositing_enabled_ == enable)
(...skipping 23 matching lines...) Expand all
1178 resize_ack_received_ = false; 1174 resize_ack_received_ = false;
1179 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ResizeGuest( 1175 browser_plugin_manager()->Send(new BrowserPluginHostMsg_ResizeGuest(
1180 render_view_routing_id_, 1176 render_view_routing_id_,
1181 instance_id_, 1177 instance_id_,
1182 params)); 1178 params));
1183 } 1179 }
1184 compositing_helper_->EnableCompositing(enable); 1180 compositing_helper_->EnableCompositing(enable);
1185 } 1181 }
1186 1182
1187 void BrowserPlugin::destroy() { 1183 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
1194 // The BrowserPlugin's WebPluginContainer is deleted immediately after this 1184 // The BrowserPlugin's WebPluginContainer is deleted immediately after this
1195 // call returns, so let's not keep a reference to it around. 1185 // call returns, so let's not keep a reference to it around.
1196 g_plugin_container_map.Get().erase(container_); 1186 g_plugin_container_map.Get().erase(container_);
1197 container_ = NULL; 1187 container_ = NULL;
1198 if (compositing_helper_) 1188 if (compositing_helper_)
1199 compositing_helper_->OnContainerDestroy(); 1189 compositing_helper_->OnContainerDestroy();
1200 // Will be a no-op if the mouse is not currently locked. 1190 // Will be a no-op if the mouse is not currently locked.
1201 if (render_view_) 1191 if (render_view_)
1202 render_view_->mouse_lock_dispatcher()->OnLockTargetDestroyed(this); 1192 render_view_->mouse_lock_dispatcher()->OnLockTargetDestroyed(this);
1203 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); 1193 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
1204 } 1194 }
1205 1195
1206 NPObject* BrowserPlugin::scriptableObject() { 1196 NPObject* BrowserPlugin::scriptableObject() {
1207 if (!bindings_) 1197 if (!bindings_)
1208 return NULL; 1198 return NULL;
1209 1199
1210 NPObject* browser_plugin_np_object(bindings_->np_object()); 1200 NPObject* browser_plugin_np_object(bindings_->np_object());
1211 // The object is expected to be retained before it is returned. 1201 // The object is expected to be retained before it is returned.
1212 WebKit::WebBindings::retainObject(browser_plugin_np_object); 1202 WebKit::WebBindings::retainObject(browser_plugin_np_object);
1213 return browser_plugin_np_object; 1203 return browser_plugin_np_object;
1214 } 1204 }
1215 1205
1216 NPP BrowserPlugin::pluginNPP() {
1217 return npp_.get();
1218 }
1219
1220 bool BrowserPlugin::supportsKeyboardFocus() const { 1206 bool BrowserPlugin::supportsKeyboardFocus() const {
1221 return true; 1207 return true;
1222 } 1208 }
1223 1209
1224 bool BrowserPlugin::canProcessDrag() const { 1210 bool BrowserPlugin::canProcessDrag() const {
1225 return true; 1211 return true;
1226 } 1212 }
1227 1213
1228 void BrowserPlugin::paint(WebCanvas* canvas, const WebRect& rect) { 1214 void BrowserPlugin::paint(WebCanvas* canvas, const WebRect& rect) {
1229 if (guest_crashed_) { 1215 if (guest_crashed_) {
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 const WebKit::WebMouseEvent& event) { 1560 const WebKit::WebMouseEvent& event) {
1575 browser_plugin_manager()->Send( 1561 browser_plugin_manager()->Send(
1576 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, 1562 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_,
1577 instance_id_, 1563 instance_id_,
1578 plugin_rect_, 1564 plugin_rect_,
1579 &event)); 1565 &event));
1580 return true; 1566 return true;
1581 } 1567 }
1582 1568
1583 } // namespace content 1569 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698