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

Unified Diff: chrome/browser/thumbnails/thumbnail_service_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
Index: chrome/browser/thumbnails/thumbnail_service_impl.cc
diff --git a/chrome/browser/thumbnails/thumbnail_service_impl.cc b/chrome/browser/thumbnails/thumbnail_service_impl.cc
index 117d730e3402581d78999ab79948c393cf622fba..029b94da2d02a01dac3620d727f8817d9d1d4f63 100644
--- a/chrome/browser/thumbnails/thumbnail_service_impl.cc
+++ b/chrome/browser/thumbnails/thumbnail_service_impl.cc
@@ -6,6 +6,7 @@
#include "base/command_line.h"
#include "base/memory/ref_counted_memory.h"
+#include "base/time/time.h"
#include "chrome/browser/history/history_service.h"
#include "chrome/browser/search/search.h"
#include "chrome/browser/thumbnails/content_based_thumbnailing_algorithm.h"
@@ -14,6 +15,8 @@
#include "chrome/common/chrome_switches.h"
#include "url/gurl.h"
+using content::BrowserThread;
+
namespace {
// The thumbnail size in DIP.
@@ -29,6 +32,14 @@ bool IsThumbnailRetargetingEnabled() {
switches::kEnableThumbnailRetargeting);
}
+void AddForcedURLOnUIThread(scoped_refptr<history::TopSites> top_sites,
+ const GURL& url) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ if (top_sites.get() != NULL)
+ top_sites->AddForcedURL(url, base::Time::Now());
+}
+
} // namespace
namespace thumbnails {
@@ -61,6 +72,16 @@ bool ThumbnailServiceImpl::GetPageThumbnail(
return local_ptr->GetPageThumbnail(url, prefix_match, bytes);
}
+void ThumbnailServiceImpl::AddForcedURL(const GURL& url) {
+ scoped_refptr<history::TopSites> local_ptr(top_sites_);
+ if (local_ptr.get() == NULL)
+ return;
+
+ // Adding
+ BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
+ base::Bind(AddForcedURLOnUIThread, local_ptr, url));
+}
+
ThumbnailingAlgorithm* ThumbnailServiceImpl::GetThumbnailingAlgorithm()
const {
const gfx::Size thumbnail_size(kThumbnailWidth, kThumbnailHeight);
« no previous file with comments | « chrome/browser/thumbnails/thumbnail_service_impl.h ('k') | chrome/browser/ui/webui/ntp/thumbnail_list_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698