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

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

Issue 835903005: [Favicon] Add new fallback icon rendering flow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup and simplification. 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
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_WEBUI_FALLBACK_ICON_SOURCE_H_
6 #define CHROME_BROWSER_UI_WEBUI_FALLBACK_ICON_SOURCE_H_
7
8 #include "components/favicon_base/fallback_icon_service.h"
9 #include "content/public/browser/url_data_source.h"
10
11 // FallbackIconSource is the gateway between network-level chrome:
12 // requests for fallback icons and the backend that renders these.
13 //
14 // Format:
15 // chrome://fallback-icon/size,bc,tc,fsr,r/url
16 // All of the parameters except for the url are optional. However, the order of
17 // the parameters is not interchangeable, and all "," must be in place.
18 //
19 // Parameter:
20 // 'size'
21 // Positive integer to specify the fallback icon's size in pixels.
22 // 'bc'
23 // Color in RRGGBBAA, RRGGBB, or RGB hex format, to specify the fallback
24 // icon's background color.
25 // 'tc'
26 // Color in RRGGBBAA, RRGGBB, or RGB hex format, to specify the fallback
27 // icon's text color.
28 // 'fsr'
29 // Number in [0.0, 1.0] to specify the fallback icon's font size (pixels)
30 // as a ratio to the icon's size.
31 // 'r'
32 // Number in [0.0, 1.0] to specify the fallback icon's roundness.
33 // 0.0 specifies a square icon; 1.0 specifies a circle icon; intermediate
34 // values specify a rounded square icon.
35 // 'url'
36 // String to specify the page URL of the fallback icon.
37 //
38 // Example: chrome://fallback-icon/32,fff,000,0.5,1.0/http://www.google.com/
39 // This requests a 32x32 fallback icon for http://www.google.com, using
40 // #fff as the background color, #000 as the text color, with font size of
41 // 32 * 0.5 = 16, and the icon's background shape is a circle.
42 class FallbackIconSource : public content::URLDataSource {
43 public:
44 FallbackIconSource();
45
46 ~FallbackIconSource() override;
47
48 // content::URLDataSource implementation.
49 std::string GetSource() const override;
50 void StartDataRequest(
51 const std::string& path,
52 int render_process_id,
53 int render_frame_id,
54 const content::URLDataSource::GotDataCallback& callback) override;
55 std::string GetMimeType(const std::string&) const override;
56 bool ShouldReplaceExistingSource() const override;
57 bool ShouldServiceRequest(const net::URLRequest* request) const override;
58
59 private:
60 // Sends the default fallback icon.
61 void SendDefaultResponse(
62 const content::URLDataSource::GotDataCallback& callback);
63
64 favicon_base::FallbackIconService fallback_icon_service_;
65
66 DISALLOW_COPY_AND_ASSIGN(FallbackIconSource);
67 };
68
69 #endif // CHROME_BROWSER_UI_WEBUI_FALLBACK_ICON_SOURCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698