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_FILEICON_SOURCE_H_ 6 #define CHROME_BROWSER_UI_WEBUI_FILEICON_SOURCE_H_ 7 #pragma once 8 9 #include <string> 10 11 #include "chrome/browser/icon_manager.h" 12 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 13 14 class GURL; 15 class RefCountedBytes; 16 17 namespace gfx { 18 class Image; 19 } 20 21 // FileIconSource is the gateway between network-level chrome: 22 // requests for favicons and the history backend that serves these. 23 class FileIconSource : public ChromeURLDataManager::DataSource { 24 public: 25 explicit FileIconSource(); 26 27 // Called when the network layer has requested a resource underneath 28 // the path we registered. 29 virtual void StartDataRequest(const std::string& path, 30 bool is_incognito, 31 int request_id); 32 33 virtual std::string GetMimeType(const std::string&) const; 34 35 // Called when favicon data is available from the history backend. 36 void OnFileIconDataAvailable( 37 IconManager::Handle request_handle, 38 gfx::Image* icon); 39 40 private: 41 virtual ~FileIconSource(); 42 43 CancelableRequestConsumerT<int, 0> cancelable_consumer_; 44 45 // Raw PNG representation of the favicon to show when the favicon 46 // database doesn't have a favicon for a webpage. 47 scoped_refptr<RefCountedBytes> default_favicon_; 48 49 DISALLOW_COPY_AND_ASSIGN(FileIconSource); 50 }; 51 #endif // CHROME_BROWSER_UI_WEBUI_FILEICON_SOURCE_H_ 52