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

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: Renaming HasSurface to IsSurfaceAvailableForCopy 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 surface_available =
506 web_contents->GetRenderWidgetHostView()->IsSurfaceAvailableForCopy();
505 // Skip if we don't need to update the thumbnail. 507 // Skip if we don't need to update the thumbnail.
506 if (!ShouldUpdateThumbnail(profile, top_sites, url)) 508 if (!ShouldUpdateThumbnail(profile, top_sites, url, surface_available))
mazda 2012/05/04 22:20:32 How about just doing as follows? if (!surface_ava
mmocny 2012/05/07 13:28:23 Yes, it is certainly a bit silly to move the bool
mazda 2012/05/07 16:37:19 We do not plan to use ShouldUpdateThumbnail in oth
507 return; 509 return;
508 510
509 AsyncUpdateThumbnail(web_contents); 511 AsyncUpdateThumbnail(web_contents);
510 } 512 }
511 513
512 void ThumbnailGenerator::UpdateThumbnail( 514 void ThumbnailGenerator::UpdateThumbnail(
513 WebContents* web_contents, const SkBitmap& thumbnail, 515 WebContents* web_contents, const SkBitmap& thumbnail,
514 const ThumbnailGenerator::ClipResult& clip_result) { 516 const ThumbnailGenerator::ClipResult& clip_result) {
515 517
516 Profile* profile = 518 Profile* profile =
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 SkBitmap thumbnail = CreateThumbnail(bmp_with_scrollbars, 578 SkBitmap thumbnail = CreateThumbnail(bmp_with_scrollbars,
577 kThumbnailWidth, 579 kThumbnailWidth,
578 kThumbnailHeight, 580 kThumbnailHeight,
579 ThumbnailGenerator::kClippedThumbnail, 581 ThumbnailGenerator::kClippedThumbnail,
580 &clip_result); 582 &clip_result);
581 UpdateThumbnail(web_contents.get(), thumbnail, clip_result); 583 UpdateThumbnail(web_contents.get(), thumbnail, clip_result);
582 } 584 }
583 585
584 bool ThumbnailGenerator::ShouldUpdateThumbnail(Profile* profile, 586 bool ThumbnailGenerator::ShouldUpdateThumbnail(Profile* profile,
585 history::TopSites* top_sites, 587 history::TopSites* top_sites,
586 const GURL& url) { 588 const GURL& url,
589 bool surface_available) {
590 if (!surface_available)
591 return false;
587 if (!profile || !top_sites) 592 if (!profile || !top_sites)
588 return false; 593 return false;
589 // Skip if it's in the incognito mode. 594 // Skip if it's in the incognito mode.
590 if (profile->IsOffTheRecord()) 595 if (profile->IsOffTheRecord())
591 return false; 596 return false;
592 // Skip if the given URL is not appropriate for history. 597 // Skip if the given URL is not appropriate for history.
593 if (!HistoryService::CanAddURL(url)) 598 if (!HistoryService::CanAddURL(url))
594 return false; 599 return false;
595 // Skip if the top sites list is full, and the URL is not known. 600 // Skip if the top sites list is full, and the URL is not known.
596 if (top_sites->IsFull() && !top_sites->IsKnownURL(url)) 601 if (top_sites->IsFull() && !top_sites->IsKnownURL(url))
(...skipping 15 matching lines...) Expand all
612 617
613 void ThumbnailGenerator::DidStartLoading() { 618 void ThumbnailGenerator::DidStartLoading() {
614 load_interrupted_ = false; 619 load_interrupted_ = false;
615 } 620 }
616 621
617 void ThumbnailGenerator::StopNavigation() { 622 void ThumbnailGenerator::StopNavigation() {
618 // This function gets called when the page loading is interrupted by the 623 // This function gets called when the page loading is interrupted by the
619 // stop button. 624 // stop button.
620 load_interrupted_ = true; 625 load_interrupted_ = true;
621 } 626 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/thumbnail_generator.h ('k') | chrome/browser/tab_contents/thumbnail_generator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698