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

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: Providing implementations for the other platforms 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 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(); 501 const GURL& url = web_contents->GetURL();
502 Profile* profile = 502 Profile* profile =
503 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 503 Profile::FromBrowserContext(web_contents->GetBrowserContext());
504 history::TopSites* top_sites = profile->GetTopSites(); 504 history::TopSites* top_sites = profile->GetTopSites();
505 bool has_surface = web_contents->GetRenderWidgetHostView()->HasSurface();
505 // Skip if we don't need to update the thumbnail. 506 // Skip if we don't need to update the thumbnail.
506 if (!ShouldUpdateThumbnail(profile, top_sites, url)) 507 if (!ShouldUpdateThumbnail(profile, top_sites, url, has_surface))
507 return; 508 return;
508 509
509 AsyncUpdateThumbnail(web_contents); 510 AsyncUpdateThumbnail(web_contents);
510 } 511 }
511 512
512 void ThumbnailGenerator::UpdateThumbnail( 513 void ThumbnailGenerator::UpdateThumbnail(
513 WebContents* web_contents, const SkBitmap& thumbnail, 514 WebContents* web_contents, const SkBitmap& thumbnail,
514 const ThumbnailGenerator::ClipResult& clip_result) { 515 const ThumbnailGenerator::ClipResult& clip_result) {
515 516
516 Profile* profile = 517 Profile* profile =
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 SkBitmap thumbnail = CreateThumbnail(bmp_with_scrollbars, 577 SkBitmap thumbnail = CreateThumbnail(bmp_with_scrollbars,
577 kThumbnailWidth, 578 kThumbnailWidth,
578 kThumbnailHeight, 579 kThumbnailHeight,
579 ThumbnailGenerator::kClippedThumbnail, 580 ThumbnailGenerator::kClippedThumbnail,
580 &clip_result); 581 &clip_result);
581 UpdateThumbnail(web_contents.get(), thumbnail, clip_result); 582 UpdateThumbnail(web_contents.get(), thumbnail, clip_result);
582 } 583 }
583 584
584 bool ThumbnailGenerator::ShouldUpdateThumbnail(Profile* profile, 585 bool ThumbnailGenerator::ShouldUpdateThumbnail(Profile* profile,
585 history::TopSites* top_sites, 586 history::TopSites* top_sites,
586 const GURL& url) { 587 const GURL& url,
588 bool has_surface) {
589 if (!has_surface)
590 return false;
587 if (!profile || !top_sites) 591 if (!profile || !top_sites)
588 return false; 592 return false;
589 // Skip if it's in the incognito mode. 593 // Skip if it's in the incognito mode.
590 if (profile->IsOffTheRecord()) 594 if (profile->IsOffTheRecord())
591 return false; 595 return false;
592 // Skip if the given URL is not appropriate for history. 596 // Skip if the given URL is not appropriate for history.
593 if (!HistoryService::CanAddURL(url)) 597 if (!HistoryService::CanAddURL(url))
594 return false; 598 return false;
595 // Skip if the top sites list is full, and the URL is not known. 599 // Skip if the top sites list is full, and the URL is not known.
596 if (top_sites->IsFull() && !top_sites->IsKnownURL(url)) 600 if (top_sites->IsFull() && !top_sites->IsKnownURL(url))
(...skipping 15 matching lines...) Expand all
612 616
613 void ThumbnailGenerator::DidStartLoading() { 617 void ThumbnailGenerator::DidStartLoading() {
614 load_interrupted_ = false; 618 load_interrupted_ = false;
615 } 619 }
616 620
617 void ThumbnailGenerator::StopNavigation() { 621 void ThumbnailGenerator::StopNavigation() {
618 // This function gets called when the page loading is interrupted by the 622 // This function gets called when the page loading is interrupted by the
619 // stop button. 623 // stop button.
620 load_interrupted_ = true; 624 load_interrupted_ = true;
621 } 625 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698