OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_WEBUI_FILEICON_SOURCE_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_FILEICON_SOURCE_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_FILEICON_SOURCE_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_FILEICON_SOURCE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
| 11 #include "base/file_path.h" |
11 #include "chrome/browser/icon_manager.h" | 12 #include "chrome/browser/icon_manager.h" |
12 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 13 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
13 | 14 |
14 class RefCountedBytes; | 15 class RefCountedBytes; |
15 | 16 |
16 namespace gfx { | 17 namespace gfx { |
17 class Image; | 18 class Image; |
18 } | 19 } |
19 | 20 |
20 // FileIconSource is the gateway between network-level chrome: | 21 // FileIconSource is the gateway between network-level chrome: |
21 // requests for favicons and the history backend that serves these. | 22 // requests for favicons and the history backend that serves these. |
22 class FileIconSource : public ChromeURLDataManager::DataSource { | 23 class FileIconSource : public ChromeURLDataManager::DataSource { |
23 public: | 24 public: |
24 explicit FileIconSource(); | 25 explicit FileIconSource(); |
25 | 26 |
26 // Called when the network layer has requested a resource underneath | 27 // Called when the network layer has requested a resource underneath |
27 // the path we registered. | 28 // the path we registered. |
28 virtual void StartDataRequest(const std::string& path, | 29 virtual void StartDataRequest(const std::string& path, |
29 bool is_incognito, | 30 bool is_incognito, |
30 int request_id) OVERRIDE; | 31 int request_id) OVERRIDE; |
31 | 32 |
32 virtual std::string GetMimeType(const std::string&) const OVERRIDE; | 33 virtual std::string GetMimeType(const std::string&) const OVERRIDE; |
33 | 34 |
34 // Called when favicon data is available from the history backend. | 35 // Called when favicon data is available from the history backend. |
35 void OnFileIconDataAvailable( | 36 void OnFileIconDataAvailable( |
36 IconManager::Handle request_handle, | 37 IconManager::Handle request_handle, |
37 gfx::Image* icon); | 38 gfx::Image* icon); |
38 | 39 |
39 private: | 40 protected: |
40 virtual ~FileIconSource(); | 41 virtual ~FileIconSource(); |
41 | 42 |
| 43 // Once the |path| and |icon_size| has been determined from the request, this |
| 44 // function is called to perform the actual fetch. Declared as virtual for |
| 45 // testing. |
| 46 virtual void FetchFileIcon(const FilePath& path, |
| 47 IconLoader::IconSize icon_size, |
| 48 int request_id); |
| 49 |
| 50 private: |
42 CancelableRequestConsumerT<int, 0> cancelable_consumer_; | 51 CancelableRequestConsumerT<int, 0> cancelable_consumer_; |
43 | 52 |
44 // Raw PNG representation of the favicon to show when the favicon | |
45 // database doesn't have a favicon for a webpage. | |
46 scoped_refptr<RefCountedBytes> default_favicon_; | |
47 | |
48 DISALLOW_COPY_AND_ASSIGN(FileIconSource); | 53 DISALLOW_COPY_AND_ASSIGN(FileIconSource); |
49 }; | 54 }; |
50 #endif // CHROME_BROWSER_UI_WEBUI_FILEICON_SOURCE_H_ | 55 #endif // CHROME_BROWSER_UI_WEBUI_FILEICON_SOURCE_H_ |
OLD | NEW |