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/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 | 657 |
658 top_sites->SetPageThumbnail(url, thumbnail, score); | 658 top_sites->SetPageThumbnail(url, thumbnail, score); |
659 VLOG(1) << "Thumbnail taken for " << url << ": " << score.ToString(); | 659 VLOG(1) << "Thumbnail taken for " << url << ": " << score.ToString(); |
660 } | 660 } |
661 | 661 |
662 bool ThumbnailGenerator::ShouldUpdateThumbnail(Profile* profile, | 662 bool ThumbnailGenerator::ShouldUpdateThumbnail(Profile* profile, |
663 history::TopSites* top_sites, | 663 history::TopSites* top_sites, |
664 const GURL& url) { | 664 const GURL& url) { |
665 if (!profile || !top_sites) | 665 if (!profile || !top_sites) |
666 return false; | 666 return false; |
667 // Skip if it's in the off-the-record mode. | 667 // Skip if it's in the incognito mode. |
668 if (profile->IsOffTheRecord()) | 668 if (profile->IsOffTheRecord()) |
669 return false; | 669 return false; |
670 // Skip if the given URL is not appropriate for history. | 670 // Skip if the given URL is not appropriate for history. |
671 if (!HistoryService::CanAddURL(url)) | 671 if (!HistoryService::CanAddURL(url)) |
672 return false; | 672 return false; |
673 // Skip if the top sites list is full, and the URL is not known. | 673 // Skip if the top sites list is full, and the URL is not known. |
674 const bool is_known = top_sites->IsKnownURL(url); | 674 const bool is_known = top_sites->IsKnownURL(url); |
675 if (top_sites->IsFull() && !is_known) | 675 if (top_sites->IsFull() && !is_known) |
676 return false; | 676 return false; |
677 // Skip if we don't have to udpate the existing thumbnail. | 677 // Skip if we don't have to udpate the existing thumbnail. |
678 ThumbnailScore current_score; | 678 ThumbnailScore current_score; |
679 if (is_known && | 679 if (is_known && |
680 top_sites->GetPageThumbnailScore(url, ¤t_score) && | 680 top_sites->GetPageThumbnailScore(url, ¤t_score) && |
681 !current_score.ShouldConsiderUpdating()) | 681 !current_score.ShouldConsiderUpdating()) |
682 return false; | 682 return false; |
683 | 683 |
684 return true; | 684 return true; |
685 } | 685 } |
OLD | NEW |