Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1354)

Side by Side Diff: chrome/browser/ui/webui/favicon_source.h

Issue 11885021: Don't derive from ChromeURLDataManager::DataSource, and instead have these classes implement a dele… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: nits Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 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_FAVICON_SOURCE_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_FAVICON_SOURCE_H_
6 #define CHROME_BROWSER_UI_WEBUI_FAVICON_SOURCE_H_ 6 #define CHROME_BROWSER_UI_WEBUI_FAVICON_SOURCE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "chrome/browser/favicon/favicon_service.h" 13 #include "chrome/browser/favicon/favicon_service.h"
14 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
15 #include "chrome/common/cancelable_task_tracker.h" 14 #include "chrome/common/cancelable_task_tracker.h"
15 #include "content/public/browser/url_data_source_delegate.h"
16 #include "ui/gfx/favicon_size.h" 16 #include "ui/gfx/favicon_size.h"
17 17
18 class Profile; 18 class Profile;
19 19
20 // FaviconSource is the gateway between network-level chrome: 20 // FaviconSource is the gateway between network-level chrome:
21 // requests for favicons and the history backend that serves these. 21 // requests for favicons and the history backend that serves these.
22 class FaviconSource : public ChromeURLDataManager::DataSource { 22 class FaviconSource : public content::URLDataSourceDelegate {
23 public: 23 public:
24 // Defines the type of icon the FaviconSource will provide. 24 // Defines the type of icon the FaviconSource will provide.
25 enum IconType { 25 enum IconType {
26 FAVICON, 26 FAVICON,
27 // Any available icon in the priority of TOUCH_ICON_PRECOMPOSED, TOUCH_ICON, 27 // Any available icon in the priority of TOUCH_ICON_PRECOMPOSED, TOUCH_ICON,
28 // FAVICON, and default favicon. 28 // FAVICON, and default favicon.
29 ANY 29 ANY
30 }; 30 };
31 31
32 // |type| is the type of icon this FaviconSource will provide. 32 // |type| is the type of icon this FaviconSource will provide.
33 FaviconSource(Profile* profile, IconType type); 33 FaviconSource(Profile* profile, IconType type);
34 34
35 // Constructor allowing the source name to be specified. 35 // content::URLDataSourceDelegate implementation.
36 FaviconSource(Profile* profile, 36 virtual std::string GetSource() OVERRIDE;
37 IconType type,
38 const std::string& source_name);
39
40 // Called when the network layer has requested a resource underneath
41 // the path we registered.
42 virtual void StartDataRequest(const std::string& path, 37 virtual void StartDataRequest(const std::string& path,
43 bool is_incognito, 38 bool is_incognito,
44 int request_id) OVERRIDE; 39 int request_id) OVERRIDE;
45
46 virtual std::string GetMimeType(const std::string&) const OVERRIDE; 40 virtual std::string GetMimeType(const std::string&) const OVERRIDE;
47
48 virtual bool ShouldReplaceExistingSource() const OVERRIDE; 41 virtual bool ShouldReplaceExistingSource() const OVERRIDE;
49 42
50 protected: 43 protected:
51 struct IconRequest { 44 struct IconRequest {
52 IconRequest() 45 IconRequest()
53 : request_id(0), 46 : request_id(0),
54 request_path(""), 47 request_path(""),
55 size_in_dip(gfx::kFaviconSize), 48 size_in_dip(gfx::kFaviconSize),
56 scale_factor(ui::SCALE_FACTOR_NONE) { 49 scale_factor(ui::SCALE_FACTOR_NONE) {
57 } 50 }
(...skipping 24 matching lines...) Expand all
82 75
83 private: 76 private:
84 // Defines the allowed pixel sizes for requested favicons. 77 // Defines the allowed pixel sizes for requested favicons.
85 enum IconSize { 78 enum IconSize {
86 SIZE_16, 79 SIZE_16,
87 SIZE_32, 80 SIZE_32,
88 SIZE_64, 81 SIZE_64,
89 NUM_SIZES 82 NUM_SIZES
90 }; 83 };
91 84
92 void Init(Profile* profile, IconType type);
93
94 // Called when favicon data is available from the history backend. 85 // Called when favicon data is available from the history backend.
95 void OnFaviconDataAvailable( 86 void OnFaviconDataAvailable(
96 const IconRequest& request, 87 const IconRequest& request,
97 const history::FaviconBitmapResult& bitmap_result); 88 const history::FaviconBitmapResult& bitmap_result);
98 89
99 // Sends the default favicon. 90 // Sends the default favicon.
100 void SendDefaultResponse(const IconRequest& request); 91 void SendDefaultResponse(const IconRequest& request);
101 92
102 CancelableTaskTracker cancelable_task_tracker_; 93 CancelableTaskTracker cancelable_task_tracker_;
103 94
104 // Raw PNG representations of favicons of each size to show when the favicon 95 // Raw PNG representations of favicons of each size to show when the favicon
105 // database doesn't have a favicon for a webpage. Indexed by IconSize values. 96 // database doesn't have a favicon for a webpage. Indexed by IconSize values.
106 scoped_refptr<base::RefCountedMemory> default_favicons_[NUM_SIZES]; 97 scoped_refptr<base::RefCountedMemory> default_favicons_[NUM_SIZES];
107 98
108 // The history::IconTypes of icon that this FaviconSource handles. 99 // The history::IconTypes of icon that this FaviconSource handles.
109 int icon_types_; 100 int icon_types_;
110 101
111 DISALLOW_COPY_AND_ASSIGN(FaviconSource); 102 DISALLOW_COPY_AND_ASSIGN(FaviconSource);
112 }; 103 };
113 104
114 #endif // CHROME_BROWSER_UI_WEBUI_FAVICON_SOURCE_H_ 105 #endif // CHROME_BROWSER_UI_WEBUI_FAVICON_SOURCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698