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

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

Issue 618823002: GuestView: Move lifetime management out of content (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added comment Created 6 years, 2 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 delegate_(delegate.Pass()), 76 delegate_(delegate.Pass()),
77 weak_ptr_factory_(this) { 77 weak_ptr_factory_(this) {
78 browser_plugin_instance_id_ = browser_plugin_manager()->GetNextInstanceID(); 78 browser_plugin_instance_id_ = browser_plugin_manager()->GetNextInstanceID();
79 79
80 if (delegate_) 80 if (delegate_)
81 delegate_->SetElementInstanceID(browser_plugin_instance_id_); 81 delegate_->SetElementInstanceID(browser_plugin_instance_id_);
82 } 82 }
83 83
84 BrowserPlugin::~BrowserPlugin() { 84 BrowserPlugin::~BrowserPlugin() {
85 browser_plugin_manager()->RemoveBrowserPlugin(browser_plugin_instance_id_); 85 browser_plugin_manager()->RemoveBrowserPlugin(browser_plugin_instance_id_);
86
87 if (!ready())
88 return;
89
90 browser_plugin_manager()->Send(
91 new BrowserPluginHostMsg_PluginDestroyed(render_view_routing_id_,
92 browser_plugin_instance_id_));
93 } 86 }
94 87
95 bool BrowserPlugin::OnMessageReceived(const IPC::Message& message) { 88 bool BrowserPlugin::OnMessageReceived(const IPC::Message& message) {
96 bool handled = true; 89 bool handled = true;
97 IPC_BEGIN_MESSAGE_MAP(BrowserPlugin, message) 90 IPC_BEGIN_MESSAGE_MAP(BrowserPlugin, message)
98 IPC_MESSAGE_HANDLER(BrowserPluginMsg_Attach_ACK, OnAttachACK) 91 IPC_MESSAGE_HANDLER(BrowserPluginMsg_Attach_ACK, OnAttachACK)
99 IPC_MESSAGE_HANDLER(BrowserPluginMsg_AdvanceFocus, OnAdvanceFocus) 92 IPC_MESSAGE_HANDLER(BrowserPluginMsg_AdvanceFocus, OnAdvanceFocus)
100 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginMsg_CompositorFrameSwapped, 93 IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginMsg_CompositorFrameSwapped,
101 OnCompositorFrameSwapped(message)) 94 OnCompositorFrameSwapped(message))
102 IPC_MESSAGE_HANDLER(BrowserPluginMsg_CopyFromCompositingSurface, 95 IPC_MESSAGE_HANDLER(BrowserPluginMsg_CopyFromCompositingSurface,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 void BrowserPlugin::OnAttachACK(int browser_plugin_instance_id) { 160 void BrowserPlugin::OnAttachACK(int browser_plugin_instance_id) {
168 DCHECK(!attached()); 161 DCHECK(!attached());
169 attached_ = true; 162 attached_ = true;
170 attach_pending_ = false; 163 attach_pending_ = false;
171 } 164 }
172 165
173 void BrowserPlugin::OnCompositorFrameSwapped(const IPC::Message& message) { 166 void BrowserPlugin::OnCompositorFrameSwapped(const IPC::Message& message) {
174 BrowserPluginMsg_CompositorFrameSwapped::Param param; 167 BrowserPluginMsg_CompositorFrameSwapped::Param param;
175 if (!BrowserPluginMsg_CompositorFrameSwapped::Read(&message, &param)) 168 if (!BrowserPluginMsg_CompositorFrameSwapped::Read(&message, &param))
176 return; 169 return;
177
178 // Note that there is no need to send ACK for this message. 170 // Note that there is no need to send ACK for this message.
179 // If the guest has updated pixels then it is no longer crashed. 171 // If the guest has updated pixels then it is no longer crashed.
180 guest_crashed_ = false; 172 guest_crashed_ = false;
181 173
182 scoped_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame); 174 scoped_ptr<cc::CompositorFrame> frame(new cc::CompositorFrame);
183 param.b.frame.AssignTo(frame.get()); 175 param.b.frame.AssignTo(frame.get());
184 176
185 EnableCompositing(true); 177 EnableCompositing(true);
186 compositing_helper_->OnCompositorFrameSwapped(frame.Pass(), 178 compositing_helper_->OnCompositorFrameSwapped(frame.Pass(),
187 param.b.producing_route_id, 179 param.b.producing_route_id,
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 302
311 bool BrowserPlugin::initialize(WebPluginContainer* container) { 303 bool BrowserPlugin::initialize(WebPluginContainer* container) {
312 if (!container) 304 if (!container)
313 return false; 305 return false;
314 306
315 container_ = container; 307 container_ = container;
316 container_->setWantsWheelEvents(true); 308 container_->setWantsWheelEvents(true);
317 309
318 g_plugin_container_map.Get().insert(std::make_pair(container_, this)); 310 g_plugin_container_map.Get().insert(std::make_pair(container_, this));
319 311
312 browser_plugin_manager()->AddBrowserPlugin(browser_plugin_instance_id_, this);
313
320 // This is a way to notify observers of our attributes that this plugin is 314 // This is a way to notify observers of our attributes that this plugin is
321 // available in render tree. 315 // available in render tree.
322 // TODO(lazyboy): This should be done through the delegate instead. Perhaps 316 // TODO(lazyboy): This should be done through the delegate instead. Perhaps
323 // by firing an event from there. 317 // by firing an event from there.
324 UpdateDOMAttribute("internalinstanceid", 318 UpdateDOMAttribute("internalinstanceid",
325 base::IntToString(browser_plugin_instance_id_)); 319 base::IntToString(browser_plugin_instance_id_));
326 320
327 browser_plugin_manager()->AddBrowserPlugin(browser_plugin_instance_id_, this);
328 return true; 321 return true;
329 } 322 }
330 323
331 void BrowserPlugin::EnableCompositing(bool enable) { 324 void BrowserPlugin::EnableCompositing(bool enable) {
332 bool enabled = !!compositing_helper_.get(); 325 bool enabled = !!compositing_helper_.get();
333 if (enabled == enable) 326 if (enabled == enable)
334 return; 327 return;
335 328
336 if (enable) { 329 if (enable) {
337 DCHECK(!compositing_helper_.get()); 330 DCHECK(!compositing_helper_.get());
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 const blink::WebMouseEvent& event) { 644 const blink::WebMouseEvent& event) {
652 browser_plugin_manager()->Send( 645 browser_plugin_manager()->Send(
653 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, 646 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_,
654 browser_plugin_instance_id_, 647 browser_plugin_instance_id_,
655 plugin_rect_, 648 plugin_rect_,
656 &event)); 649 &event));
657 return true; 650 return true;
658 } 651 }
659 652
660 } // namespace content 653 } // namespace content
OLDNEW
« no previous file with comments | « content/public/browser/browser_plugin_guest_delegate.h ('k') | content/renderer/browser_plugin/browser_plugin_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698