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

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

Issue 10868012: Browser Plugin: New Implementation (Browser Side) (Closed) Base URL: http://git.chromium.org/chromium/src.git@master-trial-obrowser
Patch Set: Fix mac build + Address nits from awong@ Created 8 years, 3 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 (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/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "content/common/browser_plugin_messages.h" 9 #include "content/common/browser_plugin_messages.h"
10 #include "content/public/common/content_client.h" 10 #include "content/public/common/content_client.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 RenderViewImpl* render_view, 47 RenderViewImpl* render_view,
48 WebKit::WebFrame* frame, 48 WebKit::WebFrame* frame,
49 const WebPluginParams& params) 49 const WebPluginParams& params)
50 : instance_id_(instance_id), 50 : instance_id_(instance_id),
51 render_view_(render_view), 51 render_view_(render_view),
52 container_(NULL), 52 container_(NULL),
53 damage_buffer_(NULL), 53 damage_buffer_(NULL),
54 sad_guest_(NULL), 54 sad_guest_(NULL),
55 guest_crashed_(false), 55 guest_crashed_(false),
56 resize_pending_(false), 56 resize_pending_(false),
57 navigate_src_sent_(false),
57 parent_frame_(frame->identifier()) { 58 parent_frame_(frame->identifier()) {
58 BrowserPluginManager::Get()->AddBrowserPlugin(instance_id, this); 59 BrowserPluginManager::Get()->AddBrowserPlugin(instance_id, this);
59 bindings_.reset(new BrowserPluginBindings(this)); 60 bindings_.reset(new BrowserPluginBindings(this));
60 61
61 std::string src; 62 std::string src;
62 if (ParseSrcAttribute(params, &src)) 63 if (ParseSrcAttribute(params, &src))
63 SetSrcAttribute(src); 64 SetSrcAttribute(src);
64 } 65 }
65 66
66 BrowserPlugin::~BrowserPlugin() { 67 BrowserPlugin::~BrowserPlugin() {
(...skipping 16 matching lines...) Expand all
83 } 84 }
84 } 85 }
85 86
86 std::string BrowserPlugin::GetSrcAttribute() const { 87 std::string BrowserPlugin::GetSrcAttribute() const {
87 return src_; 88 return src_;
88 } 89 }
89 90
90 void BrowserPlugin::SetSrcAttribute(const std::string& src) { 91 void BrowserPlugin::SetSrcAttribute(const std::string& src) {
91 if (src == src_ && !guest_crashed_) 92 if (src == src_ && !guest_crashed_)
92 return; 93 return;
93 if (!src.empty()) { 94 if (!src.empty() || navigate_src_sent_) {
94 BrowserPluginManager::Get()->Send( 95 BrowserPluginManager::Get()->Send(
95 new BrowserPluginHostMsg_NavigateOrCreateGuest( 96 new BrowserPluginHostMsg_NavigateGuest(
96 render_view_->GetRoutingID(), 97 render_view_->GetRoutingID(),
97 instance_id_, 98 instance_id_,
98 parent_frame_, 99 parent_frame_,
99 src)); 100 src,
101 gfx::Size(width(), height())));
102 // Record that we sent a NavigateGuest message to embedder, once we send
103 // such message, subsequent SetSrcAttribute must always send NavigateGuest
awong 2012/09/06 00:23:27 nits: embedder, once -> embedder. Once such messa
lazyboy 2012/09/06 04:33:53 Done.
104 // message to the embedder even if src is empty.
awong 2012/09/06 00:23:27 nit: message to -> messages to
lazyboy 2012/09/06 04:33:53 Done.
105 navigate_src_sent_ = true;
100 } 106 }
101 src_ = src; 107 src_ = src;
102 guest_crashed_ = false; 108 guest_crashed_ = false;
103 } 109 }
104 110
105 bool BrowserPlugin::ParseSrcAttribute( 111 bool BrowserPlugin::ParseSrcAttribute(
106 const WebKit::WebPluginParams& params, 112 const WebKit::WebPluginParams& params,
107 std::string* src) { 113 std::string* src) {
108 // Get the src attribute from the attributes vector 114 // Get the src attribute from the attributes vector
109 for (unsigned i = 0; i < params.attributeNames.size(); ++i) { 115 for (unsigned i = 0; i < params.attributeNames.size(); ++i) {
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 const WebRect& window_rect, 328 const WebRect& window_rect,
323 const WebRect& clip_rect, 329 const WebRect& clip_rect,
324 const WebVector<WebRect>& cut_outs_rects, 330 const WebVector<WebRect>& cut_outs_rects,
325 bool is_visible) { 331 bool is_visible) {
326 int old_width = width(); 332 int old_width = width();
327 int old_height = height(); 333 int old_height = height();
328 plugin_rect_ = window_rect; 334 plugin_rect_ = window_rect;
329 if (old_width == window_rect.width && 335 if (old_width == window_rect.width &&
330 old_height == window_rect.height) 336 old_height == window_rect.height)
331 return; 337 return;
338 // If we didn't ever load a guest (navigate_src_sent_ = false), we ignore
339 // sending anything anything to embedder until an actual navigation (non empty
awong 2012/09/06 00:23:27 nit: anything anything -> anything Same as above,
lazyboy 2012/09/06 04:33:53 Done.
340 // src) happens.
341 if (src_.empty() && !navigate_src_sent_)
342 return;
332 343
333 const size_t stride = skia::PlatformCanvas::StrideForWidth(window_rect.width); 344 const size_t stride = skia::PlatformCanvas::StrideForWidth(window_rect.width);
334 const size_t size = window_rect.height * 345 const size_t size = window_rect.height *
335 stride * 346 stride *
336 GetDeviceScaleFactor() * 347 GetDeviceScaleFactor() *
337 GetDeviceScaleFactor(); 348 GetDeviceScaleFactor();
338 349
339 // Don't drop the old damage buffer until after we've made sure that the 350 // Don't drop the old damage buffer until after we've made sure that the
340 // browser process has dropped it. 351 // browser process has dropped it.
341 TransportDIB* new_damage_buffer = 352 TransportDIB* new_damage_buffer =
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 void* notify_data) { 423 void* notify_data) {
413 } 424 }
414 425
415 void BrowserPlugin::didFailLoadingFrameRequest( 426 void BrowserPlugin::didFailLoadingFrameRequest(
416 const WebKit::WebURL& url, 427 const WebKit::WebURL& url,
417 void* notify_data, 428 void* notify_data,
418 const WebKit::WebURLError& error) { 429 const WebKit::WebURLError& error) {
419 } 430 }
420 431
421 } // namespace content 432 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698