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

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

Issue 835903005: [Favicon] Add new fallback icon rendering flow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactor by extracting FallbackIconSpecsBuilder. Created 5 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
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 <memory>
8 #include <vector> 9 #include <vector>
9 10
10 #include "base/callback.h" 11 #include "base/callback.h"
11 #include "base/containers/hash_tables.h" 12 #include "base/containers/hash_tables.h"
12 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
13 #include "base/task/cancelable_task_tracker.h" 14 #include "base/task/cancelable_task_tracker.h"
14 #include "components/favicon_base/favicon_callback.h" 15 #include "components/favicon_base/favicon_callback.h"
15 #include "components/favicon_base/favicon_types.h" 16 #include "components/favicon_base/favicon_types.h"
16 #include "components/keyed_service/core/keyed_service.h" 17 #include "components/keyed_service/core/keyed_service.h"
17 18
18 class FaviconClient; 19 class FaviconClient;
19 class GURL; 20 class GURL;
20 class HistoryService; 21 class HistoryService;
21 struct ImportedFaviconUsage; 22 struct ImportedFaviconUsage;
22 class Profile; 23 class Profile;
23 24
25 namespace favicon_base {
26 class FallbackIconService;
27 struct FallbackIconSpecs;
28 } // namespace favicon_base
29
24 // The favicon service provides methods to access favicons. It calls the history 30 // The favicon service provides methods to access favicons. It calls the history
25 // backend behind the scenes. The callbacks are run asynchronously, even in the 31 // backend behind the scenes. The callbacks are run asynchronously, even in the
26 // case of an error. 32 // case of an error.
27 class FaviconService : public KeyedService { 33 class FaviconService : public KeyedService {
28 public: 34 public:
29 // TODO(jif): Remove usage of Profile. http://crbug.com/378208. 35 // TODO(jif): Remove usage of Profile. http://crbug.com/378208.
30 // The FaviconClient must outlive the constructed FaviconService. 36 // The FaviconClient must outlive the constructed FaviconService.
31 FaviconService(Profile* profile, FaviconClient* favicon_client); 37 FaviconService(Profile* profile, FaviconClient* favicon_client);
32 38
33 ~FaviconService() override; 39 ~FaviconService() override;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // result for each of the resource scale factors. There are less entries if a 78 // result for each of the resource scale factors. There are less entries if a
73 // single/ result is the best bitmap to use for several resource scale 79 // single/ result is the best bitmap to use for several resource scale
74 // factors. 80 // factors.
75 base::CancelableTaskTracker::TaskId GetFavicon( 81 base::CancelableTaskTracker::TaskId GetFavicon(
76 const GURL& icon_url, 82 const GURL& icon_url,
77 favicon_base::IconType icon_type, 83 favicon_base::IconType icon_type,
78 int desired_size_in_dip, 84 int desired_size_in_dip,
79 const favicon_base::FaviconResultsCallback& callback, 85 const favicon_base::FaviconResultsCallback& callback,
80 base::CancelableTaskTracker* tracker); 86 base::CancelableTaskTracker* tracker);
81 87
88 // Generates a fallback favicon for |icon_url| with size |size_in_pixel|,
89 // using auxiliary rendering parameters in |params|. |size_in_pixel| = 0
90 // specifies maximum fallback favicon size. |specs| does not need to live
91 // beyond the function call.
pkotwicz 2015/01/19 04:32:02 My hope is that this function will never be needed
huangs 2015/01/20 22:20:41 Simplified, and named everything "FallbackIcon" or
92 base::CancelableTaskTracker::TaskId GetRawFallbackFaviconImage(
93 const GURL& icon_url,
94 favicon_base::IconType icon_type,
95 int desired_size_in_pixel,
96 const favicon_base::FallbackIconSpecs& specs,
97 const favicon_base::FaviconRawBitmapCallback& callback,
98 base::CancelableTaskTracker* tracker);
99
82 ////////////////////////////////////////////////////////////////////////////// 100 //////////////////////////////////////////////////////////////////////////////
83 // Methods to request favicon bitmaps from the history backend for |page_url|. 101 // Methods to request favicon bitmaps from the history backend for |page_url|.
84 // |page_url| is the web page the favicon is associated with. 102 // |page_url| is the web page the favicon is associated with.
85 // (e.g. <http://www.google.com>) 103 // (e.g. <http://www.google.com>)
86 104
87 // Requests the favicon for the page at |page_url| of type 105 // Requests the favicon for the page at |page_url| of type
88 // favicon_base::FAVICON and of size gfx::kFaviconSize. The returned 106 // favicon_base::FAVICON and of size gfx::kFaviconSize. The returned
89 // gfx::Image is populated with representations for all of the scale factors 107 // gfx::Image is populated with representations for all of the scale factors
90 // supported by the platform (e.g. MacOS). If data is unavailable for some or 108 // supported by the platform (e.g. MacOS). If data is unavailable for some or
91 // all of the scale factors, the bitmaps with the best matching sizes are 109 // all of the scale factors, the bitmaps with the best matching sizes are
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 225
208 // Avoid repeated requests to download missing favicon. 226 // Avoid repeated requests to download missing favicon.
209 void UnableToDownloadFavicon(const GURL& icon_url); 227 void UnableToDownloadFavicon(const GURL& icon_url);
210 bool WasUnableToDownloadFavicon(const GURL& icon_url) const; 228 bool WasUnableToDownloadFavicon(const GURL& icon_url) const;
211 void ClearUnableToDownloadFavicons(); 229 void ClearUnableToDownloadFavicons();
212 230
213 private: 231 private:
214 typedef uint32 MissingFaviconURLHash; 232 typedef uint32 MissingFaviconURLHash;
215 base::hash_set<MissingFaviconURLHash> missing_favicon_urls_; 233 base::hash_set<MissingFaviconURLHash> missing_favicon_urls_;
216 HistoryService* history_service_; 234 HistoryService* history_service_;
235 std::unique_ptr<favicon_base::FallbackIconService> fallback_icon_service_;
217 Profile* profile_; 236 Profile* profile_;
218 FaviconClient* favicon_client_; 237 FaviconClient* favicon_client_;
219 238
220 // Helper function for GetFaviconImageForPageURL(), GetRawFaviconForPageURL() 239 // Helper function for GetFaviconImageForPageURL(), GetRawFaviconForPageURL()
221 // and GetFaviconForPageURL(). 240 // and GetFaviconForPageURL().
222 base::CancelableTaskTracker::TaskId GetFaviconForPageURLImpl( 241 base::CancelableTaskTracker::TaskId GetFaviconForPageURLImpl(
223 const GURL& page_url, 242 const GURL& page_url,
224 int icon_types, 243 int icon_types,
225 const std::vector<int>& desired_sizes_in_pixel, 244 const std::vector<int>& desired_sizes_in_pixel,
226 const favicon_base::FaviconResultsCallback& callback, 245 const favicon_base::FaviconResultsCallback& callback,
(...skipping 16 matching lines...) Expand all
243 void RunFaviconRawBitmapCallbackWithBitmapResults( 262 void RunFaviconRawBitmapCallbackWithBitmapResults(
244 const favicon_base::FaviconRawBitmapCallback& callback, 263 const favicon_base::FaviconRawBitmapCallback& callback,
245 int desired_size_in_pixel, 264 int desired_size_in_pixel,
246 const std::vector<favicon_base::FaviconRawBitmapResult>& 265 const std::vector<favicon_base::FaviconRawBitmapResult>&
247 favicon_bitmap_results); 266 favicon_bitmap_results);
248 267
249 DISALLOW_COPY_AND_ASSIGN(FaviconService); 268 DISALLOW_COPY_AND_ASSIGN(FaviconService);
250 }; 269 };
251 270
252 #endif // CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_ 271 #endif // CHROME_BROWSER_FAVICON_FAVICON_SERVICE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/favicon/favicon_service.cc » ('j') | chrome/browser/ui/webui/favicon_source.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698