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

Unified Diff: ui/webui/resources/js/util.js

Issue 1318523011: [Password Manager] Copiable username and origin. Linkable origin elided from the left. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Icons appearance fixed Created 5 years, 2 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: ui/webui/resources/js/util.js
diff --git a/ui/webui/resources/js/util.js b/ui/webui/resources/js/util.js
index 3907c5215aa302660dd221706cfda9e6028ea6c0..b509fb1537d94c3f4cf14ead407e7cc4010d47fc 100644
--- a/ui/webui/resources/js/util.js
+++ b/ui/webui/resources/js/util.js
@@ -346,6 +346,46 @@ function getFaviconImageSet(url, opt_size, opt_type) {
}
/**
+ * Creates a CSS -webkit-image-set based on whether the url is secure.
+ * @param {string} url The url for the icon.
+ * @param {boolean} isUrlSecure True if the url is secure.
+ * @return {string} -webkit-image-set for the icon.
+ */
+function getIconBasedOnUrlSecurity(url, isUrlSecure) {
+ return isUrlSecure ?
+ getLargeiconOrFallbackIconImageSet(url, 16) :
+ getFaviconImageSet('', 16);
pkotwicz 2015/10/15 15:44:26 This code confuses me. Here is my understanding o
kolos1 2015/10/15 20:22:46 If the url is insecure, we show 'blank' icon. If
pkotwicz 2015/10/15 21:10:55 Sorry for my misunderstanding. I think that we sho
kolos1 2015/10/16 14:19:26 Thanks for your advices. Could you share your op
+}
+
+/**
+ * Creates a CSS -webkit-image-set for a large icon request. The service
+ * chrome://large-icon/ return a fallback icon, if there is no available icon.
+ * @param(string) path The url for the large icon.
+ * @param {number=} opt_size Optional preferred size of the large icon.
+ * @return {string} -webkit-image-set for the large icon.
+ */
+function getLargeiconOrFallbackIconImageSet(path, opt_size) {
+ // Description of fallback icon's parameters can be found in
+ // chrome/browser/ui/webui/fallback_icon_source.h.
+ // The first parameter is ignored, since the size of icon should be defined in
+ // the following way 'chrome://large-icon/size/...'.
+ var fallback_icon_parameters = 'fallback/,777,FFF,0.625,0.4/';
+ var size = opt_size || 16;
+ var supportedScaleFactors = getSupportedScaleFactors();
+ var result = '';
+ for (var i = 0; i < supportedScaleFactors.length; ++i) {
+ var scaleFactor = supportedScaleFactors[i];
+ var scaledSize = Math.round(size * scaleFactor);
+ var large_icon = 'chrome://large-icon/' + scaledSize + '/' +
+ fallback_icon_parameters + path;
+ result += url(large_icon) + ' ' + scaleFactor + 'x';
+ if (i != supportedScaleFactors.length - 1)
+ result += ', ';
+ }
+ return '-webkit-image-set(' + result + ')';
+}
+
+/**
* Creates a new URL for a favicon request for the current device pixel ratio.
* The URL must be updated when the user moves the browser to a screen with a
* different device pixel ratio. Use getFaviconImageSet() for the updating to

Powered by Google App Engine
This is Rietveld 408576698