Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / ui / webui / fallback_icon_source.h
blobbba497267891d14c4700d207df84070d37f17a73
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.
5 #ifndef CHROME_BROWSER_UI_WEBUI_FALLBACK_ICON_SOURCE_H_
6 #define CHROME_BROWSER_UI_WEBUI_FALLBACK_ICON_SOURCE_H_
8 #include <string>
10 #include "base/memory/scoped_ptr.h"
11 #include "content/public/browser/url_data_source.h"
13 class GURL;
15 namespace favicon_base {
16 struct FallbackIconStyle;
19 namespace favicon {
20 class FallbackIconService;
23 // FallbackIconSource services explicit chrome:// requests for fallback icons.
25 // Format:
26 // chrome://fallback-icon/size,bc,tc,fsr,r/url
27 // All of the parameters except for the url are optional. However, the order of
28 // the parameters is not interchangeable, and all "," must be in place.
30 // Parameter:
31 // 'size'
32 // Positive integer to specify the fallback icon's size in pixels.
33 // 'bc'
34 // Fallback icon's background color, as named CSS color, or RGB / ARGB /
35 // RRGGBB / AARRGGBB hex formats (no leading "#").
36 // 'tc'
37 // Fallback icon text color, as named CSS color, or RGB / ARGB / RRGGBB /
38 // AARRGGBB hex formats (no leading "#").
39 // 'fsr'
40 // Number in [0.0, 1.0] to specify the fallback icon's font size (pixels)
41 // as a ratio to the icon's size.
42 // 'r'
43 // Number in [0.0, 1.0] to specify the fallback icon's roundness.
44 // 0.0 specifies a square icon; 1.0 specifies a circle icon; intermediate
45 // values specify a rounded square icon.
46 // 'url'
47 // String to specify the page URL of the fallback icon.
49 // Example: chrome://fallback-icon/32,red,#000,0.5,1.0/http://www.google.com/
50 // This requests a 32x32 fallback icon for http://www.google.com, using
51 // red as the background color, #000 as the text color, with font size of
52 // 32 * 0.5 = 16, and the icon's background shape is a circle.
53 class FallbackIconSource : public content::URLDataSource {
54 public:
55 // |fallback_icon_service| is owned by caller, and may be null.
56 explicit FallbackIconSource(
57 favicon::FallbackIconService* fallback_icon_service);
59 ~FallbackIconSource() override;
61 // content::URLDataSource implementation.
62 std::string GetSource() const override;
63 void StartDataRequest(
64 const std::string& path,
65 int render_process_id,
66 int render_frame_id,
67 const content::URLDataSource::GotDataCallback& callback) override;
68 std::string GetMimeType(const std::string&) const override;
69 bool ShouldReplaceExistingSource() const override;
70 bool ShouldServiceRequest(const net::URLRequest* request) const override;
72 private:
73 void SendFallbackIconHelper(
74 const GURL& url,
75 int size_in_pixels,
76 const favicon_base::FallbackIconStyle& style,
77 const content::URLDataSource::GotDataCallback& callback);
79 // Sends the default fallback icon.
80 void SendDefaultResponse(
81 const content::URLDataSource::GotDataCallback& callback);
83 favicon::FallbackIconService* fallback_icon_service_;
85 DISALLOW_COPY_AND_ASSIGN(FallbackIconSource);
88 #endif // CHROME_BROWSER_UI_WEBUI_FALLBACK_ICON_SOURCE_H_