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

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: Adding new host chrome://fallback-icon. 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..728ca9a5cbe89ebd6b6bf373fabdc5a59fbf766e
--- /dev/null
+++ b/chrome/browser/ui/webui/fallback_icon_source.h
@@ -0,0 +1,66 @@
+// 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:
+// requests for fallback icons and the backend that renders these.
+//
+// Format:
+// chrome://fallback-icon/size&scalefactor/rendering specs/url
+// Some parameters are optional as described below. However, the order of the
+// parameters is not interchangeable.
+//
+// Parameter:
+// 'size&scalefactor' Optional
pkotwicz 2015/01/21 19:44:15 For simplicity, make all of the parameters mandato
huangs 2015/01/22 01:13:27 I really think size should be separate from styles
pkotwicz 2015/01/22 16:14:20 I don't think that making chrome://fallback-icon s
huangs 2015/01/22 22:51:39 Done, removed scale factor, and always have dummy
+// Values: ['size/aa@bx/']
+// 'size/aa@bx/':
+// Specifies the requested fallback icon's size in DIP (aa) and the
+// scale factor (b).
+// If the parameter is unspecified, the requested icon's size defaults
+// to 16 and the requested scale factor defaults to 1x.
+// Example: chrome://fallback-icon/size/16@2x/http://www.google.com/
+// 'style&specs' Optional
+// Values: ['style/<specs>/']
+// '<specs>':
+// Specifies styling parameters of a fallback con. <specs> is a
+// comma-separated string of fallback specifications. For details, see
+// /components/favicon_base/fallback_icon_specs_builder.h.
+// Example: chrome://fallback-icon/style/fff,000/http://www.google.com/
+// This requests the fallback icon for http://www.google.com, using
+// #fff as the background color and #000 as the text color.
+// 'url' Required
+// Specifies the page URL of the requested fallback icon.
+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.
+ 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