Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / chrome / browser / search / thumbnail_source.h
blob4bf5072e4bd11754e6fb571c60bb01bee366c46c
1 // Copyright (c) 2012 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_SEARCH_THUMBNAIL_SOURCE_H_
6 #define CHROME_BROWSER_SEARCH_THUMBNAIL_SOURCE_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h"
12 #include "content/public/browser/url_data_source.h"
14 class Profile;
16 namespace base {
17 class RefCountedMemory;
20 namespace thumbnails {
21 class ThumbnailService;
24 // ThumbnailSource is the gateway between network-level chrome: requests for
25 // thumbnails and the history/top-sites backend that serves these.
26 class ThumbnailSource : public content::URLDataSource {
27 public:
28 ThumbnailSource(Profile* profile, bool capture_thumbnails);
30 // content::URLDataSource implementation.
31 std::string GetSource() const override;
32 void StartDataRequest(
33 const std::string& path,
34 int render_process_id,
35 int render_frame_id,
36 const content::URLDataSource::GotDataCallback& callback) override;
37 std::string GetMimeType(const std::string& path) const override;
38 base::MessageLoop* MessageLoopForRequestPath(
39 const std::string& path) const override;
40 bool ShouldServiceRequest(const net::URLRequest* request) const override;
42 private:
43 ~ThumbnailSource() override;
45 // Raw PNG representation of the thumbnail to show when the thumbnail
46 // database doesn't have a thumbnail for a webpage.
47 scoped_refptr<base::RefCountedMemory> default_thumbnail_;
49 // ThumbnailService.
50 scoped_refptr<thumbnails::ThumbnailService> thumbnail_service_;
52 // Indicate that, when a URL for which we don't have a thumbnail is requested
53 // from this source, then Chrome should capture a thumbnail next time it
54 // navigates to this URL. This is useful when the thumbnail URLs are generated
55 // by an external service rather than TopSites, so Chrome can learn about the
56 // URLs for which it should get thumbnails. Sources that capture thumbnails
57 // are also be more lenient when matching thumbnail URLs by checking for
58 // existing thumbnails in the database that contain a URL matching the prefix
59 // of the requested URL.
60 const bool capture_thumbnails_;
62 DISALLOW_COPY_AND_ASSIGN(ThumbnailSource);
65 #endif // CHROME_BROWSER_SEARCH_THUMBNAIL_SOURCE_H_