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

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

Issue 10910212: Enable hidpi favicons for favicons history does not know about (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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_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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
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| and |desired_scale_factors|. The vector has at most
80 // one result for each of |desired_scale_factors|. There are less entries if 80 // one result for each of |desired_scale_factors|. There are less entries if
81 // a single result is the best bitmap to use for several scale factors. 81 // a single result is the best bitmap to use for several scale factors.
82 // 82 //
83 // Third argument: 83 // Third argument:
84 // a) If the callback is called as a result of GetFaviconForURL(): 84 // 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 85 // 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. 86 // the sizes at which the favicon is available from the web.
87 // b) If the callback is called as a result of GetFavicon() or 87 // b) If the callback is called as a result of GetFavicon() or
88 // UpdateFaviconMappingAndFetch(): 88 // UpdateFaviconMappingsAndFetch():
89 // The third argument is a map with a single element with the passed in 89 // The third argument is a map of the subset of |icon_urls| known to the
90 // |icon_url| to the vector of sizes of the favicon bitmaps at that URL. If 90 // history backend to a vector of sizes of the favicon bitmaps at each
91 // |icon_url| is not known to the history backend, an empty map is 91 // URL. If none of |icon_urls| are known to the history backend, an empty
92 // returned. 92 // map is returned.
93 // See history_types.h for more information about IconURLSizesMap. 93 // See history_types.h for more information about IconURLSizesMap.
94 typedef base::Callback< 94 typedef base::Callback<
95 void(Handle, // handle 95 void(Handle, // handle
96 std::vector<history::FaviconBitmapResult>, 96 std::vector<history::FaviconBitmapResult>,
97 history::IconURLSizesMap)> 97 history::IconURLSizesMap)>
98 FaviconResultsCallback; 98 FaviconResultsCallback;
99 99
100 typedef CancelableRequest<FaviconResultsCallback> GetFaviconRequest; 100 typedef CancelableRequest<FaviconResultsCallback> GetFaviconRequest;
101 101
102 // Requests the favicon at |icon_url| of |icon_type| whose size most closely 102 // Requests the favicon at |icon_url| of |icon_type| whose size most closely
(...skipping 17 matching lines...) Expand all
120 CancelableRequestConsumerBase* consumer, 120 CancelableRequestConsumerBase* consumer,
121 const FaviconRawCallback& callback); 121 const FaviconRawCallback& callback);
122 122
123 Handle GetFavicon(const GURL& icon_url, 123 Handle GetFavicon(const GURL& icon_url,
124 history::IconType icon_type, 124 history::IconType icon_type,
125 int desired_size_in_dip, 125 int desired_size_in_dip,
126 const std::vector<ui::ScaleFactor>& desired_scale_factors, 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 // Fetches the |icon_type| of favicon at |icon_url|, sending the results to 130 // Set the favicon mappings to |page_url| for |icon_types| in the history
131 // the given |callback|. If the favicon has previously been set via 131 // database.
132 // SetFavicon(), then the favicon URL for |page_url| and all redirects is set 132 // Sample |icon_urls|:
133 // to |icon_url|. If the favicon has not been set, the database is not 133 // { ICON_URL1 -> TOUCH_ICON, known to the database,
134 // updated. 134 // ICON_URL2 -> TOUCH_ICON, not known to the database,
135 Handle UpdateFaviconMappingAndFetch(const GURL& page_url, 135 // ICON_URL3 -> TOUCH_PRECOMPOSED_ICON, known to the database }
136 const GURL& icon_url, 136 // The new mappings are computed from |icon_urls| with these rules:
137 history::IconType icon_type, 137 // 1) Any urls in |icon_urls| which are not already known to the database are
138 CancelableRequestConsumerBase* consumer, 138 // rejected.
139 const FaviconResultsCallback& callback); 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
141 // largest icon type.
142 // Sample new mappings to |page_url|: { ICON_URL3 }
143 // |icon_types| can only have multiple IconTypes if
144 // |icon_types| == TOUCH_ICON | TOUCH_PRECOMPOSED_ICON.
145 // The favicon bitmaps which most closely match |desired_size_in_dip|
146 // and |desired_scale_factors| from the favicons which were just mapped
147 // to |page_url| are returned. If |desired_size_in_dip| is 0, the
148 // largest favicon bitmap is returned.
149 Handle UpdateFaviconMappingsAndFetch(
150 const GURL& page_url,
151 const std::vector<GURL>& icon_urls,
152 int icon_types,
153 int desired_size_in_dip,
154 const std::vector<ui::ScaleFactor>& desired_scale_factors,
155 CancelableRequestConsumerBase* consumer,
156 const FaviconResultsCallback& callback);
140 157
141 // 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
142 // 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
143 // 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
144 // 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
145 // 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
146 // 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,
147 // 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
148 // 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
149 // factors supported by the current platform (eg MacOS) are requested for 166 // factors supported by the current platform (eg MacOS) are requested for
(...skipping 27 matching lines...) Expand all
177 // Needed if you want to declare favicons (tentatively) in advance, before a 194 // Needed if you want to declare favicons (tentatively) in advance, before a
178 // page is ever visited. 195 // page is ever visited.
179 void CloneFavicon(const GURL& old_page_url, const GURL& new_page_url); 196 void CloneFavicon(const GURL& old_page_url, const GURL& new_page_url);
180 197
181 // Allows the importer to set many favicons for many pages at once. The pages 198 // Allows the importer to set many favicons for many pages at once. The pages
182 // must exist, any favicon sets for unknown pages will be discarded. Existing 199 // must exist, any favicon sets for unknown pages will be discarded. Existing
183 // favicons will not be overwritten. 200 // favicons will not be overwritten.
184 void SetImportedFavicons( 201 void SetImportedFavicons(
185 const std::vector<history::ImportedFaviconUsage>& favicon_usage); 202 const std::vector<history::ImportedFaviconUsage>& favicon_usage);
186 203
187 // Sets the favicon for a page. 204 // Set the favicon for |page_url| for |icon_type| in the thumbnail database.
188 void SetFavicon(const GURL& page_url, 205 // Unlike SetFavicons(), this method will not delete preexisting bitmap data
189 const GURL& icon_url, 206 // which is associated to |page_url| if at all possible. Use this method if
190 const std::vector<unsigned char>& image_data, 207 // the favicon bitmaps for any of ui::GetSupportedScaleFactors() are not
191 history::IconType icon_type); 208 // known. If a favicon bitmap at |icon_url| with |pixel_size| is already in
209 // the database:
210 // The favicon bitmap for |icon_url| will be updated with |bitmap_data|.
211 // If a favicon bitmap at |icon_url| with |pixel_size| is not in the database:
212 // A new favicon bitmap (and favicon if necessary) will be created. The
213 // favicon sizes for |icon_url| will be set to the default favicon sizes to
214 // indicate that the favicon sizes are no longer known.
215 // Arbitrary favicons and favicon bitmaps associated to |page_url| and
216 // |icon_url| may be deleted in order to maintain the restriction for the
217 // max favicons per page, and max favicon bitmaps per icon URL.
218 // TODO(pkotwicz): Remove once no longer required by sync.
219 void MergeFavicon(const GURL& page_url,
220 const GURL& icon_url,
221 history::IconType icon_type,
222 scoped_refptr<base::RefCountedMemory> bitmap_data,
223 const gfx::Size& pixel_size);
224
225 // Set the favicon for |page_url| for |icon_type| in the thumbnail database.
226 // |icon_url| is the single favicon to map to |page_url|. Mappings from
227 // |page_url| to favicons at different icon URLs will be deleted.
228 // A favicon bitmap is added for each image rep in |image|. Any preexisting
229 // bitmap data for |icon_url| is deleted. It is important that |image|
230 // contains image reps for all of ui::GetSupportedScaleFactors(). Use
231 // MergeFavicon() if it does not.
232 // TODO(pkotwicz): Save unresized favicon bitmaps to the database.
233 // TODO(pkotwicz): Support adding favicons for multiple icon URLs to the
234 // thumbnail database.
235 void SetFavicons(
236 const GURL& page_url,
237 const GURL& icon_url,
238 history::IconType icon_type,
239 const gfx::Image& image);
192 240
193 private: 241 private:
194 HistoryService* history_service_; 242 HistoryService* history_service_;
195 243
196 // Helper to forward an empty result if we cannot get the history service. 244 // Helper to forward an empty result if we cannot get the history service.
197 void ForwardEmptyResultAsync(GetFaviconRequest* request); 245 void ForwardEmptyResultAsync(GetFaviconRequest* request);
198 246
199 // Helper function for GetFaviconImageForURL(), GetRawFaviconForURL() and 247 // Helper function for GetFaviconImageForURL(), GetRawFaviconForURL() and
200 // GetFaviconForURL(). 248 // GetFaviconForURL().
201 Handle GetFaviconForURLImpl( 249 Handle GetFaviconForURLImpl(
(...skipping 20 matching lines...) Expand all
222 ui::ScaleFactor desired_scale_factor, 270 ui::ScaleFactor desired_scale_factor,
223 FaviconRawCallback callback, 271 FaviconRawCallback callback,
224 Handle handle, 272 Handle handle,
225 std::vector<history::FaviconBitmapResult> favicon_bitmap_results, 273 std::vector<history::FaviconBitmapResult> favicon_bitmap_results,
226 history::IconURLSizesMap icon_url_sizes_map); 274 history::IconURLSizesMap icon_url_sizes_map);
227 275
228 DISALLOW_COPY_AND_ASSIGN(FaviconService); 276 DISALLOW_COPY_AND_ASSIGN(FaviconService);
229 }; 277 };
230 278
231 #endif // CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_ 279 #endif // CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/favicon/favicon_handler_unittest.cc ('k') | chrome/browser/favicon/favicon_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698