diff options
author | joshia@google.com <joshia@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-12 01:17:15 +0000 |
---|---|---|
committer | joshia@google.com <joshia@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-12 01:17:15 +0000 |
commit | b6e4beca3a071606c537af2d55eba21d99769cb0 (patch) | |
tree | fa20b394752eb03839814b409a31c01601c9ebb9 /chrome/renderer/render_view.cc | |
parent | 799edbdbd3aadc8044bccf4e10bf6a3ebfef1d6b (diff) | |
download | chromium_src-b6e4beca3a071606c537af2d55eba21d99769cb0.zip chromium_src-b6e4beca3a071606c537af2d55eba21d99769cb0.tar.gz chromium_src-b6e4beca3a071606c537af2d55eba21d99769cb0.tar.bz2 |
Prevent crash due to DIB allocation failure
Change the way we capture tab thumbnail images so that
the capturing code can deal with failure.
BUG=3795
Review URL: http://codereview.chromium.org/9717
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5244 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/render_view.cc')
-rw-r--r-- | chrome/renderer/render_view.cc | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index bac75d8..30cd633 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -422,8 +422,10 @@ void RenderView::SendThumbnail() { ThumbnailScore score; SkBitmap thumbnail; - CaptureThumbnail(main_frame, kThumbnailWidth, kThumbnailHeight, &thumbnail, - &score); + if (!CaptureThumbnail(main_frame, kThumbnailWidth, kThumbnailHeight, + &thumbnail, &score)) + return; + // send the thumbnail message to the browser process IPC::Message* thumbnail_msg = new IPC::Message(routing_id_, ViewHostMsg_Thumbnail::ID, IPC::Message::PRIORITY_NORMAL); @@ -739,7 +741,7 @@ void RenderView::CaptureText(WebFrame* frame, std::wstring* contents) { } } -void RenderView::CaptureThumbnail(WebFrame* frame, +bool RenderView::CaptureThumbnail(WebFrame* frame, int w, int h, SkBitmap* thumbnail, @@ -748,8 +750,11 @@ void RenderView::CaptureThumbnail(WebFrame* frame, double begin = time_util::GetHighResolutionTimeNow(); #endif - gfx::BitmapPlatformDeviceWin device(frame->CaptureImage(true)); - const SkBitmap& src_bmp = device.accessBitmap(false); + scoped_ptr<gfx::BitmapPlatformDevice> device; + if (!frame->CaptureImage(&device, true)) + return false; + + const SkBitmap& src_bmp = device->accessBitmap(false); SkRect dest_rect; dest_rect.set(0, 0, SkIntToScalar(w), SkIntToScalar(h)); @@ -785,7 +790,7 @@ void RenderView::CaptureThumbnail(WebFrame* frame, score->at_top = (frame->ScrollOffset().height() == 0); SkBitmap subset; - device.accessBitmap(false).extractSubset(&subset, src_rect); + device->accessBitmap(false).extractSubset(&subset, src_rect); // Resample the subset that we want to get it the right size. *thumbnail = gfx::ImageOperations::Resize( @@ -799,6 +804,7 @@ void RenderView::CaptureThumbnail(WebFrame* frame, sprintf_s(buf, "thumbnail in %gms\n", (end - begin) * 1000); OutputDebugStringA(buf); #endif + return true; } double RenderView::CalculateBoringScore(SkBitmap* bitmap) { |