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 WebKit::WebElement plugin = container()->element(); | 330 WebKit::WebElement plugin = container()->element(); |
328 v8::HandleScope handle_scope; | 331 v8::HandleScope handle_scope; |
329 v8::Context::Scope context_scope( | 332 v8::Context::Scope context_scope( |
330 plugin.document().frame()->mainWorldScriptContext()); | 333 plugin.document().frame()->mainWorldScriptContext()); |
331 | 334 |
332 // TODO(fsamuel): Copying the event listeners is insufficent because | 335 // TODO(fsamuel): Copying the event listeners is insufficent because |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 return true; | 535 return true; |
533 } | 536 } |
534 | 537 |
535 void BrowserPlugin::paint(WebCanvas* canvas, const WebRect& rect) { | 538 void BrowserPlugin::paint(WebCanvas* canvas, const WebRect& rect) { |
536 if (guest_crashed_) { | 539 if (guest_crashed_) { |
537 if (!sad_guest_) // Lazily initialize bitmap. | 540 if (!sad_guest_) // Lazily initialize bitmap. |
538 sad_guest_ = content::GetContentClient()->renderer()-> | 541 sad_guest_ = content::GetContentClient()->renderer()-> |
539 GetSadPluginBitmap(); | 542 GetSadPluginBitmap(); |
540 // TODO(fsamuel): Do we want to paint something other than a sad plugin | 543 // TODO(fsamuel): Do we want to paint something other than a sad plugin |
541 // on crash? See http://www.crbug.com/140266. | 544 // on crash? See http://www.crbug.com/140266. |
542 webkit::PaintSadPlugin(canvas, plugin_rect_, *sad_guest_); | 545 // content_shell does not have the sad plugin bitmap, so we'll paint black |
543 return; | 546 // instead to make it clear that something went wrong. |
| 547 if (sad_guest_) { |
| 548 webkit::PaintSadPlugin(canvas, plugin_rect_, *sad_guest_); |
| 549 return; |
| 550 } |
544 } | 551 } |
545 SkAutoCanvasRestore auto_restore(canvas, true); | 552 SkAutoCanvasRestore auto_restore(canvas, true); |
546 canvas->translate(plugin_rect_.x(), plugin_rect_.y()); | 553 canvas->translate(plugin_rect_.x(), plugin_rect_.y()); |
547 SkRect image_data_rect = SkRect::MakeXYWH( | 554 SkRect image_data_rect = SkRect::MakeXYWH( |
548 SkIntToScalar(0), | 555 SkIntToScalar(0), |
549 SkIntToScalar(0), | 556 SkIntToScalar(0), |
550 SkIntToScalar(plugin_rect_.width()), | 557 SkIntToScalar(plugin_rect_.width()), |
551 SkIntToScalar(plugin_rect_.height())); | 558 SkIntToScalar(plugin_rect_.height())); |
552 canvas->clipRect(image_data_rect); | 559 canvas->clipRect(image_data_rect); |
553 // Paint white in case we have nothing in our backing store or we need to | 560 // Paint black or white in case we have nothing in our backing store or we |
554 // show a gutter. | 561 // need to show a gutter. |
555 SkPaint paint; | 562 SkPaint paint; |
556 paint.setStyle(SkPaint::kFill_Style); | 563 paint.setStyle(SkPaint::kFill_Style); |
557 paint.setColor(SK_ColorWHITE); | 564 paint.setColor(guest_crashed_ ? SK_ColorBLACK : SK_ColorWHITE); |
558 canvas->drawRect(image_data_rect, paint); | 565 canvas->drawRect(image_data_rect, paint); |
559 // Stay at white if we have never set a non-empty src, or we don't yet have a | 566 // Stay a solid color if we have never set a non-empty src, or we don't have a |
560 // backing store. | 567 // backing store. |
561 if (!backing_store_.get() || !navigate_src_sent_) | 568 if (!backing_store_.get() || !navigate_src_sent_) |
562 return; | 569 return; |
563 float inverse_scale_factor = 1.0f / backing_store_->GetScaleFactor(); | 570 float inverse_scale_factor = 1.0f / backing_store_->GetScaleFactor(); |
564 canvas->scale(inverse_scale_factor, inverse_scale_factor); | 571 canvas->scale(inverse_scale_factor, inverse_scale_factor); |
565 canvas->drawBitmap(backing_store_->GetBitmap(), 0, 0); | 572 canvas->drawBitmap(backing_store_->GetBitmap(), 0, 0); |
566 } | 573 } |
567 | 574 |
568 void BrowserPlugin::updateGeometry( | 575 void BrowserPlugin::updateGeometry( |
569 const WebRect& window_rect, | 576 const WebRect& window_rect, |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 void* notify_data) { | 757 void* notify_data) { |
751 } | 758 } |
752 | 759 |
753 void BrowserPlugin::didFailLoadingFrameRequest( | 760 void BrowserPlugin::didFailLoadingFrameRequest( |
754 const WebKit::WebURL& url, | 761 const WebKit::WebURL& url, |
755 void* notify_data, | 762 void* notify_data, |
756 const WebKit::WebURLError& error) { | 763 const WebKit::WebURLError& error) { |
757 } | 764 } |
758 | 765 |
759 } // namespace content | 766 } // namespace content |
OLD | NEW |