Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4737)

Unified Diff: chrome/browser/history/top_sites.cc

Issue 3135035: Fix broken thumbnails for sites with redirects. (Closed)
Patch Set: Comment. Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/history/top_sites.h ('k') | chrome/browser/history/top_sites_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/history/top_sites.cc
diff --git a/chrome/browser/history/top_sites.cc b/chrome/browser/history/top_sites.cc
index c0e458078ba455f9e31fa91ed0c89f5782e090ef..b6dc22663fb7a92714f01653c3caf4e949544bc2 100644
--- a/chrome/browser/history/top_sites.cc
+++ b/chrome/browser/history/top_sites.cc
@@ -249,7 +249,8 @@ void TopSites::GetMostVisitedURLs(CancelableRequestConsumer* consumer,
bool TopSites::GetPageThumbnail(const GURL& url, RefCountedBytes** data) const {
AutoLock lock(lock_);
- std::map<GURL, Images>::const_iterator found = top_images_.find(url);
+ std::map<GURL, Images>::const_iterator found =
+ top_images_.find(GetCanonicalURL(url));
if (found == top_images_.end()) {
found = temp_thumbnails_map_.find(url);
if (found == temp_thumbnails_map_.end())
@@ -379,7 +380,9 @@ std::string TopSites::GetURLString(const GURL& url) {
std::string TopSites::GetURLHash(const GURL& url) {
lock_.AssertAcquired();
- return MD5String(GetCanonicalURL(url).spec());
+ // We don't use canonical URLs here to be able to blacklist only one of
+ // the two 'duplicate' sites, e.g. 'gmail.com' and 'mail.google.com'.
+ return MD5String(url.spec());
}
void TopSites::UpdateMostVisited(MostVisitedURLList most_visited) {
@@ -565,8 +568,11 @@ void TopSites::StoreRedirectChain(const RedirectList& redirects,
}
// Map all the redirected URLs to the destination.
- for (size_t i = 0; i < redirects.size(); i++)
- canonical_urls_[redirects[i]] = destination;
+ for (size_t i = 0; i < redirects.size(); i++) {
+ // If this redirect is already known, don't replace it with a new one.
+ if (canonical_urls_.find(redirects[i]) == canonical_urls_.end())
+ canonical_urls_[redirects[i]] = destination;
+ }
}
GURL TopSites::GetCanonicalURL(const GURL& url) const {
@@ -634,7 +640,7 @@ void TopSites::StartQueryForMostVisited() {
// Testing with a mockup.
// QueryMostVisitedURLs is not virtual, so we have to duplicate the code.
mock_history_service_->QueryMostVisitedURLs(
- kTopSitesNumber,
+ kTopSitesNumber + blacklist_->size(),
kDaysOfHistory,
&cancelable_consumer_,
NewCallback(this, &TopSites::OnTopSitesAvailable));
@@ -646,7 +652,7 @@ void TopSites::StartQueryForMostVisited() {
// |hs| may be null during unit tests.
if (hs) {
hs->QueryMostVisitedURLs(
- kTopSitesNumber,
+ kTopSitesNumber + blacklist_->size(),
kDaysOfHistory,
&cancelable_consumer_,
NewCallback(this, &TopSites::OnTopSitesAvailable));
@@ -764,7 +770,6 @@ base::TimeDelta TopSites::GetUpdateDelay() {
void TopSites::OnTopSitesAvailable(
CancelableRequestProvider::Handle handle,
MostVisitedURLList pages) {
-
AddPrepopulatedPages(&pages);
ChromeThread::PostTask(ChromeThread::DB, FROM_HERE, NewRunnableMethod(
this, &TopSites::UpdateMostVisited, pages));
« no previous file with comments | « chrome/browser/history/top_sites.h ('k') | chrome/browser/history/top_sites_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698