blob: cbf417ee2d58d876978032dbf8c725e1e9ff0062 [file] [log] [blame]
[email protected]e0813a392011-02-01 22:57:251// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]eb3a892e2009-05-12 18:38:412// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]fd42ac30f2011-02-27 19:33:365#ifndef CHROME_BROWSER_UI_WEBUI_FAVICON_SOURCE_H_
6#define CHROME_BROWSER_UI_WEBUI_FAVICON_SOURCE_H_
[email protected]32b76ef2010-07-26 23:08:247#pragma once
[email protected]eb3a892e2009-05-12 18:38:418
[email protected]19677192011-11-12 03:54:569#include <map>
[email protected]eb3a892e2009-05-12 18:38:4110#include <string>
11
12#include "base/basictypes.h"
[email protected]3b63f8f42011-03-28 01:54:1513#include "base/memory/ref_counted.h"
[email protected]ee2ed42c2011-04-28 22:19:1414#include "chrome/browser/favicon/favicon_service.h"
[email protected]fd42ac30f2011-02-27 19:33:3615#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
[email protected]eb3a892e2009-05-12 18:38:4116
[email protected]eb3a892e2009-05-12 18:38:4117class Profile;
18
[email protected]16835e62011-03-16 14:13:0819// FaviconSource is the gateway between network-level chrome:
[email protected]eb3a892e2009-05-12 18:38:4120// requests for favicons and the history backend that serves these.
[email protected]16835e62011-03-16 14:13:0821class FaviconSource : public ChromeURLDataManager::DataSource {
[email protected]eb3a892e2009-05-12 18:38:4122 public:
[email protected]7c158cca2011-04-20 17:57:0623 // Defines the type of icon the FaviconSource will provide.
24 enum IconType {
25 FAVICON,
[email protected]2a023ab2011-05-20 16:08:2126 // Any available icon in the priority of TOUCH_ICON_PRECOMPOSED, TOUCH_ICON,
27 // FAVICON, and default favicon.
28 ANY
[email protected]7c158cca2011-04-20 17:57:0629 };
30
31 // |type| is the type of icon this FaviconSource will provide.
32 FaviconSource(Profile* profile, IconType type);
[email protected]eb3a892e2009-05-12 18:38:4133
34 // Called when the network layer has requested a resource underneath
35 // the path we registered.
[email protected]f09d93792009-11-17 00:10:3636 virtual void StartDataRequest(const std::string& path,
[email protected]d1c7d712011-03-29 22:35:3037 bool is_incognito,
[email protected]f09d93792009-11-17 00:10:3638 int request_id);
[email protected]eb3a892e2009-05-12 18:38:4139
[email protected]3071754432010-07-28 00:09:5440 virtual std::string GetMimeType(const std::string&) const;
[email protected]eb3a892e2009-05-12 18:38:4141
[email protected]ffe3d6f2011-02-23 16:42:5242 virtual bool ShouldReplaceExistingSource() const;
43
44 private:
[email protected]eb3a892e2009-05-12 18:38:4145 // Called when favicon data is available from the history backend.
[email protected]abc2f262011-03-15 21:15:4446 void OnFaviconDataAvailable(FaviconService::Handle request_handle,
[email protected]849ccee2011-03-16 17:05:3047 history::FaviconData favicon);
[email protected]eb3a892e2009-05-12 18:38:4148
[email protected]969894ab2010-08-29 00:35:0149 // Sends the default favicon.
50 void SendDefaultResponse(int request_id);
51
[email protected]16835e62011-03-16 14:13:0852 virtual ~FaviconSource();
[email protected]8de85a62009-11-06 08:32:1753
[email protected]eb3a892e2009-05-12 18:38:4154 Profile* profile_;
55 CancelableRequestConsumerT<int, 0> cancelable_consumer_;
56
[email protected]abbd2f4b2011-07-05 18:53:1857 // Map from request ID to size requested (in pixels). TODO(estade): Get rid of
58 // this map when we properly support multiple favicon sizes.
59 std::map<int, int> request_size_map_;
60
[email protected]eb3a892e2009-05-12 18:38:4161 // Raw PNG representation of the favicon to show when the favicon
62 // database doesn't have a favicon for a webpage.
[email protected]abbd2f4b2011-07-05 18:53:1863 // 16x16
[email protected]6de27992009-10-19 17:04:4664 scoped_refptr<RefCountedMemory> default_favicon_;
[email protected]abbd2f4b2011-07-05 18:53:1865 // 32x32
66 scoped_refptr<RefCountedMemory> default_favicon_large_;
[email protected]eb3a892e2009-05-12 18:38:4167
[email protected]7c158cca2011-04-20 17:57:0668 // The history::IconTypes of icon that this FaviconSource handles.
69 const int icon_types_;
70
[email protected]16835e62011-03-16 14:13:0871 DISALLOW_COPY_AND_ASSIGN(FaviconSource);
[email protected]eb3a892e2009-05-12 18:38:4172};
73
[email protected]fd42ac30f2011-02-27 19:33:3674#endif // CHROME_BROWSER_UI_WEBUI_FAVICON_SOURCE_H_