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

Unified Diff: chrome/browser/resources/md_downloads/crisper.js

Issue 1929763002: Update Polymer.IronValidatableBehavior (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/resources/md_downloads/vulcanized.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/md_downloads/crisper.js
diff --git a/chrome/browser/resources/md_downloads/crisper.js b/chrome/browser/resources/md_downloads/crisper.js
index f3935b2a46fe41ed7baaaf408c8f88398811bf53..6ffd15575e53698cff353a941a98601ce5785ff8 100644
--- a/chrome/browser/resources/md_downloads/crisper.js
+++ b/chrome/browser/resources/md_downloads/crisper.js
@@ -1189,30 +1189,6 @@ function announceAccessibleMessage(msg) {
}
/**
- * Returns the scale factors supported by this platform for webui
- * resources.
- * @return {Array} The supported scale factors.
- */
-function getSupportedScaleFactors() {
- var supportedScaleFactors = [];
- if (cr.isMac || cr.isChromeOS || cr.isWindows || cr.isLinux) {
- // All desktop platforms support zooming which also updates the
- // renderer's device scale factors (a.k.a devicePixelRatio), and
- // these platforms has high DPI assets for 2.0x. Use 1x and 2x in
- // image-set on these platforms so that the renderer can pick the
- // closest image for the current device scale factor.
- supportedScaleFactors.push(1);
- supportedScaleFactors.push(2);
- } else {
- // For other platforms that use fixed device scale factor, use
- // the window's device pixel ratio.
- // TODO(oshima): Investigate if Android/iOS need to use image-set.
- supportedScaleFactors.push(window.devicePixelRatio);
- }
- return supportedScaleFactors;
-}
-
-/**
* Generates a CSS url string.
* @param {string} s The URL to generate the CSS url for.
* @return {string} The CSS url string.
@@ -1232,51 +1208,6 @@ function url(s) {
}
/**
- * Returns the URL of the image, or an image set of URLs for the profile avatar.
- * Default avatars have resources available for multiple scalefactors, whereas
- * the GAIA profile image only comes in one size.
- *
- * @param {string} path The path of the image.
- * @return {string} The url, or an image set of URLs of the avatar image.
- */
-function getProfileAvatarIcon(path) {
- var chromeThemePath = 'chrome://theme';
- var isDefaultAvatar =
- (path.slice(0, chromeThemePath.length) == chromeThemePath);
- return isDefaultAvatar ? imageset(path + '@scalefactorx'): url(path);
-}
-
-/**
- * Generates a CSS -webkit-image-set for a chrome:// url.
- * An entry in the image set is added for each of getSupportedScaleFactors().
- * The scale-factor-specific url is generated by replacing the first instance of
- * 'scalefactor' in |path| with the numeric scale factor.
- * @param {string} path The URL to generate an image set for.
- * 'scalefactor' should be a substring of |path|.
- * @return {string} The CSS -webkit-image-set.
- */
-function imageset(path) {
- var supportedScaleFactors = getSupportedScaleFactors();
-
- var replaceStartIndex = path.indexOf('scalefactor');
- if (replaceStartIndex < 0)
- return url(path);
-
- var s = '';
- for (var i = 0; i < supportedScaleFactors.length; ++i) {
- var scaleFactor = supportedScaleFactors[i];
- var pathWithScaleFactor = path.substr(0, replaceStartIndex) + scaleFactor +
- path.substr(replaceStartIndex + 'scalefactor'.length);
-
- s += url(pathWithScaleFactor) + ' ' + scaleFactor + 'x';
-
- if (i != supportedScaleFactors.length - 1)
- s += ', ';
- }
- return '-webkit-image-set(' + s + ')';
-}
-
-/**
* Parses query parameters from Location.
* @param {Location} location The URL to generate the CSS url for.
* @return {Object} Dictionary containing name value pairs for URL
@@ -1468,34 +1399,6 @@ function appendParam(url, key, value) {
}
/**
- * A regular expression for identifying favicon URLs.
- * @const {!RegExp}
- * TODO(dpapad): Move all favicon related methods to a new favicon_util.js file
- * and make this RegExp private.
- */
-var FAVICON_URL_REGEX = /\.ico$/i;
-
-/**
- * Creates a CSS -webkit-image-set for a favicon request.
- * @param {string} url Either the URL of the original page or of the favicon
- * itself.
- * @param {number=} opt_size Optional preferred size of the favicon.
- * @param {string=} opt_type Optional type of favicon to request. Valid values
- * are 'favicon' and 'touch-icon'. Default is 'favicon'.
- * @return {string} -webkit-image-set for the favicon.
- */
-function getFaviconImageSet(url, opt_size, opt_type) {
- var size = opt_size || 16;
- var type = opt_type || 'favicon';
-
- return imageset(
- 'chrome://' + type + '/size/' + size + '@scalefactorx/' +
- // Note: Literal 'iconurl' must match |kIconURLParameter| in
- // components/favicon_base/favicon_url_parser.cc.
- (FAVICON_URL_REGEX.test(url) ? 'iconurl/' : '') + url);
-}
-
-/**
* Creates an element of a specified type with a specified class name.
* @param {string} type The node type.
* @param {string} className The class name to use.
@@ -10284,6 +10187,11 @@ Polymer({
};
})();
/**
+ * Singleton IronMeta instance.
+ */
+ Polymer.IronValidatableBehaviorMeta = null;
+
+ /**
* `Use Polymer.IronValidatableBehavior` to implement an element that validates user input.
* Use the related `Polymer.IronValidatorBehavior` to add custom validation logic to an iron-input.
*
@@ -10312,14 +10220,6 @@ Polymer({
properties: {
/**
- * Namespace for this validator.
- */
- validatorType: {
- type: String,
- value: 'validator'
- },
-
- /**
* Name of the validator to use.
*/
validator: {
@@ -10336,22 +10236,36 @@ Polymer({
value: false
},
+ /**
+ * This property is deprecated and should not be used. Use the global
+ * validator meta singleton, `Polymer.IronValidatableBehaviorMeta` instead.
+ */
_validatorMeta: {
type: Object
- }
+ },
+ /**
+ * Namespace for this validator. This property is deprecated and should
+ * not be used. For all intents and purposes, please consider it a
+ * read-only, config-time property.
+ */
+ validatorType: {
+ type: String,
+ value: 'validator'
+ },
+
+ _validator: {
+ type: Object,
+ computed: '__computeValidator(validator)'
+ }
},
observers: [
'_invalidChanged(invalid)'
],
- get _validator() {
- return this._validatorMeta && this._validatorMeta.byKey(this.validator);
- },
-
- ready: function() {
- this._validatorMeta = new Polymer.IronMeta({type: this.validatorType});
+ registered: function() {
+ Polymer.IronValidatableBehaviorMeta = new Polymer.IronMeta({type: 'validator'});
},
_invalidChanged: function() {
@@ -10398,6 +10312,11 @@ Polymer({
return this._validator.validate(value);
}
return true;
+ },
+
+ __computeValidator: function() {
+ return Polymer.IronValidatableBehaviorMeta &&
+ Polymer.IronValidatableBehaviorMeta.byKey(this.validator);
}
};
/*
« no previous file with comments | « no previous file | chrome/browser/resources/md_downloads/vulcanized.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698