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