| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/history/top_sites_impl.h" | 5 #include "chrome/browser/history/top_sites_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 144 |
| 145 bool add_temp_thumbnail = false; | 145 bool add_temp_thumbnail = false; |
| 146 if (!IsKnownURL(url)) { | 146 if (!IsKnownURL(url)) { |
| 147 if (!IsNonForcedFull()) { | 147 if (!IsNonForcedFull()) { |
| 148 add_temp_thumbnail = true; | 148 add_temp_thumbnail = true; |
| 149 } else { | 149 } else { |
| 150 return false; // This URL is not known to us. | 150 return false; // This URL is not known to us. |
| 151 } | 151 } |
| 152 } | 152 } |
| 153 | 153 |
| 154 if (!HistoryService::CanAddURL(url)) | 154 if (!CanAddURL(url)) |
| 155 return false; // It's not a real webpage. | 155 return false; // It's not a real webpage. |
| 156 | 156 |
| 157 scoped_refptr<base::RefCountedBytes> thumbnail_data; | 157 scoped_refptr<base::RefCountedBytes> thumbnail_data; |
| 158 if (!EncodeBitmap(thumbnail, &thumbnail_data)) | 158 if (!EncodeBitmap(thumbnail, &thumbnail_data)) |
| 159 return false; | 159 return false; |
| 160 | 160 |
| 161 if (add_temp_thumbnail) { | 161 if (add_temp_thumbnail) { |
| 162 // Always remove the existing entry and then add it back. That way if we end | 162 // Always remove the existing entry and then add it back. That way if we end |
| 163 // up with too many temp thumbnails we'll prune the oldest first. | 163 // up with too many temp thumbnails we'll prune the oldest first. |
| 164 RemoveTemporaryThumbnailByURL(url); | 164 RemoveTemporaryThumbnailByURL(url); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 183 | 183 |
| 184 bool add_temp_thumbnail = false; | 184 bool add_temp_thumbnail = false; |
| 185 if (!IsKnownURL(url)) { | 185 if (!IsKnownURL(url)) { |
| 186 if (!IsNonForcedFull()) { | 186 if (!IsNonForcedFull()) { |
| 187 add_temp_thumbnail = true; | 187 add_temp_thumbnail = true; |
| 188 } else { | 188 } else { |
| 189 return false; // This URL is not known to us. | 189 return false; // This URL is not known to us. |
| 190 } | 190 } |
| 191 } | 191 } |
| 192 | 192 |
| 193 if (!HistoryService::CanAddURL(url)) | 193 if (!CanAddURL(url)) |
| 194 return false; // It's not a real webpage. | 194 return false; // It's not a real webpage. |
| 195 | 195 |
| 196 if (add_temp_thumbnail) { | 196 if (add_temp_thumbnail) { |
| 197 // Always remove the existing entry and then add it back. That way if we end | 197 // Always remove the existing entry and then add it back. That way if we end |
| 198 // up with too many temp thumbnails we'll prune the oldest first. | 198 // up with too many temp thumbnails we'll prune the oldest first. |
| 199 RemoveTemporaryThumbnailByURL(url); | 199 RemoveTemporaryThumbnailByURL(url); |
| 200 AddTemporaryThumbnail(url, memory, score); | 200 AddTemporaryThumbnail(url, memory, score); |
| 201 return true; | 201 return true; |
| 202 } | 202 } |
| 203 | 203 |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 NavigationController* controller = | 770 NavigationController* controller = |
| 771 content::Source<NavigationController>(source).ptr(); | 771 content::Source<NavigationController>(source).ptr(); |
| 772 Profile* profile = Profile::FromBrowserContext( | 772 Profile* profile = Profile::FromBrowserContext( |
| 773 controller->GetWebContents()->GetBrowserContext()); | 773 controller->GetWebContents()->GetBrowserContext()); |
| 774 if (profile == profile_ && !IsNonForcedFull()) { | 774 if (profile == profile_ && !IsNonForcedFull()) { |
| 775 content::LoadCommittedDetails* load_details = | 775 content::LoadCommittedDetails* load_details = |
| 776 content::Details<content::LoadCommittedDetails>(details).ptr(); | 776 content::Details<content::LoadCommittedDetails>(details).ptr(); |
| 777 if (!load_details) | 777 if (!load_details) |
| 778 return; | 778 return; |
| 779 const GURL& url = load_details->entry->GetURL(); | 779 const GURL& url = load_details->entry->GetURL(); |
| 780 if (!cache_->IsKnownURL(url) && HistoryService::CanAddURL(url)) { | 780 if (!cache_->IsKnownURL(url) && CanAddURL(url)) { |
| 781 // To avoid slamming history we throttle requests when the url updates. | 781 // To avoid slamming history we throttle requests when the url updates. |
| 782 // To do otherwise negatively impacts perf tests. | 782 // To do otherwise negatively impacts perf tests. |
| 783 RestartQueryForTopSitesTimer(GetUpdateDelay()); | 783 RestartQueryForTopSitesTimer(GetUpdateDelay()); |
| 784 } | 784 } |
| 785 } | 785 } |
| 786 } | 786 } |
| 787 } | 787 } |
| 788 | 788 |
| 789 void TopSitesImpl::SetTopSites(const MostVisitedURLList& new_top_sites) { | 789 void TopSitesImpl::SetTopSites(const MostVisitedURLList& new_top_sites) { |
| 790 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 790 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 919 base::TimeDelta::FromSeconds(kUpdateIntervalSecs)); | 919 base::TimeDelta::FromSeconds(kUpdateIntervalSecs)); |
| 920 } | 920 } |
| 921 | 921 |
| 922 void TopSitesImpl::OnTopSitesAvailableFromHistory( | 922 void TopSitesImpl::OnTopSitesAvailableFromHistory( |
| 923 const MostVisitedURLList* pages) { | 923 const MostVisitedURLList* pages) { |
| 924 DCHECK(pages); | 924 DCHECK(pages); |
| 925 SetTopSites(*pages); | 925 SetTopSites(*pages); |
| 926 } | 926 } |
| 927 | 927 |
| 928 } // namespace history | 928 } // namespace history |
| OLD | NEW |