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

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

Issue 10965048: [BrowserTag] Send dib info with NavigateGuest message, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments from Fady + remove commented code. Created 8 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 | 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/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #if defined (OS_WIN) 9 #if defined (OS_WIN)
10 #include "base/sys_info.h" 10 #include "base/sys_info.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 } 89 }
90 90
91 std::string BrowserPlugin::GetSrcAttribute() const { 91 std::string BrowserPlugin::GetSrcAttribute() const {
92 return src_; 92 return src_;
93 } 93 }
94 94
95 void BrowserPlugin::SetSrcAttribute(const std::string& src) { 95 void BrowserPlugin::SetSrcAttribute(const std::string& src) {
96 if (src == src_ && !guest_crashed_) 96 if (src == src_ && !guest_crashed_)
97 return; 97 return;
98 if (!src.empty() || navigate_src_sent_) { 98 if (!src.empty() || navigate_src_sent_) {
99 scoped_ptr<BrowserPluginHostMsg_ResizeGuest_Params> params(
100 GetPendingResizeParams());
101 DCHECK(!params->resize_pending);
99 BrowserPluginManager::Get()->Send( 102 BrowserPluginManager::Get()->Send(
100 new BrowserPluginHostMsg_NavigateGuest( 103 new BrowserPluginHostMsg_NavigateGuest(
101 render_view_->GetRoutingID(), 104 render_view_->GetRoutingID(),
102 instance_id_, 105 instance_id_,
103 parent_frame_, 106 parent_frame_,
104 src, 107 src,
105 gfx::Size(width(), height()))); 108 *params));
106 // Record that we sent a NavigateGuest message to embedder. Once we send 109 // Record that we sent a NavigateGuest message to embedder. Once we send
107 // such a message, subsequent SetSrcAttribute() calls must always send 110 // such a message, subsequent SetSrcAttribute() calls must always send
108 // NavigateGuest messages to the embedder (even if |src| is empty), so 111 // NavigateGuest messages to the embedder (even if |src| is empty), so
109 // resize works correctly for all cases (e.g. The embedder can reset the 112 // resize works correctly for all cases (e.g. The embedder can reset the
110 // guest's |src| to empty value, resize and then set the |src| to a 113 // guest's |src| to empty value, resize and then set the |src| to a
111 // non-empty value). 114 // non-empty value).
112 navigate_src_sent_ = true; 115 navigate_src_sent_ = true;
113 } 116 }
114 src_ = src; 117 src_ = src;
115 guest_crashed_ = false; 118 guest_crashed_ = false;
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 const WebRect& clip_rect, 358 const WebRect& clip_rect,
356 const WebVector<WebRect>& cut_outs_rects, 359 const WebVector<WebRect>& cut_outs_rects,
357 bool is_visible) { 360 bool is_visible) {
358 int old_width = width(); 361 int old_width = width();
359 int old_height = height(); 362 int old_height = height();
360 plugin_rect_ = window_rect; 363 plugin_rect_ = window_rect;
361 if (old_width == window_rect.width && 364 if (old_width == window_rect.width &&
362 old_height == window_rect.height) { 365 old_height == window_rect.height) {
363 return; 366 return;
364 } 367 }
365 // Until an actual navigation occurs, there is no browser side embedder
366 // present to notify about geometry updates. In this case, after we've updated
367 // the BrowserPlugin's state we are done and can return immediately.
368 if (!navigate_src_sent_)
369 return;
370 368
371 const size_t stride = skia::PlatformCanvas::StrideForWidth(window_rect.width); 369 const size_t stride = skia::PlatformCanvas::StrideForWidth(window_rect.width);
372 // Make sure the size of the damage buffer is at least four bytes so that we 370 // Make sure the size of the damage buffer is at least four bytes so that we
373 // can fit in a magic word to verify that the memory is shared correctly. 371 // can fit in a magic word to verify that the memory is shared correctly.
374 size_t size = 372 size_t size =
375 std::max(sizeof(unsigned int), 373 std::max(sizeof(unsigned int),
376 static_cast<size_t>(window_rect.height * 374 static_cast<size_t>(window_rect.height *
377 stride * 375 stride *
378 GetDeviceScaleFactor() * 376 GetDeviceScaleFactor() *
379 GetDeviceScaleFactor())); 377 GetDeviceScaleFactor()));
(...skipping 12 matching lines...) Expand all
392 new_damage_buffer = TransportDIB::Map(shared_mem.handle()); 390 new_damage_buffer = TransportDIB::Map(shared_mem.handle());
393 #else 391 #else
394 new_damage_buffer = RenderProcess::current()->CreateTransportDIB(size); 392 new_damage_buffer = RenderProcess::current()->CreateTransportDIB(size);
395 #endif 393 #endif
396 if (!new_damage_buffer) 394 if (!new_damage_buffer)
397 NOTREACHED() << "Unable to create damage buffer"; 395 NOTREACHED() << "Unable to create damage buffer";
398 DCHECK(new_damage_buffer->memory()); 396 DCHECK(new_damage_buffer->memory());
399 // Insert the magic word. 397 // Insert the magic word.
400 *static_cast<unsigned int*>(new_damage_buffer->memory()) = 0xdeadbeef; 398 *static_cast<unsigned int*>(new_damage_buffer->memory()) = 0xdeadbeef;
401 399
402 BrowserPluginHostMsg_ResizeGuest_Params params;
403 params.damage_buffer_id = new_damage_buffer->id();
404 #if defined(OS_WIN)
405 params.damage_buffer_size = size;
406 #endif
407 params.width = window_rect.width;
408 params.height = window_rect.height;
409 params.resize_pending = resize_pending_;
410 params.scale_factor = GetDeviceScaleFactor();
411 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_ResizeGuest(
412 render_view_->GetRoutingID(),
413 instance_id_,
414 params));
415 resize_pending_ = true;
416
417 if (damage_buffer_) { 400 if (damage_buffer_) {
418 RenderProcess::current()->FreeTransportDIB(damage_buffer_); 401 RenderProcess::current()->FreeTransportDIB(damage_buffer_);
419 damage_buffer_ = NULL; 402 damage_buffer_ = NULL;
420 } 403 }
421 damage_buffer_ = new_damage_buffer; 404 damage_buffer_ = new_damage_buffer;
405 pending_resize_params_.reset();
406
407 scoped_ptr<BrowserPluginHostMsg_ResizeGuest_Params> params(
408 new BrowserPluginHostMsg_ResizeGuest_Params);
409 params->damage_buffer_id = new_damage_buffer->id();
410 #if defined(OS_WIN)
411 params->damage_buffer_size = size;
412 #endif
413 params->width = window_rect.width;
414 params->height = window_rect.height;
415 params->resize_pending = resize_pending_;
416 params->scale_factor = GetDeviceScaleFactor();
417
418 if (navigate_src_sent_) {
419 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_ResizeGuest(
420 render_view_->GetRoutingID(),
421 instance_id_,
422 *params));
423 resize_pending_ = true;
424 } else {
425 // Until an actual navigation occurs, there is no browser side embedder
426 // present to notify about geometry updates. In this case, after we've
427 // updated the BrowserPlugin's state we are done and we do not send a resize
428 // message to the browser.
429 pending_resize_params_.reset(params.release());
430 }
431 }
432
433 BrowserPluginHostMsg_ResizeGuest_Params*
434 BrowserPlugin::GetPendingResizeParams() {
435 if (pending_resize_params_.get()) {
436 resize_pending_ = true;
437 return pending_resize_params_.release();
438 } else {
439 BrowserPluginHostMsg_ResizeGuest_Params* params =
440 new BrowserPluginHostMsg_ResizeGuest_Params;
441
442 // We don't have a pending resize to send, so we send an invalid transport
443 // dib Id.
444 params->damage_buffer_id = TransportDIB::Id();
445 params->width = width();
446 params->height = height();
447 params->resize_pending = false;
448 return params;
449 }
422 } 450 }
423 451
424 void BrowserPlugin::updateFocus(bool focused) { 452 void BrowserPlugin::updateFocus(bool focused) {
425 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_SetFocus( 453 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_SetFocus(
426 render_view_->GetRoutingID(), 454 render_view_->GetRoutingID(),
427 instance_id_, 455 instance_id_,
428 focused)); 456 focused));
429 } 457 }
430 458
431 void BrowserPlugin::updateVisibility(bool visible) { 459 void BrowserPlugin::updateVisibility(bool visible) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 void* notify_data) { 500 void* notify_data) {
473 } 501 }
474 502
475 void BrowserPlugin::didFailLoadingFrameRequest( 503 void BrowserPlugin::didFailLoadingFrameRequest(
476 const WebKit::WebURL& url, 504 const WebKit::WebURL& url,
477 void* notify_data, 505 void* notify_data,
478 const WebKit::WebURLError& error) { 506 const WebKit::WebURLError& error) {
479 } 507 }
480 508
481 } // namespace content 509 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698