| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 } | 433 } |
| 434 | 434 |
| 435 SkBitmap clipped_bitmap; | 435 SkBitmap clipped_bitmap; |
| 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 TabContents* tab_contents) { | 441 TabContents* tab_contents) { |
| 442 const GURL& url = tab_contents->GetURL(); | 442 const GURL& url = tab_contents->GetURL(); |
| 443 history::TopSites* top_sites = tab_contents->profile()->GetTopSites(); | 443 Profile* profile = static_cast<Profile*>(tab_contents->browser_context()); |
| 444 history::TopSites* top_sites = profile->GetTopSites(); |
| 444 // Skip if we don't need to update the thumbnail. | 445 // Skip if we don't need to update the thumbnail. |
| 445 if (!ShouldUpdateThumbnail(tab_contents->profile(), top_sites, url)) | 446 if (!ShouldUpdateThumbnail(profile, top_sites, url)) |
| 446 return; | 447 return; |
| 447 | 448 |
| 448 const int options = ThumbnailGenerator::kClippedThumbnail; | 449 const int options = ThumbnailGenerator::kClippedThumbnail; |
| 449 ThumbnailGenerator::ClipResult clip_result = ThumbnailGenerator::kNotClipped; | 450 ThumbnailGenerator::ClipResult clip_result = ThumbnailGenerator::kNotClipped; |
| 450 SkBitmap thumbnail = GetThumbnailForRendererWithOptions( | 451 SkBitmap thumbnail = GetThumbnailForRendererWithOptions( |
| 451 tab_contents->render_view_host(), options, &clip_result); | 452 tab_contents->render_view_host(), options, &clip_result); |
| 452 // Failed to generate a thumbnail. Maybe the tab is in the background? | 453 // Failed to generate a thumbnail. Maybe the tab is in the background? |
| 453 if (thumbnail.isNull()) | 454 if (thumbnail.isNull()) |
| 454 return; | 455 return; |
| 455 | 456 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 | 499 |
| 499 void ThumbnailGenerator::DidStartLoading() { | 500 void ThumbnailGenerator::DidStartLoading() { |
| 500 load_interrupted_ = false; | 501 load_interrupted_ = false; |
| 501 } | 502 } |
| 502 | 503 |
| 503 void ThumbnailGenerator::StopNavigation() { | 504 void ThumbnailGenerator::StopNavigation() { |
| 504 // This function gets called when the page loading is interrupted by the | 505 // This function gets called when the page loading is interrupted by the |
| 505 // stop button. | 506 // stop button. |
| 506 load_interrupted_ = true; | 507 load_interrupted_ = true; |
| 507 } | 508 } |
| OLD | NEW |