1 // Copyright 2014 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_THUMBNAILS_THUMBNAIL_LIST_SOURCE_H_
6 #define CHROME_BROWSER_THUMBNAILS_THUMBNAIL_LIST_SOURCE_H_
10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h"
13 #include "components/history/core/browser/history_types.h"
14 #include "content/public/browser/url_data_source.h"
19 class RefCountedMemory
;
26 namespace thumbnails
{
27 class ThumbnailService
;
30 // ThumbnailListSource renders a webpage to list all thumbnails stored in
31 // TopSites, along with all associated URLs. The thumbnail images are embedded
32 // into the HTML via Base64, so we can easily produce a dump of TopSites and
33 // the thumbnails it stores.
34 class ThumbnailListSource
: public content::URLDataSource
{
36 explicit ThumbnailListSource(Profile
* profile
);
38 // content::URLDataSource implementation.
39 std::string
GetSource() const override
;
40 // Called on the IO thread.
41 void StartDataRequest(
42 const std::string
& path
,
43 int render_process_id
,
45 const content::URLDataSource::GotDataCallback
& callback
) override
;
47 std::string
GetMimeType(const std::string
& path
) const override
;
48 base::MessageLoop
* MessageLoopForRequestPath(
49 const std::string
& path
) const override
;
50 bool ShouldServiceRequest(const net::URLRequest
* request
) const override
;
51 bool ShouldReplaceExistingSource() const override
;
54 ~ThumbnailListSource() override
;
56 // Called on the IO thread.
57 void OnMostVisitedURLsAvailable(
58 const content::URLDataSource::GotDataCallback
& callback
,
59 const history::MostVisitedURLList
& mvurl_list
);
62 scoped_refptr
<thumbnails::ThumbnailService
> thumbnail_service_
;
64 scoped_refptr
<history::TopSites
> top_sites_
;
66 // For callbacks may be run after destruction.
67 base::WeakPtrFactory
<ThumbnailListSource
> weak_ptr_factory_
;
69 DISALLOW_COPY_AND_ASSIGN(ThumbnailListSource
);
73 #endif // CHROME_BROWSER_THUMBNAILS_THUMBNAIL_LIST_SOURCE_H_