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

Unified Diff: chrome/browser/ui/webui/ntp/thumbnail_list_source.h

Issue 24632002: Implementing chrome://thumbnails page to view URLs in TopSites and cached thumbnails. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Trying to fix Linux compile by reordering initializing order of weak_ptr_factory_. Created 7 years, 3 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
Index: chrome/browser/ui/webui/ntp/thumbnail_list_source.h
diff --git a/chrome/browser/ui/webui/ntp/thumbnail_source.h b/chrome/browser/ui/webui/ntp/thumbnail_list_source.h
similarity index 51%
copy from chrome/browser/ui/webui/ntp/thumbnail_source.h
copy to chrome/browser/ui/webui/ntp/thumbnail_list_source.h
index f4ff8f014388f4cc9752889265219f08650ed7c4..2134818e63b28a0a3614d7852acbdad104dfaefd 100644
--- a/chrome/browser/ui/webui/ntp/thumbnail_source.h
+++ b/chrome/browser/ui/webui/ntp/thumbnail_list_source.h
@@ -1,64 +1,67 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_NTP_THUMBNAIL_SOURCE_H_
-#define CHROME_BROWSER_UI_WEBUI_NTP_THUMBNAIL_SOURCE_H_
-
-#include <string>
-
-#include "base/basictypes.h"
-#include "base/memory/ref_counted.h"
-#include "content/public/browser/url_data_source.h"
-
-class Profile;
-
-namespace base {
-class RefCountedMemory;
-}
-
-namespace thumbnails {
-class ThumbnailService;
-}
-
-// ThumbnailSource is the gateway between network-level chrome: requests for
-// thumbnails and the history/top-sites backend that serves these.
-class ThumbnailSource : public content::URLDataSource {
- public:
- ThumbnailSource(Profile* profile, bool prefix_match);
-
- // content::URLDataSource implementation.
- virtual std::string GetSource() const OVERRIDE;
- virtual void StartDataRequest(
- const std::string& path,
- int render_process_id,
- int render_view_id,
- const content::URLDataSource::GotDataCallback& callback) OVERRIDE;
- virtual std::string GetMimeType(const std::string& path) const OVERRIDE;
- virtual base::MessageLoop* MessageLoopForRequestPath(
- const std::string& path) const OVERRIDE;
- virtual bool ShouldServiceRequest(
- const net::URLRequest* request) const OVERRIDE;
-
- private:
- virtual ~ThumbnailSource();
-
- // Raw PNG representation of the thumbnail to show when the thumbnail
- // database doesn't have a thumbnail for a webpage.
- scoped_refptr<base::RefCountedMemory> default_thumbnail_;
-
- // ThumbnailService.
- scoped_refptr<thumbnails::ThumbnailService> thumbnail_service_;
-
- // Only used when servicing requests on the UI thread.
- Profile* const profile_;
-
- // If an exact thumbnail URL match fails, specifies whether or not to try
- // harder by matching the query thumbnail URL as URL prefix. This affects
- // GetSource().
- const bool prefix_match_;
-
- DISALLOW_COPY_AND_ASSIGN(ThumbnailSource);
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_NTP_THUMBNAIL_SOURCE_H_
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_NTP_THUMBNAIL_LIST_SOURCE_H_
+#define CHROME_BROWSER_UI_WEBUI_NTP_THUMBNAIL_LIST_SOURCE_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
+#include "chrome/browser/history/history_types.h"
+#include "content/public/browser/url_data_source.h"
+
+class Profile;
+
+namespace base {
+class RefCountedMemory;
+}
+
+namespace thumbnails {
+class ThumbnailService;
+}
+
+// ThumbnailListSource renders a webpage to list all thumbnails stored in
+// TopSites, along with all associated URLs. The thumbnail images are embedded
+// into the HTML via Base64, so we can easily produce a dump of TopSites and
+// the thumbnails it stores.
+class ThumbnailListSource : public content::URLDataSource {
+ public:
+ explicit ThumbnailListSource(Profile* profile);
+
+ // content::URLDataSource implementation.
+ virtual std::string GetSource() const OVERRIDE;
+ virtual void StartDataRequest(
+ const std::string& path,
+ int render_process_id,
+ int render_view_id,
+ const content::URLDataSource::GotDataCallback& callback) OVERRIDE;
+ virtual std::string GetMimeType(const std::string& path) const OVERRIDE;
+ virtual base::MessageLoop* MessageLoopForRequestPath(
+ const std::string& path) const OVERRIDE;
+ virtual bool ShouldServiceRequest(
+ const net::URLRequest* request) const OVERRIDE;
+
+ private:
+ virtual ~ThumbnailListSource();
+
+ void OnMostVisitedURLsAvailable(
+ const content::URLDataSource::GotDataCallback& callback,
+ const history::MostVisitedURLList& mvurl_list);
+
+ // ThumbnailService.
+ scoped_refptr<thumbnails::ThumbnailService> thumbnail_service_;
+
+ // Only used when servicing requests on the UI thread.
+ Profile* const profile_;
+
+ // For callbacks may be run after destruction.
+ base::WeakPtrFactory<ThumbnailListSource> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(ThumbnailListSource);
+};
+
+
+#endif // CHROME_BROWSER_UI_WEBUI_NTP_THUMBNAIL_LIST_SOURCE_H_
« no previous file with comments | « chrome/browser/ui/webui/ntp/most_visited_handler.cc ('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