NaCl: Update revision in DEPS, r12770 -> r12773
[chromium-blink-merge.git] / chrome / browser / ui / webui / ntp / thumbnail_list_source.h
blob605c9c2c74712dcf4d472a5efc63cfa411350574
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_WEBUI_NTP_THUMBNAIL_LIST_SOURCE_H_
6 #define CHROME_BROWSER_UI_WEBUI_NTP_THUMBNAIL_LIST_SOURCE_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h"
13 #include "chrome/browser/history/history_types.h"
14 #include "content/public/browser/url_data_source.h"
16 class Profile;
18 namespace base {
19 class RefCountedMemory;
22 namespace thumbnails {
23 class ThumbnailService;
26 // ThumbnailListSource renders a webpage to list all thumbnails stored in
27 // TopSites, along with all associated URLs. The thumbnail images are embedded
28 // into the HTML via Base64, so we can easily produce a dump of TopSites and
29 // the thumbnails it stores.
30 class ThumbnailListSource : public content::URLDataSource {
31 public:
32 explicit ThumbnailListSource(Profile* profile);
34 // content::URLDataSource implementation.
35 virtual std::string GetSource() const OVERRIDE;
36 virtual void StartDataRequest(
37 const std::string& path,
38 int render_process_id,
39 int render_frame_id,
40 const content::URLDataSource::GotDataCallback& callback) OVERRIDE;
41 virtual std::string GetMimeType(const std::string& path) const OVERRIDE;
42 virtual base::MessageLoop* MessageLoopForRequestPath(
43 const std::string& path) const OVERRIDE;
44 virtual bool ShouldServiceRequest(
45 const net::URLRequest* request) const OVERRIDE;
47 private:
48 virtual ~ThumbnailListSource();
50 void OnMostVisitedURLsAvailable(
51 const content::URLDataSource::GotDataCallback& callback,
52 const history::MostVisitedURLList& mvurl_list);
54 // ThumbnailService.
55 scoped_refptr<thumbnails::ThumbnailService> thumbnail_service_;
57 // Only used when servicing requests on the UI thread.
58 Profile* const profile_;
60 // For callbacks may be run after destruction.
61 base::WeakPtrFactory<ThumbnailListSource> weak_ptr_factory_;
63 DISALLOW_COPY_AND_ASSIGN(ThumbnailListSource);
67 #endif // CHROME_BROWSER_UI_WEBUI_NTP_THUMBNAIL_LIST_SOURCE_H_