| 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/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 | 475 |
| 476 Profile* profile = | 476 Profile* profile = |
| 477 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 477 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 478 history::TopSites* top_sites = profile->GetTopSites(); | 478 history::TopSites* top_sites = profile->GetTopSites(); |
| 479 if (!top_sites) | 479 if (!top_sites) |
| 480 return; | 480 return; |
| 481 | 481 |
| 482 // Compute the thumbnail score. | 482 // Compute the thumbnail score. |
| 483 ThumbnailScore score; | 483 ThumbnailScore score; |
| 484 score.at_top = | 484 score.at_top = |
| 485 (web_contents->GetRenderViewHost()->last_scroll_offset().y() == 0); | 485 (web_contents->GetRenderViewHost()->GetLastScrollOffset().y() == 0); |
| 486 score.boring_score = ThumbnailGenerator::CalculateBoringScore(&thumbnail); | 486 score.boring_score = ThumbnailGenerator::CalculateBoringScore(&thumbnail); |
| 487 score.good_clipping = | 487 score.good_clipping = |
| 488 (clip_result == ThumbnailGenerator::kTallerThanWide || | 488 (clip_result == ThumbnailGenerator::kTallerThanWide || |
| 489 clip_result == ThumbnailGenerator::kNotClipped); | 489 clip_result == ThumbnailGenerator::kNotClipped); |
| 490 score.load_completed = (!load_interrupted_ && !web_contents->IsLoading()); | 490 score.load_completed = (!load_interrupted_ && !web_contents->IsLoading()); |
| 491 | 491 |
| 492 gfx::Image image(new SkBitmap(thumbnail)); | 492 gfx::Image image(new SkBitmap(thumbnail)); |
| 493 const GURL& url = web_contents->GetURL(); | 493 const GURL& url = web_contents->GetURL(); |
| 494 top_sites->SetPageThumbnail(url, &image, score); | 494 top_sites->SetPageThumbnail(url, &image, score); |
| 495 VLOG(1) << "Thumbnail taken for " << url << ": " << score.ToString(); | 495 VLOG(1) << "Thumbnail taken for " << url << ": " << score.ToString(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 526 | 526 |
| 527 void ThumbnailGenerator::DidStartLoading() { | 527 void ThumbnailGenerator::DidStartLoading() { |
| 528 load_interrupted_ = false; | 528 load_interrupted_ = false; |
| 529 } | 529 } |
| 530 | 530 |
| 531 void ThumbnailGenerator::StopNavigation() { | 531 void ThumbnailGenerator::StopNavigation() { |
| 532 // This function gets called when the page loading is interrupted by the | 532 // This function gets called when the page loading is interrupted by the |
| 533 // stop button. | 533 // stop button. |
| 534 load_interrupted_ = true; | 534 load_interrupted_ = true; |
| 535 } | 535 } |
| OLD | NEW |