Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 13 matching lines...) Expand all Loading... | |
| 80 if (damage_buffer_) { | 81 if (damage_buffer_) { |
| 81 RenderProcess::current()->FreeTransportDIB(damage_buffer_); | 82 RenderProcess::current()->FreeTransportDIB(damage_buffer_); |
| 82 damage_buffer_ = NULL; | 83 damage_buffer_ = NULL; |
| 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) { |
|
awong
2012/09/06 19:55:26
On Charlie's comment that on src.empty(), we shoul
lazyboy
2012/09/07 19:33:19
If we haven't loaded a guest at all in |guest|, we
awong
2012/09/07 20:51:03
If we navigate the existing WebContents to "", wha
lazyboy
2012/09/08 02:12:22
If we navigate the existing WebContents to "", wha
| |
| 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 a message, subsequent SetSrcAttribute() calls must always send | |
|
awong
2012/09/06 19:55:26
nit: extra space after calls
lazyboy
2012/09/07 19:33:19
Done.
| |
| 104 // NavigateGuest messages to the embedder (even if |src| is empty), so | |
| 105 // resize works correctly for all cases (e.g. The embedder can reset the | |
| 106 // guest's |src| to empty value, resize and then set the |src| to a | |
| 107 // non-empty value). | |
|
awong
2012/09/06 19:55:26
Awesome. That's way more clear :)
lazyboy
2012/09/07 19:33:19
Done.
| |
| 108 navigate_src_sent_ = true; | |
| 100 } | 109 } |
| 101 src_ = src; | 110 src_ = src; |
| 102 guest_crashed_ = false; | 111 guest_crashed_ = false; |
| 103 } | 112 } |
| 104 | 113 |
| 105 bool BrowserPlugin::ParseSrcAttribute( | 114 bool BrowserPlugin::ParseSrcAttribute( |
| 106 const WebKit::WebPluginParams& params, | 115 const WebKit::WebPluginParams& params, |
| 107 std::string* src) { | 116 std::string* src) { |
| 108 // Get the src attribute from the attributes vector | 117 // Get the src attribute from the attributes vector |
| 109 for (unsigned i = 0; i < params.attributeNames.size(); ++i) { | 118 for (unsigned i = 0; i < params.attributeNames.size(); ++i) { |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 320 | 329 |
| 321 void BrowserPlugin::updateGeometry( | 330 void BrowserPlugin::updateGeometry( |
| 322 const WebRect& window_rect, | 331 const WebRect& window_rect, |
| 323 const WebRect& clip_rect, | 332 const WebRect& clip_rect, |
| 324 const WebVector<WebRect>& cut_outs_rects, | 333 const WebVector<WebRect>& cut_outs_rects, |
| 325 bool is_visible) { | 334 bool is_visible) { |
| 326 int old_width = width(); | 335 int old_width = width(); |
| 327 int old_height = height(); | 336 int old_height = height(); |
| 328 plugin_rect_ = window_rect; | 337 plugin_rect_ = window_rect; |
| 329 if (old_width == window_rect.width && | 338 if (old_width == window_rect.width && |
| 330 old_height == window_rect.height) | 339 old_height == window_rect.height) |
|
awong
2012/09/06 19:55:26
use braces if you have a multi-line conditional
lazyboy
2012/09/07 19:33:19
Done.
| |
| 331 return; | 340 return; |
| 341 // Don't send anything to embedder until an actual navigation occurs, since | |
|
awong
2012/09/06 19:55:26
nit: remove comment.
Also, I think it we should c
Fady Samuel
2012/09/06 21:08:15
As discussed offline, please also verify that we'r
lazyboy
2012/09/07 19:33:19
Done.
lazyboy
2012/09/07 19:33:19
I've tested with
1. set guest src to a infinite lo
| |
| 342 // there is no browser side embedder present to handle it. | |
| 343 if (src_.empty() && !navigate_src_sent_) | |
| 344 return; | |
| 332 | 345 |
| 333 const size_t stride = skia::PlatformCanvas::StrideForWidth(window_rect.width); | 346 const size_t stride = skia::PlatformCanvas::StrideForWidth(window_rect.width); |
| 334 const size_t size = window_rect.height * | 347 const size_t size = window_rect.height * |
| 335 stride * | 348 stride * |
| 336 GetDeviceScaleFactor() * | 349 GetDeviceScaleFactor() * |
| 337 GetDeviceScaleFactor(); | 350 GetDeviceScaleFactor(); |
| 338 | 351 |
| 339 // Don't drop the old damage buffer until after we've made sure that the | 352 // Don't drop the old damage buffer until after we've made sure that the |
| 340 // browser process has dropped it. | 353 // browser process has dropped it. |
| 341 TransportDIB* new_damage_buffer = | 354 TransportDIB* new_damage_buffer = |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 412 void* notify_data) { | 425 void* notify_data) { |
| 413 } | 426 } |
| 414 | 427 |
| 415 void BrowserPlugin::didFailLoadingFrameRequest( | 428 void BrowserPlugin::didFailLoadingFrameRequest( |
| 416 const WebKit::WebURL& url, | 429 const WebKit::WebURL& url, |
| 417 void* notify_data, | 430 void* notify_data, |
| 418 const WebKit::WebURLError& error) { | 431 const WebKit::WebURLError& error) { |
| 419 } | 432 } |
| 420 | 433 |
| 421 } // namespace content | 434 } // namespace content |
| OLD | NEW |