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

Side by Side Diff: chrome/browser/tab_contents/thumbnail_generator.cc

Issue 10349013: Prevent browser thumbnailer from trying to read from frontbuffer (surface texture) when none exists. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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 "chrome/browser/tab_contents/thumbnail_generator.h" 5 #include "chrome/browser/tab_contents/thumbnail_generator.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 } 491 }
492 } 492 }
493 493
494 SkBitmap clipped_bitmap; 494 SkBitmap clipped_bitmap;
495 bitmap.extractSubset(&clipped_bitmap, src_rect); 495 bitmap.extractSubset(&clipped_bitmap, src_rect);
496 return clipped_bitmap; 496 return clipped_bitmap;
497 } 497 }
498 498
499 void ThumbnailGenerator::UpdateThumbnailIfNecessary( 499 void ThumbnailGenerator::UpdateThumbnailIfNecessary(
500 WebContents* web_contents) { 500 WebContents* web_contents) {
501 const GURL& url = web_contents->GetURL();
502 Profile* profile =
503 Profile::FromBrowserContext(web_contents->GetBrowserContext());
504 history::TopSites* top_sites = profile->GetTopSites();
505 // Skip if we don't need to update the thumbnail. 501 // Skip if we don't need to update the thumbnail.
506 if (!ShouldUpdateThumbnail(profile, top_sites, url)) 502 if (!ShouldUpdateThumbnail(web_contents))
507 return; 503 return;
508 504
509 AsyncUpdateThumbnail(web_contents); 505 AsyncUpdateThumbnail(web_contents);
510 } 506 }
511 507
512 void ThumbnailGenerator::UpdateThumbnail( 508 void ThumbnailGenerator::UpdateThumbnail(
513 WebContents* web_contents, const SkBitmap& thumbnail, 509 WebContents* web_contents, const SkBitmap& thumbnail,
514 const ThumbnailGenerator::ClipResult& clip_result) { 510 const ThumbnailGenerator::ClipResult& clip_result) {
515 511
516 Profile* profile = 512 Profile* profile =
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 skia::GetTopDevice(*temp_canvas)->accessBitmap(false); 570 skia::GetTopDevice(*temp_canvas)->accessBitmap(false);
575 ClipResult clip_result; 571 ClipResult clip_result;
576 SkBitmap thumbnail = CreateThumbnail(bmp_with_scrollbars, 572 SkBitmap thumbnail = CreateThumbnail(bmp_with_scrollbars,
577 kThumbnailWidth, 573 kThumbnailWidth,
578 kThumbnailHeight, 574 kThumbnailHeight,
579 ThumbnailGenerator::kClippedThumbnail, 575 ThumbnailGenerator::kClippedThumbnail,
580 &clip_result); 576 &clip_result);
581 UpdateThumbnail(web_contents.get(), thumbnail, clip_result); 577 UpdateThumbnail(web_contents.get(), thumbnail, clip_result);
582 } 578 }
583 579
584 bool ThumbnailGenerator::ShouldUpdateThumbnail(Profile* profile, 580 bool ThumbnailGenerator::ShouldUpdateThumbnail(
585 history::TopSites* top_sites, 581 content::WebContents* web_contents) {
586 const GURL& url) { 582 const GURL& url = web_contents->GetURL();
583 Profile* profile =
584 Profile::FromBrowserContext(web_contents->GetBrowserContext());
mazda 2012/05/03 19:57:31 NULL check for profile is needed.
585 history::TopSites* top_sites = profile->GetTopSites();
mazda 2012/05/03 19:57:31 Could you move this just before |top_sites| is use
586 content::RenderWidgetHostView* rwhv = web_contents->GetRenderWidgetHostView();
587 if (!rwhv->HasSurface())
mazda 2012/05/03 19:57:31 In order to use this function here, it needs to ha
588 return false;
587 if (!profile || !top_sites) 589 if (!profile || !top_sites)
mazda 2012/05/03 19:57:31 Please delete this with the changes above.
588 return false; 590 return false;
589 // Skip if it's in the incognito mode. 591 // Skip if it's in the incognito mode.
590 if (profile->IsOffTheRecord()) 592 if (profile->IsOffTheRecord())
591 return false; 593 return false;
592 // Skip if the given URL is not appropriate for history. 594 // Skip if the given URL is not appropriate for history.
593 if (!HistoryService::CanAddURL(url)) 595 if (!HistoryService::CanAddURL(url))
594 return false; 596 return false;
595 // Skip if the top sites list is full, and the URL is not known. 597 // Skip if the top sites list is full, and the URL is not known.
596 if (top_sites->IsFull() && !top_sites->IsKnownURL(url)) 598 if (top_sites->IsFull() && !top_sites->IsKnownURL(url))
597 return false; 599 return false;
(...skipping 14 matching lines...) Expand all
612 614
613 void ThumbnailGenerator::DidStartLoading() { 615 void ThumbnailGenerator::DidStartLoading() {
614 load_interrupted_ = false; 616 load_interrupted_ = false;
615 } 617 }
616 618
617 void ThumbnailGenerator::StopNavigation() { 619 void ThumbnailGenerator::StopNavigation() {
618 // This function gets called when the page loading is interrupted by the 620 // This function gets called when the page loading is interrupted by the
619 // stop button. 621 // stop button.
620 load_interrupted_ = true; 622 load_interrupted_ = true;
621 } 623 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698