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

Unified 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: Removing FallbackIconStyleBuilder; trimming down chrome://fallback-icon syntax. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/fallback_icon_source.h
diff --git a/chrome/browser/ui/webui/fallback_icon_source.h b/chrome/browser/ui/webui/fallback_icon_source.h
new file mode 100644
index 0000000000000000000000000000000000000000..f741022811ea35c60168cfab7ce7ba51d2444f88
--- /dev/null
+++ b/chrome/browser/ui/webui/fallback_icon_source.h
@@ -0,0 +1,68 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_FALLBACK_ICON_SOURCE_H_
+#define CHROME_BROWSER_UI_WEBUI_FALLBACK_ICON_SOURCE_H_
+
+#include "components/favicon_base/fallback_icon_service.h"
+#include "content/public/browser/url_data_source.h"
+
+// FaviconSource is the gateway between network-level chrome:
pkotwicz 2015/01/23 16:00:47 FaviconSource -> FallbackIconSource
huangs 2015/01/23 19:47:50 Done.
+// requests for fallback icons and the backend that renders these.
+//
+// Format:
+// chrome://fallback-icon/size,bc,tc,fsr,r/url
+// Some parameters are optional as described below. However, the order of the
pkotwicz 2015/01/23 16:00:47 How about: "All of the parameters except for the u
huangs 2015/01/23 19:47:50 Done.
+// parameters is not interchangeable, and all "," must be in place.
+//
+// Parameter:
+// 'size' Optional
pkotwicz 2015/01/23 16:00:47 Nit: With my suggested comment you can remove the
huangs 2015/01/23 19:47:50 Done.
+// Positive integer to specify the fallback icon's size in pixels.
+// 'bc' Optional
+// Color in RRGBBBAA, RRGGBB, or RGB hex format, to specify the fallback
pkotwicz 2015/01/23 16:00:47 RRGBBAA -> RRGGBBAA
huangs 2015/01/23 19:47:50 Done.
+// icon's background color.
+// 'tc' Optional
+// Color in RRGBBBAA, RRGGBB, or RGB hex format, to specify the fallback
+// icon's text color.
pkotwicz 2015/01/23 16:00:47 RRGBBAA -> RRGGBBAA
huangs 2015/01/23 19:47:50 Done.
+// 'fsr' Optional
+// Number in [0.0, 1.0] to specify the request fallback icon's font size
+// (pixels) as a ratio to the icon's size.
pkotwicz 2015/01/23 16:00:47 "request fallback" -> "fallback"
huangs 2015/01/23 19:47:50 Done.
+// 'r' Optional
+// Number in [0.0, 1.0] to specify the request fallback icon's roundness.
pkotwicz 2015/01/23 16:00:47 "request fallback" -> "fallback"
huangs 2015/01/23 19:47:50 Done.
+// 0.0 specifies a square icon; 1.0 specifies a circle icon; intermediate
+// values specify a rounded square icon.
+// 'url' Required
+// String to specify the page URL of the fallback icon.
pkotwicz 2015/01/23 16:00:47 Nit: Add a new line
huangs 2015/01/23 19:47:50 Done.
+// Example: chrome://fallback-icon/32,fff,000,0.5,1.0/http://www.google.com/
+// This requests a 32x32 fallback icon for http://www.google.com, using
+// #fff as the background color, #000 as the text color, with font size of
+// 32 * 0.5 = 16, and the icon's background shape is a circle.
+class FallbackIconSource : public content::URLDataSource {
+ public:
+ FallbackIconSource();
+
+ ~FallbackIconSource() override;
+
+ // content::URLDataSource implementation.
+ std::string GetSource() const override;
+ void StartDataRequest(
+ const std::string& path,
+ int render_process_id,
+ int render_frame_id,
+ const content::URLDataSource::GotDataCallback& callback) override;
+ std::string GetMimeType(const std::string&) const override;
+ bool ShouldReplaceExistingSource() const override;
+ bool ShouldServiceRequest(const net::URLRequest* request) const override;
+
+ private:
+ // Sends the 16x16 DIP 1x default favicon.
pkotwicz 2015/01/23 16:00:47 How about: "Sends the default fallback icon."
huangs 2015/01/23 19:47:50 Done.
+ void SendDefaultResponse(
+ const content::URLDataSource::GotDataCallback& callback);
+
+ favicon_base::FallbackIconService fallback_icon_service_;
+
+ DISALLOW_COPY_AND_ASSIGN(FallbackIconSource);
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_FALLBACK_ICON_SOURCE_H_

Powered by Google App Engine
This is Rietveld 408576698