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 #if defined (OS_WIN) | 9 #if defined (OS_WIN) |
| 10 #include "base/sys_info.h" | 10 #include "base/sys_info.h" |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 313 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_UpdateRect_ACK( | 313 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_UpdateRect_ACK( |
| 314 render_view_->GetRoutingID(), | 314 render_view_->GetRoutingID(), |
| 315 instance_id_, | 315 instance_id_, |
| 316 message_id, | 316 message_id, |
| 317 gfx::Size())); | 317 gfx::Size())); |
| 318 } | 318 } |
| 319 | 319 |
| 320 void BrowserPlugin::GuestCrashed() { | 320 void BrowserPlugin::GuestCrashed() { |
| 321 guest_crashed_ = true; | 321 guest_crashed_ = true; |
| 322 container_->invalidate(); | 322 container_->invalidate(); |
| 323 // We won't paint the contents of the current backing store again so we might | |
| 324 // as well toss it out and save memory. | |
| 325 backing_store_.reset(); | |
| 323 | 326 |
| 324 if (!HasListeners(kCrashEventName)) | 327 if (!HasListeners(kCrashEventName)) |
| 325 return; | 328 return; |
| 326 | 329 |
| 327 EventListeners& listeners = event_listener_map_[kCrashEventName]; | 330 EventListeners& listeners = event_listener_map_[kCrashEventName]; |
| 328 EventListeners::iterator it = listeners.begin(); | 331 EventListeners::iterator it = listeners.begin(); |
| 329 for (; it != listeners.end(); ++it) { | 332 for (; it != listeners.end(); ++it) { |
| 330 v8::Context::Scope context_scope(v8::Context::New()); | 333 v8::Context::Scope context_scope(v8::Context::New()); |
| 331 v8::HandleScope handle_scope; | 334 v8::HandleScope handle_scope; |
| 332 container()->element().document().frame()-> | 335 container()->element().document().frame()-> |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 522 return true; | 525 return true; |
| 523 } | 526 } |
| 524 | 527 |
| 525 void BrowserPlugin::paint(WebCanvas* canvas, const WebRect& rect) { | 528 void BrowserPlugin::paint(WebCanvas* canvas, const WebRect& rect) { |
| 526 if (guest_crashed_) { | 529 if (guest_crashed_) { |
| 527 if (!sad_guest_) // Lazily initialize bitmap. | 530 if (!sad_guest_) // Lazily initialize bitmap. |
| 528 sad_guest_ = content::GetContentClient()->renderer()-> | 531 sad_guest_ = content::GetContentClient()->renderer()-> |
| 529 GetSadPluginBitmap(); | 532 GetSadPluginBitmap(); |
| 530 // TODO(fsamuel): Do we want to paint something other than a sad plugin | 533 // TODO(fsamuel): Do we want to paint something other than a sad plugin |
| 531 // on crash? See http://www.crbug.com/140266. | 534 // on crash? See http://www.crbug.com/140266. |
| 532 webkit::PaintSadPlugin(canvas, plugin_rect_, *sad_guest_); | 535 // content_shell does not have the sad plugin bitmap, so we'll paint black |
| 533 return; | 536 // instead to make it clear that something went wrong. |
| 537 if (sad_guest_) { | |
| 538 webkit::PaintSadPlugin(canvas, plugin_rect_, *sad_guest_); | |
| 539 return; | |
| 540 } | |
| 534 } | 541 } |
| 535 SkAutoCanvasRestore auto_restore(canvas, true); | 542 SkAutoCanvasRestore auto_restore(canvas, true); |
| 536 canvas->translate(plugin_rect_.x(), plugin_rect_.y()); | 543 canvas->translate(plugin_rect_.x(), plugin_rect_.y()); |
| 537 SkRect image_data_rect = SkRect::MakeXYWH( | 544 SkRect image_data_rect = SkRect::MakeXYWH( |
| 538 SkIntToScalar(0), | 545 SkIntToScalar(0), |
| 539 SkIntToScalar(0), | 546 SkIntToScalar(0), |
| 540 SkIntToScalar(plugin_rect_.width()), | 547 SkIntToScalar(plugin_rect_.width()), |
| 541 SkIntToScalar(plugin_rect_.height())); | 548 SkIntToScalar(plugin_rect_.height())); |
| 542 canvas->clipRect(image_data_rect); | 549 canvas->clipRect(image_data_rect); |
| 543 // Paint white in case we have nothing in our backing store or we need to | 550 // Paint white in case we have nothing in our backing store or we need to |
|
Charlie Reis
2012/10/10 16:37:39
nit: white or black
| |
| 544 // show a gutter. | 551 // show a gutter. |
| 545 SkPaint paint; | 552 SkPaint paint; |
| 546 paint.setStyle(SkPaint::kFill_Style); | 553 paint.setStyle(SkPaint::kFill_Style); |
| 547 paint.setColor(SK_ColorWHITE); | 554 paint.setColor(guest_crashed_ ? SK_ColorBLACK : SK_ColorWHITE); |
| 548 canvas->drawRect(image_data_rect, paint); | 555 canvas->drawRect(image_data_rect, paint); |
| 549 // Stay at white if we have never set a non-empty src, or we don't yet have a | 556 // Stay a solid color if we have never set a non-empty src, or we don't have a |
| 550 // backing store. | 557 // backing store. |
| 551 if (!backing_store_.get() || !navigate_src_sent_) | 558 if (!backing_store_.get() || !navigate_src_sent_) |
| 552 return; | 559 return; |
| 553 float inverse_scale_factor = 1.0f / backing_store_->GetScaleFactor(); | 560 float inverse_scale_factor = 1.0f / backing_store_->GetScaleFactor(); |
| 554 canvas->scale(inverse_scale_factor, inverse_scale_factor); | 561 canvas->scale(inverse_scale_factor, inverse_scale_factor); |
| 555 canvas->drawBitmap(backing_store_->GetBitmap(), 0, 0); | 562 canvas->drawBitmap(backing_store_->GetBitmap(), 0, 0); |
| 556 } | 563 } |
| 557 | 564 |
| 558 void BrowserPlugin::updateGeometry( | 565 void BrowserPlugin::updateGeometry( |
| 559 const WebRect& window_rect, | 566 const WebRect& window_rect, |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 740 void* notify_data) { | 747 void* notify_data) { |
| 741 } | 748 } |
| 742 | 749 |
| 743 void BrowserPlugin::didFailLoadingFrameRequest( | 750 void BrowserPlugin::didFailLoadingFrameRequest( |
| 744 const WebKit::WebURL& url, | 751 const WebKit::WebURL& url, |
| 745 void* notify_data, | 752 void* notify_data, |
| 746 const WebKit::WebURLError& error) { | 753 const WebKit::WebURLError& error) { |
| 747 } | 754 } |
| 748 | 755 |
| 749 } // namespace content | 756 } // namespace content |
| OLD | NEW |