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 16 matching lines...) Expand all Loading... |
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 a message, subsequent SetSrcAttribute() calls must always send |
| 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). |
| 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) { |
| 340 return; |
| 341 } |
| 342 // Until an actual navigation occurs, there is no browser side embedder |
| 343 // present to notify about geometry updates. In this case, after we've updated |
| 344 // the BrowserPlugin's state we are done and can return immediately. |
| 345 if (src_.empty() && !navigate_src_sent_) |
331 return; | 346 return; |
332 | 347 |
333 const size_t stride = skia::PlatformCanvas::StrideForWidth(window_rect.width); | 348 const size_t stride = skia::PlatformCanvas::StrideForWidth(window_rect.width); |
334 const size_t size = window_rect.height * | 349 const size_t size = window_rect.height * |
335 stride * | 350 stride * |
336 GetDeviceScaleFactor() * | 351 GetDeviceScaleFactor() * |
337 GetDeviceScaleFactor(); | 352 GetDeviceScaleFactor(); |
338 | 353 |
339 // Don't drop the old damage buffer until after we've made sure that the | 354 // Don't drop the old damage buffer until after we've made sure that the |
340 // browser process has dropped it. | 355 // browser process has dropped it. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 void* notify_data) { | 427 void* notify_data) { |
413 } | 428 } |
414 | 429 |
415 void BrowserPlugin::didFailLoadingFrameRequest( | 430 void BrowserPlugin::didFailLoadingFrameRequest( |
416 const WebKit::WebURL& url, | 431 const WebKit::WebURL& url, |
417 void* notify_data, | 432 void* notify_data, |
418 const WebKit::WebURLError& error) { | 433 const WebKit::WebURLError& error) { |
419 } | 434 } |
420 | 435 |
421 } // namespace content | 436 } // namespace content |
OLD | NEW |