Commit e3e3dd9e authored by rbpotter's avatar rbpotter Committed by Commit Bot

Web UI Polymer 3: Change cr-toast-manager syntax

Change cr-toast-manager's cr.define to use:
cr.define(... () => {
  function foo() {}
  let bar = ...
  return {
    foo: foo,
  };
});
syntax, to make it simpler to autogenerate the Polymer 3 version of this
code by matching the polymer autogeneration script's approach to that of
the JS modulizer script.

It is possible to modify the autogeneration script to handle the code
as-is, but this requires adding more annotations (e.g. to indicate
whether variables should be let or const) and more complexity in the
script (e.g. to replace ": " with "= " and to correctly handle arrow
syntax).

Also fixing some typechecking errors that were found by the compiler
after changing the syntax.

Bug: 965770
Change-Id: I7a725ad8513f4141bba13e13cd842133105cb60a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1784101Reviewed-by: default avatarEsmael Elmoslimany <aee@chromium.org>
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#693410}
parent 7eabfd94
......@@ -474,7 +474,13 @@ cr.define('downloads', function() {
// Make the file name collapsible.
p.collapsible = !!p.arg;
});
cr.toastManager.getInstance().showForStringPieces(pieces, true);
cr.toastManager.getInstance().showForStringPieces(
/**
* @type {!Array<{collapsible: boolean,
* value: string,
* arg: (string|null)}>}
*/
(pieces), true);
this.mojoHandler_.remove(this.data.id);
},
......
......@@ -375,7 +375,7 @@ Polymer({
onMenuRemovePasswordTap_: function() {
this.passwordManager_.removeSavedPassword(
this.activePassword.item.entry.id);
cr.toastManager.getInstance().show(this.i18n('passwordDeleted'));
cr.toastManager.getInstance().show(this.i18n('passwordDeleted'), false);
/** @type {CrActionMenuElement} */ (this.$.menu).close();
},
......
......@@ -3,11 +3,18 @@
// found in the LICENSE file.
cr.define('cr.toastManager', () => {
/* eslint-disable */
/** @private {?CrToastManagerElement} */
let toastManagerInstance = null;
/* eslint-enable */
/** @return {!CrToastManagerElement} */
function getInstance() {
return assert(cr.toastManager.toastManagerInstance);
}
return {
/** @private {?CrToastManagerElement} */
instance_: null,
/** @return {!CrToastManagerElement} */
getInstance: () => assert(cr.toastManager.instance_),
getInstance: getInstance,
};
});
......@@ -43,13 +50,13 @@ Polymer({
/** @override */
attached: function() {
assert(!cr.toastManager.instance_);
cr.toastManager.instance_ = this;
assert(!cr.toastManager.toastManagerInstance);
cr.toastManager.toastManagerInstance = this;
},
/** @override */
detached: function() {
cr.toastManager.instance_ = null;
cr.toastManager.toastManagerInstance = null;
},
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment