| 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 "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 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 bitmap.extractSubset(&clipped_bitmap, src_rect); | 436 bitmap.extractSubset(&clipped_bitmap, src_rect); |
| 437 return clipped_bitmap; | 437 return clipped_bitmap; |
| 438 } | 438 } |
| 439 | 439 |
| 440 void ThumbnailGenerator::UpdateThumbnailIfNecessary( | 440 void ThumbnailGenerator::UpdateThumbnailIfNecessary( |
| 441 WebContents* web_contents) { | 441 WebContents* web_contents) { |
| 442 const GURL& url = web_contents->GetURL(); | 442 const GURL& url = web_contents->GetURL(); |
| 443 Profile* profile = | 443 Profile* profile = |
| 444 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 444 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 445 history::TopSites* top_sites = profile->GetTopSites(); | 445 history::TopSites* top_sites = profile->GetTopSites(); |
| 446 bool surface_available = |
| 447 web_contents->GetRenderWidgetHostView()->IsSurfaceAvailableForCopy(); |
| 448 // Skip if we can't update the thumbnail. |
| 449 if (!surface_available) |
| 450 return; |
| 446 // Skip if we don't need to update the thumbnail. | 451 // Skip if we don't need to update the thumbnail. |
| 447 if (!ShouldUpdateThumbnail(profile, top_sites, url)) | 452 if (!ShouldUpdateThumbnail(profile, top_sites, url)) |
| 448 return; | 453 return; |
| 449 | 454 |
| 450 AsyncUpdateThumbnail(web_contents); | 455 AsyncUpdateThumbnail(web_contents); |
| 451 } | 456 } |
| 452 | 457 |
| 453 void ThumbnailGenerator::UpdateThumbnail( | 458 void ThumbnailGenerator::UpdateThumbnail( |
| 454 WebContents* web_contents, const SkBitmap& thumbnail, | 459 WebContents* web_contents, const SkBitmap& thumbnail, |
| 455 const ThumbnailGenerator::ClipResult& clip_result) { | 460 const ThumbnailGenerator::ClipResult& clip_result) { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 | 558 |
| 554 void ThumbnailGenerator::DidStartLoading() { | 559 void ThumbnailGenerator::DidStartLoading() { |
| 555 load_interrupted_ = false; | 560 load_interrupted_ = false; |
| 556 } | 561 } |
| 557 | 562 |
| 558 void ThumbnailGenerator::StopNavigation() { | 563 void ThumbnailGenerator::StopNavigation() { |
| 559 // This function gets called when the page loading is interrupted by the | 564 // This function gets called when the page loading is interrupted by the |
| 560 // stop button. | 565 // stop button. |
| 561 load_interrupted_ = true; | 566 load_interrupted_ = true; |
| 562 } | 567 } |
| OLD | NEW |