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

Side by Side Diff: chrome/browser/favicon/favicon_service.h

Issue 11360233: Ensure that favicons always have 1x representation regardless of whether the platform supports it (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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
« no previous file with comments | « chrome/browser/favicon/favicon_handler.cc ('k') | chrome/browser/favicon/favicon_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_FAVICON_FAVICON_SERVICE_H_ 5 #ifndef CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_
6 #define CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_ 6 #define CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 GURL page_url; 49 GURL page_url;
50 int icon_types; 50 int icon_types;
51 int desired_size_in_dip; 51 int desired_size_in_dip;
52 CancelableRequestConsumerBase* consumer; 52 CancelableRequestConsumerBase* consumer;
53 }; 53 };
54 54
55 // Callback for GetFaviconImage() and GetFaviconImageForURL(). 55 // Callback for GetFaviconImage() and GetFaviconImageForURL().
56 // |FaviconImageResult::image| is constructed from the bitmaps for the 56 // |FaviconImageResult::image| is constructed from the bitmaps for the
57 // passed in URL and icon types which most which closely match the passed in 57 // passed in URL and icon types which most which closely match the passed in
58 // |desired_size_in_dip| at the scale factors supported by the current 58 // |desired_size_in_dip| at the scale factors supported by the current
59 // platform (eg MacOS). 59 // platform (eg MacOS) in addition to 1x.
60 // |FaviconImageResult::icon_url| is the favicon that the favicon bitmaps in 60 // |FaviconImageResult::icon_url| is the favicon that the favicon bitmaps in
61 // |image| originate from. 61 // |image| originate from.
62 // TODO(pkotwicz): Enable constructing |image| from bitmaps from several 62 // TODO(pkotwicz): Enable constructing |image| from bitmaps from several
63 // icon URLs. 63 // icon URLs.
64 typedef base::Callback<void(Handle, const history::FaviconImageResult&)> 64 typedef base::Callback<void(Handle, const history::FaviconImageResult&)>
65 FaviconImageCallback; 65 FaviconImageCallback;
66 66
67 // Callback for GetRawFavicon() and GetRawFaviconForURL(). 67 // Callback for GetRawFavicon() and GetRawFaviconForURL().
68 // FaviconBitmapResult::bitmap_data is the bitmap in the thumbnail database 68 // FaviconBitmapResult::bitmap_data is the bitmap in the thumbnail database
69 // for the passed in URL and icon types whose pixel size best matches the 69 // for the passed in URL and icon types whose pixel size best matches the
70 // passed in |desired_size_in_dip| and |desired_scale_factor|. Returns an 70 // passed in |desired_size_in_dip| and |desired_scale_factor|. Returns an
71 // invalid history::FaviconBitmapResult if there are no matches. 71 // invalid history::FaviconBitmapResult if there are no matches.
72 typedef base::Callback<void(Handle, const history::FaviconBitmapResult&)> 72 typedef base::Callback<void(Handle, const history::FaviconBitmapResult&)>
73 FaviconRawCallback; 73 FaviconRawCallback;
74 74
75 // Callback for GetFavicon() and GetFaviconForURL(). 75 // Callback for GetFavicon() and GetFaviconForURL().
76 // 76 //
77 // The second argument is the set of bitmaps for the passed in URL and 77 // The second argument is the set of bitmaps for the passed in URL and
78 // icon types whose pixel sizes best match the passed in 78 // icon types whose pixel sizes best match the passed in
79 // |desired_size_in_dip| and |desired_scale_factors|. The vector has at most 79 // |desired_size_in_dip| at the scale factors supported by the current
80 // one result for each of |desired_scale_factors|. There are less entries if 80 // platform (eg MacOS) in addition to 1x. The vector has at most one result
81 // a single result is the best bitmap to use for several scale factors. 81 // for each of the scale factors. There are less entries if a single result
82 // is the best bitmap to use for several scale factors.
82 // 83 //
83 // Third argument: 84 // Third argument:
84 // a) If the callback is called as a result of GetFaviconForURL(): 85 // a) If the callback is called as a result of GetFaviconForURL():
85 // The third argument is a map of the icon URLs mapped to |page_url| to 86 // The third argument is a map of the icon URLs mapped to |page_url| to
86 // the sizes at which the favicon is available from the web. 87 // the sizes at which the favicon is available from the web.
87 // b) If the callback is called as a result of GetFavicon() or 88 // b) If the callback is called as a result of GetFavicon() or
88 // UpdateFaviconMappingsAndFetch(): 89 // UpdateFaviconMappingsAndFetch():
89 // The third argument is a map of the subset of |icon_urls| known to the 90 // The third argument is a map of the subset of |icon_urls| known to the
90 // history backend to a vector of sizes of the favicon bitmaps at each 91 // history backend to a vector of sizes of the favicon bitmaps at each
91 // URL. If none of |icon_urls| are known to the history backend, an empty 92 // URL. If none of |icon_urls| are known to the history backend, an empty
(...skipping 24 matching lines...) Expand all
116 Handle GetRawFavicon(const GURL& icon_url, 117 Handle GetRawFavicon(const GURL& icon_url,
117 history::IconType icon_type, 118 history::IconType icon_type,
118 int desired_size_in_dip, 119 int desired_size_in_dip,
119 ui::ScaleFactor desired_scale_factor, 120 ui::ScaleFactor desired_scale_factor,
120 CancelableRequestConsumerBase* consumer, 121 CancelableRequestConsumerBase* consumer,
121 const FaviconRawCallback& callback); 122 const FaviconRawCallback& callback);
122 123
123 Handle GetFavicon(const GURL& icon_url, 124 Handle GetFavicon(const GURL& icon_url,
124 history::IconType icon_type, 125 history::IconType icon_type,
125 int desired_size_in_dip, 126 int desired_size_in_dip,
126 const std::vector<ui::ScaleFactor>& desired_scale_factors,
127 CancelableRequestConsumerBase* consumer, 127 CancelableRequestConsumerBase* consumer,
128 const FaviconResultsCallback& callback); 128 const FaviconResultsCallback& callback);
129 129
130 // Set the favicon mappings to |page_url| for |icon_types| in the history 130 // Set the favicon mappings to |page_url| for |icon_types| in the history
131 // database. 131 // database.
132 // Sample |icon_urls|: 132 // Sample |icon_urls|:
133 // { ICON_URL1 -> TOUCH_ICON, known to the database, 133 // { ICON_URL1 -> TOUCH_ICON, known to the database,
134 // ICON_URL2 -> TOUCH_ICON, not known to the database, 134 // ICON_URL2 -> TOUCH_ICON, not known to the database,
135 // ICON_URL3 -> TOUCH_PRECOMPOSED_ICON, known to the database } 135 // ICON_URL3 -> TOUCH_PRECOMPOSED_ICON, known to the database }
136 // The new mappings are computed from |icon_urls| with these rules: 136 // The new mappings are computed from |icon_urls| with these rules:
137 // 1) Any urls in |icon_urls| which are not already known to the database are 137 // 1) Any urls in |icon_urls| which are not already known to the database are
138 // rejected. 138 // rejected.
139 // Sample new mappings to |page_url|: { ICON_URL1, ICON_URL3 } 139 // Sample new mappings to |page_url|: { ICON_URL1, ICON_URL3 }
140 // 2) If |icon_types| has multiple types, the mappings are only set for the 140 // 2) If |icon_types| has multiple types, the mappings are only set for the
141 // largest icon type. 141 // largest icon type.
142 // Sample new mappings to |page_url|: { ICON_URL3 } 142 // Sample new mappings to |page_url|: { ICON_URL3 }
143 // |icon_types| can only have multiple IconTypes if 143 // |icon_types| can only have multiple IconTypes if
144 // |icon_types| == TOUCH_ICON | TOUCH_PRECOMPOSED_ICON. 144 // |icon_types| == TOUCH_ICON | TOUCH_PRECOMPOSED_ICON.
145 // The favicon bitmaps which most closely match |desired_size_in_dip| 145 // The favicon bitmaps which most closely match |desired_size_in_dip|
146 // and |desired_scale_factors| from the favicons which were just mapped 146 // at the scale factors supported by the current platform (eg MacOS) in
147 // to |page_url| are returned. If |desired_size_in_dip| is 0, the 147 // addition to 1x from the favicons which were just mapped to |page_url| are
148 // largest favicon bitmap is returned. 148 // returned. If |desired_size_in_dip| is 0, the largest favicon bitmap is
149 // returned.
149 Handle UpdateFaviconMappingsAndFetch( 150 Handle UpdateFaviconMappingsAndFetch(
150 const GURL& page_url, 151 const GURL& page_url,
151 const std::vector<GURL>& icon_urls, 152 const std::vector<GURL>& icon_urls,
152 int icon_types, 153 int icon_types,
153 int desired_size_in_dip, 154 int desired_size_in_dip,
154 const std::vector<ui::ScaleFactor>& desired_scale_factors,
155 CancelableRequestConsumerBase* consumer, 155 CancelableRequestConsumerBase* consumer,
156 const FaviconResultsCallback& callback); 156 const FaviconResultsCallback& callback);
157 157
158 // Requests the favicons of any of |icon_types| whose pixel sizes most 158 // Requests the favicons of any of |icon_types| whose pixel sizes most
159 // closely match |desired_size_in_dip| and desired scale factors for a web 159 // closely match |desired_size_in_dip| and desired scale factors for a web
160 // page URL. If |desired_size_in_dip| is 0, the largest favicon for the web 160 // page URL. If |desired_size_in_dip| is 0, the largest favicon for the web
161 // page URL is returned. |consumer| is notified when the bits have been 161 // page URL is returned. |consumer| is notified when the bits have been
162 // fetched. |icon_types| can be any combination of IconType value, but only 162 // fetched. |icon_types| can be any combination of IconType value, but only
163 // one icon will be returned in the priority of TOUCH_PRECOMPOSED_ICON, 163 // one icon will be returned in the priority of TOUCH_PRECOMPOSED_ICON,
164 // TOUCH_ICON and FAVICON. Each of the three methods below differs in the 164 // TOUCH_ICON and FAVICON. Each of the three methods below differs in the
165 // format of the callback and the requested scale factors. All of the scale 165 // format of the callback and the requested scale factors. All of the scale
166 // factors supported by the current platform (eg MacOS) are requested for 166 // factors supported by the current platform (eg MacOS) are requested for
167 // GetFaviconImageForURL(). 167 // GetFaviconImageForURL().
168 Handle GetFaviconImageForURL(const FaviconForURLParams& params, 168 Handle GetFaviconImageForURL(const FaviconForURLParams& params,
169 const FaviconImageCallback& callback); 169 const FaviconImageCallback& callback);
170 170
171 Handle GetRawFaviconForURL(const FaviconForURLParams& params, 171 Handle GetRawFaviconForURL(const FaviconForURLParams& params,
172 ui::ScaleFactor desired_scale_factor, 172 ui::ScaleFactor desired_scale_factor,
173 const FaviconRawCallback& callback); 173 const FaviconRawCallback& callback);
174 174
175 Handle GetFaviconForURL( 175 Handle GetFaviconForURL(
176 const FaviconForURLParams& params, 176 const FaviconForURLParams& params,
177 const std::vector<ui::ScaleFactor>& desired_scale_factors,
178 const FaviconResultsCallback& callback); 177 const FaviconResultsCallback& callback);
179 178
180 // Used to request a bitmap for the favicon with |favicon_id| which is not 179 // Used to request a bitmap for the favicon with |favicon_id| which is not
181 // resized from the size it is stored at in the database. If there are 180 // resized from the size it is stored at in the database. If there are
182 // multiple favicon bitmaps for |favicon_id|, the largest favicon bitmap is 181 // multiple favicon bitmaps for |favicon_id|, the largest favicon bitmap is
183 // returned. 182 // returned.
184 Handle GetLargestRawFaviconForID(history::FaviconID favicon_id, 183 Handle GetLargestRawFaviconForID(history::FaviconID favicon_id,
185 CancelableRequestConsumerBase* consumer, 184 CancelableRequestConsumerBase* consumer,
186 const FaviconRawCallback& callback); 185 const FaviconRawCallback& callback);
187 186
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 ui::ScaleFactor desired_scale_factor, 263 ui::ScaleFactor desired_scale_factor,
265 FaviconRawCallback callback, 264 FaviconRawCallback callback,
266 Handle handle, 265 Handle handle,
267 std::vector<history::FaviconBitmapResult> favicon_bitmap_results, 266 std::vector<history::FaviconBitmapResult> favicon_bitmap_results,
268 history::IconURLSizesMap icon_url_sizes_map); 267 history::IconURLSizesMap icon_url_sizes_map);
269 268
270 DISALLOW_COPY_AND_ASSIGN(FaviconService); 269 DISALLOW_COPY_AND_ASSIGN(FaviconService);
271 }; 270 };
272 271
273 #endif // CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_ 272 #endif // CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/favicon/favicon_handler.cc ('k') | chrome/browser/favicon/favicon_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698