• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2011 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.
4 
5 #ifndef CHROME_BROWSER_UI_WEBUI_THUMBNAIL_SOURCE_H_
6 #define CHROME_BROWSER_UI_WEBUI_THUMBNAIL_SOURCE_H_
7 #pragma once
8 
9 #include <string>
10 
11 #include "base/basictypes.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/ref_counted_memory.h"
14 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
15 
16 class Profile;
17 
18 namespace history {
19 class TopSites;
20 }
21 
22 // ThumbnailSource is the gateway between network-level chrome: requests for
23 // thumbnails and the history/top-sites backend that serves these.
24 class ThumbnailSource : public ChromeURLDataManager::DataSource {
25  public:
26   explicit ThumbnailSource(Profile* profile);
27 
28   // Called when the network layer has requested a resource underneath
29   // the path we registered.
30   virtual void StartDataRequest(const std::string& path,
31                                 bool is_incognito,
32                                 int request_id);
33 
34   virtual std::string GetMimeType(const std::string& path) const;
35 
36   virtual MessageLoop* MessageLoopForRequestPath(const std::string& path) const;
37 
38  private:
39   virtual ~ThumbnailSource();
40 
41   // Send the default thumbnail when we are missing a real one.
42   void SendDefaultThumbnail(int request_id);
43 
44   // Raw PNG representation of the thumbnail to show when the thumbnail
45   // database doesn't have a thumbnail for a webpage.
46   scoped_refptr<RefCountedMemory> default_thumbnail_;
47 
48   // TopSites.
49   scoped_refptr<history::TopSites> top_sites_;
50 
51   DISALLOW_COPY_AND_ASSIGN(ThumbnailSource);
52 };
53 
54 #endif  // CHROME_BROWSER_UI_WEBUI_THUMBNAIL_SOURCE_H_
55