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

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

Issue 59903010: Ensure using chrome://thumb2/... adds the URL as a forced URL in TopSites so that a thumbnail is ca… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Take 2. Created 7 years, 1 month 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_impl.h ('k') | chrome/browser/history/top_sites_impl_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_impl.cc
diff --git a/chrome/browser/history/top_sites_impl.cc b/chrome/browser/history/top_sites_impl.cc
index 9eb3a00694f7a060f98cdb30e5dfadc134aca212..40f78fce1bd49afb2299049a584dc73725f7eefb 100644
--- a/chrome/browser/history/top_sites_impl.cc
+++ b/chrome/browser/history/top_sites_impl.cc
@@ -607,6 +607,39 @@ bool TopSitesImpl::loaded() const {
return loaded_;
}
+bool TopSitesImpl::AddForcedURL(const GURL& url, const base::Time& time) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ size_t num_forced = cache_->GetNumForcedURLs();
+ MostVisitedURLList new_list(cache_->top_sites());
+ MostVisitedURL new_url;
+
+ if (cache_->IsKnownURL(url)) {
+ size_t index = cache_->GetURLIndex(url);
+ // Do nothing if we currently have that URL as non-forced.
+ if (new_list[index].last_forced_time.is_null())
+ return false;
+
+ // Update the |last_forced_time| of the already existing URL. Delete it and
+ // reinsert it at the right location.
+ new_url = new_list[index];
+ new_list.erase(new_list.begin() + index);
+ num_forced--;
+ } else {
+ new_url.url = url;
+ new_url.redirects.push_back(url);
+ }
+ new_url.last_forced_time = time;
+ // Add forced URLs and sort. Added to the end of the list of forced URLs
+ // since this is almost always where it needs to go, unless the user's local
+ // clock is fiddled with.
+ MostVisitedURLList::iterator mid = new_list.begin() + num_forced;
+ new_list.insert(mid, new_url);
+ mid = new_list.begin() + num_forced; // Mid was invalidated.
+ std::inplace_merge(new_list.begin(), mid, mid + 1, ForcedURLComparator);
+ SetTopSites(new_list);
+ return true;
+}
+
bool TopSitesImpl::AddPrepopulatedPages(MostVisitedURLList* urls,
size_t num_forced_urls) {
bool added = false;
« no previous file with comments | « chrome/browser/history/top_sites_impl.h ('k') | chrome/browser/history/top_sites_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698