OLD | NEW |
---|---|
(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 "base/memory/scoped_ptr.h" | |
9 #include "components/favicon_base/fallback_icon_service.h" | |
10 #include "content/public/browser/url_data_source.h" | |
11 | |
12 // FallbackIconSource is the gateway between network-level chrome: | |
13 // requests for fallback icons and the backend that renders these. | |
Evan Stade
2015/03/05 02:54:42
"the backend that renders these"? How about:
Fall
huangs
2015/03/05 19:47:46
Done, added "explicit" since there will be an "imp
| |
14 // | |
15 // Format: | |
16 // chrome://fallback-icon/size,bc,tc,fsr,r/url | |
17 // All of the parameters except for the url are optional. However, the order of | |
18 // the parameters is not interchangeable, and all "," must be in place. | |
19 // | |
20 // Parameter: | |
21 // 'size' | |
22 // Positive integer to specify the fallback icon's size in pixels. | |
23 // 'bc' | |
24 // Fallback icon's background color, as named CSS color, or #RGB / #RRGGBB / | |
25 // #AARRGGBB hex formats. | |
26 // 'tc' | |
27 // Fallback icon text color, as named CSS color, or #RGB / #RRGGBB / | |
28 // #AARRGGBB hex formats. | |
29 // 'fsr' | |
30 // Number in [0.0, 1.0] to specify the fallback icon's font size (pixels) | |
31 // as a ratio to the icon's size. | |
32 // 'r' | |
33 // Number in [0.0, 1.0] to specify the fallback icon's roundness. | |
34 // 0.0 specifies a square icon; 1.0 specifies a circle icon; intermediate | |
35 // values specify a rounded square icon. | |
36 // 'url' | |
37 // String to specify the page URL of the fallback icon. | |
38 // | |
39 // Example: chrome://fallback-icon/32,red,#000,0.5,1.0/http://www.google.com/ | |
40 // This requests a 32x32 fallback icon for http://www.google.com, using | |
41 // red as the background color, #000 as the text color, with font size of | |
42 // 32 * 0.5 = 16, and the icon's background shape is a circle. | |
43 class FallbackIconSource : public content::URLDataSource { | |
44 public: | |
45 FallbackIconSource(); | |
46 | |
47 ~FallbackIconSource() override; | |
48 | |
49 // content::URLDataSource implementation. | |
50 std::string GetSource() const override; | |
51 void StartDataRequest( | |
52 const std::string& path, | |
53 int render_process_id, | |
54 int render_frame_id, | |
55 const content::URLDataSource::GotDataCallback& callback) override; | |
56 std::string GetMimeType(const std::string&) const override; | |
57 bool ShouldReplaceExistingSource() const override; | |
58 bool ShouldServiceRequest(const net::URLRequest* request) const override; | |
59 | |
60 private: | |
61 // Sends the default fallback icon. | |
62 void SendDefaultResponse( | |
63 const content::URLDataSource::GotDataCallback& callback); | |
64 | |
65 scoped_ptr<favicon_base::FallbackIconService> fallback_icon_service_; | |
66 | |
67 DISALLOW_COPY_AND_ASSIGN(FallbackIconSource); | |
68 }; | |
69 | |
70 #endif // CHROME_BROWSER_UI_WEBUI_FALLBACK_ICON_SOURCE_H_ | |
OLD | NEW |