Commit ab321585 authored by Demetrios Papadopoulos's avatar Demetrios Papadopoulos Committed by Commit Bot

Settings: Remove patterns that break semi-automatic Polymer3 migration.

This is in preparation of running auto conversion tools for c/b/r/settings.

Bug: 1026426
Change-Id: I1a1fdbd1f97910c2611f54f8f0ccb87192b4ad52
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2001379
Auto-Submit: Demetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Commit-Queue: Demetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#731661}
parent cdd1d6e3
...@@ -20,136 +20,136 @@ cr.define('settings', function() { ...@@ -20,136 +20,136 @@ cr.define('settings', function() {
*/ */
const CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW = 4; const CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW = 4;
return {ChromeCleanupRemovalListItem, CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW}; /**
}); * @fileoverview
* 'items-to-remove-list' represents a list of items to
/** * be removed or changed to be shown on the Chrome Cleanup page.
* @fileoverview * TODO(crbug.com/776538): Update the strings to say that some items are only
* 'items-to-remove-list' represents a list of items to * changed and not removed.
* be removed or changed to be shown on the Chrome Cleanup page. *
* TODO(crbug.com/776538): Update the strings to say that some items are only * Example:
* changed and not removed. *
* * <!-- Items list initially shows |CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW|
* Example: * items. If there are more than
* * |CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW| items on the list, then a "show
* <!-- Items list initially shows |CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW| * more" link is shown; tapping on it expands the list. -->
* items. If there are more than |CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW| * <items-to-remove-list
* items on the list, then a "show more" link is shown; tapping on it * title="Files and programs:"
* expands the list. --> * items-to-show="[[filesToShow]]">
* <items-to-remove-list * </items-to-remove-list>
* title="Files and programs:" */
* items-to-show="[[filesToShow]]"> Polymer({
* </items-to-remove-list> is: 'items-to-remove-list',
*/
Polymer({ properties: {
is: 'items-to-remove-list', title: {
type: String,
properties: { value: '',
title: { },
type: String,
value: '', /** @type {!Array<settings.ChromeCleanupRemovalListItem>} */
itemsToShow: {
type: Array,
observer: 'updateVisibleState_',
},
/**
* If true, all items from |itemsToShow| will be presented on the card,
* and the "show more" link will be omitted.
*/
expanded_: {
type: Boolean,
value: false,
},
/**
* The first |CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW| items of |itemsToShow|
* if the list is longer than |CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW|.
* @private {?Array<settings.ChromeCleanupRemovalListItem>}
*/
initialItems_: Array,
/**
* The remaining items to be presented that are not included in
* |initialItems_|. Items in this list are only shown to the user if
* |expanded_| is true.
* @private {?Array<settings.ChromeCleanupRemovalListItem>}
*/
remainingItems_: Array,
/**
* The text for the "show more" link available if not all files are
* visible in the card.
* @private
*/
moreItemsLinkText_: {
type: String,
value: '',
},
}, },
/** @type {!Array<settings.ChromeCleanupRemovalListItem>} */ /** @private */
itemsToShow: { expandList_() {
type: Array, this.expanded_ = true;
observer: 'updateVisibleState_', this.moreItemsLinkText_ = '';
}, },
/** /**
* If true, all items from |itemsToShow| will be presented on the card, * Decides which elements will be visible in the card and if the "show more"
* and the "show more" link will be omitted. * link will be rendered.
*
* 1. If size(itemsToShow) < CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW, then all
* items will be visible.
* 2. Otherwise, exactly |CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW - 1| will be
* visible and the "show more" link will be rendered. The list presented
* to the user will contain exactly |CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW|
* elements, and the last one will be the "show more" link.
*
* @param {!Array<settings.ChromeCleanupRemovalListItem>} itemsToShow
*/ */
expanded_: { updateVisibleState_(itemsToShow) {
type: Boolean, // Start expanded if there are less than
value: false, // |settings.CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW| items to show.
this.expanded_ =
itemsToShow.length <= settings.CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW;
if (this.expanded_) {
this.initialItems_ = itemsToShow;
this.remainingItems_ = [];
this.moreItemsLinkText_ = '';
return;
}
this.initialItems_ = itemsToShow.slice(
0, settings.CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW - 1);
this.remainingItems_ =
itemsToShow.slice(settings.CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW - 1);
const browserProxy = settings.ChromeCleanupProxyImpl.getInstance();
browserProxy.getMoreItemsPluralString(this.remainingItems_.length)
.then(linkText => {
this.moreItemsLinkText_ = linkText;
});
}, },
/** /**
* The first |CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW| items of |itemsToShow| * Returns the class for the <li> elements that correspond to the items
* if the list is longer than |CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW|. * hidden in the default view.
* @private {?Array<settings.ChromeCleanupRemovalListItem>} * @param {boolean} expanded
*/
initialItems_: Array,
/**
* The remaining items to be presented that are not included in
* |initialItems_|. Items in this list are only shown to the user if
* |expanded_| is true.
* @private {?Array<settings.ChromeCleanupRemovalListItem>}
*/ */
remainingItems_: Array, remainingItemsClass_(expanded) {
return expanded ? 'visible-item' : 'hidden-item';
},
/** /**
* The text for the "show more" link available if not all files are visible * @param {settings.ChromeCleanupRemovalListItem} item
* in the card. * @return {boolean} Whether a highlight suffix exists.
* @private * @private
*/ */
moreItemsLinkText_: { hasHighlightSuffix_(item) {
type: String, return item.highlightSuffix !== null;
value: '',
}, },
}, });
/** @private */
expandList_() {
this.expanded_ = true;
this.moreItemsLinkText_ = '';
},
/** return {ChromeCleanupRemovalListItem, CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW};
* Decides which elements will be visible in the card and if the "show more"
* link will be rendered.
*
* 1. If size(itemsToShow) < CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW, then all
* items will be visible.
* 2. Otherwise, exactly |CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW - 1| will be
* visible and the "show more" link will be rendered. The list presented to
* the user will contain exactly |CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW|
* elements, and the last one will be the "show more" link.
*
* @param {!Array<settings.ChromeCleanupRemovalListItem>} itemsToShow
*/
updateVisibleState_(itemsToShow) {
// Start expanded if there are less than
// |settings.CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW| items to show.
this.expanded_ =
itemsToShow.length <= settings.CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW;
if (this.expanded_) {
this.initialItems_ = itemsToShow;
this.remainingItems_ = [];
this.moreItemsLinkText_ = '';
return;
}
this.initialItems_ =
itemsToShow.slice(0, settings.CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW - 1);
this.remainingItems_ =
itemsToShow.slice(settings.CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW - 1);
const browserProxy = settings.ChromeCleanupProxyImpl.getInstance();
browserProxy.getMoreItemsPluralString(this.remainingItems_.length)
.then(linkText => {
this.moreItemsLinkText_ = linkText;
});
},
/**
* Returns the class for the <li> elements that correspond to the items hidden
* in the default view.
* @param {boolean} expanded
*/
remainingItemsClass_(expanded) {
return expanded ? 'visible-item' : 'hidden-item';
},
/**
* @param {settings.ChromeCleanupRemovalListItem} item
* @return {boolean} Whether a highlight suffix exists.
* @private
*/
hasHighlightSuffix_(item) {
return item.highlightSuffix !== null;
},
}); });
...@@ -35,6 +35,5 @@ ...@@ -35,6 +35,5 @@
<cr-button on-click="onDisableTap_">$i18n{disable}</cr-button> <cr-button on-click="onDisableTap_">$i18n{disable}</cr-button>
</template> </template>
</template> </template>
<script src="extension_controlled_indicator.js"></script>
</dom-module> </dom-module>
<script src="extension_controlled_indicator.js"></script>
...@@ -16,192 +16,193 @@ cr.define('settings', function() { ...@@ -16,192 +16,193 @@ cr.define('settings', function() {
*/ */
let PINFieldSubmitFunc; let PINFieldSubmitFunc;
return {
PINFieldSubmitFunc: PINFieldSubmitFunc,
};
});
Polymer({ Polymer({
is: 'settings-security-keys-pin-field', is: 'settings-security-keys-pin-field',
behaviors: [ behaviors: [
I18nBehavior, I18nBehavior,
], ],
properties: { properties: {
/* @private */ /* @private */
error_: { error_: {
type: String, type: String,
observer: 'errorChanged_', observer: 'errorChanged_',
}, },
/* @private */ /* @private */
value_: String, value_: String,
/* @private */ /* @private */
inputVisible_: { inputVisible_: {
type: Boolean, type: Boolean,
value: false, value: false,
},
}, },
},
/** @override */ /** @override */
attached() { attached() {
Polymer.RenderStatus.afterNextRender(this, function() { Polymer.RenderStatus.afterNextRender(this, function() {
Polymer.IronA11yAnnouncer.requestAvailability(); Polymer.IronA11yAnnouncer.requestAvailability();
}); });
}, },
/** Focuses the PIN input field. */ /** Focuses the PIN input field. */
focus() { focus() {
this.$.pin.focus(); this.$.pin.focus();
}, },
/** /**
* Validates the PIN and sets the validation error if it is not valid. * Validates the PIN and sets the validation error if it is not valid.
* @return {boolean} True iff the PIN is valid. * @return {boolean} True iff the PIN is valid.
* @private * @private
*/ */
validate_() { validate_() {
const error = this.isValidPIN_(this.value_); const error = this.isValidPIN_(this.value_);
if (error != '') { if (error != '') {
this.error_ = error; this.error_ = error;
return false; return false;
} }
return true; return true;
}, },
/** /**
* Attempts submission of the PIN by invoking |submitFunc|. Updates the UI to * Attempts submission of the PIN by invoking |submitFunc|. Updates the UI
* show an error if the PIN was incorrect. * to show an error if the PIN was incorrect.
* @param {!settings.PINFieldSubmitFunc} submitFunc * @param {!settings.PINFieldSubmitFunc} submitFunc
* @return {!Promise} resolves if the PIN was correct, else rejects * @return {!Promise} resolves if the PIN was correct, else rejects
*/ */
trySubmit(submitFunc) { trySubmit(submitFunc) {
if (!this.validate_()) { if (!this.validate_()) {
this.focus();
return Promise.reject();
}
return submitFunc(this.value_).then(retries => {
if (retries != null) {
this.showIncorrectPINError_(retries);
this.focus(); this.focus();
return Promise.reject(); return Promise.reject();
} }
}); return submitFunc(this.value_).then(retries => {
}, if (retries != null) {
this.showIncorrectPINError_(retries);
this.focus();
return Promise.reject();
}
});
},
/** /**
* Sets the validation error to indicate the PIN was incorrect. * Sets the validation error to indicate the PIN was incorrect.
* @param {number} retries The number of retries remaining. * @param {number} retries The number of retries remaining.
* @private * @private
*/ */
showIncorrectPINError_(retries) { showIncorrectPINError_(retries) {
// Warn the user if the number of retries is getting low. // Warn the user if the number of retries is getting low.
let error; let error;
if (1 < retries && retries <= 3) { if (1 < retries && retries <= 3) {
error = error =
this.i18n('securityKeysPINIncorrectRetriesPl', retries.toString()); this.i18n('securityKeysPINIncorrectRetriesPl', retries.toString());
} else if (retries == 1) { } else if (retries == 1) {
error = this.i18n('securityKeysPINIncorrectRetriesSin'); error = this.i18n('securityKeysPINIncorrectRetriesSin');
} else { } else {
error = this.i18n('securityKeysPINIncorrect'); error = this.i18n('securityKeysPINIncorrect');
} }
this.error_ = error; this.error_ = error;
}, },
/** @private */
onPINInput_() {
// Typing in the PIN box after an error makes the error message
// disappear.
this.error_ = '';
},
/** /** @private */
* Polymer helper function to detect when an error string is empty. onPINInput_() {
* @param {string} s Arbitrary string // Typing in the PIN box after an error makes the error message
* @return {boolean} True iff |s| is non-empty. // disappear.
* @private this.error_ = '';
*/ },
isNonEmpty_(s) {
return s != '';
},
/** /**
* @return {string} The PIN-input element type. * Polymer helper function to detect when an error string is empty.
* @private * @param {string} s Arbitrary string
*/ * @return {boolean} True iff |s| is non-empty.
inputType_() { * @private
return this.inputVisible_ ? 'text' : 'password'; */
}, isNonEmpty_(s) {
return s != '';
},
/** /**
* @return {string} The class (and thus icon) to be displayed. * @return {string} The PIN-input element type.
* @private * @private
*/ */
showButtonClass_() { inputType_() {
return 'icon-visibility' + (this.inputVisible_ ? '-off' : ''); return this.inputVisible_ ? 'text' : 'password';
}, },
/** /**
* @return {string} The tooltip for the icon. * @return {string} The class (and thus icon) to be displayed.
* @private * @private
*/ */
showButtonTitle_() { showButtonClass_() {
return this.i18n( return 'icon-visibility' + (this.inputVisible_ ? '-off' : '');
this.inputVisible_ ? 'securityKeysHidePINs' : 'securityKeysShowPINs'); },
},
/** /**
* onClick handler for the show/hide icon. * @return {string} The tooltip for the icon.
* @private * @private
*/ */
showButtonClick_() { showButtonTitle_() {
this.inputVisible_ = !this.inputVisible_; return this.i18n(
}, this.inputVisible_ ? 'securityKeysHidePINs' : 'securityKeysShowPINs');
},
/** /**
* @param {string} pin A candidate PIN. * onClick handler for the show/hide icon.
* @return {string} An error string or else '' to indicate validity. * @private
* @private */
*/ showButtonClick_() {
isValidPIN_(pin) { this.inputVisible_ = !this.inputVisible_;
// The UTF-8 encoding of the PIN must be between 4 },
// and 63 bytes, and the final byte cannot be zero.
const utf8Encoded = new TextEncoder().encode(pin); /**
if (utf8Encoded.length < 4) { * @param {string} pin A candidate PIN.
return this.i18n('securityKeysPINTooShort'); * @return {string} An error string or else '' to indicate validity.
} * @private
if (utf8Encoded.length > 63 || */
// If the PIN somehow has a NUL at the end then it's invalid, but this isValidPIN_(pin) {
// is so obscure that we don't try to message it. Rather we just say // The UTF-8 encoding of the PIN must be between 4
// that it's too long because trimming the final character is the best // and 63 bytes, and the final byte cannot be zero.
// response by the user. const utf8Encoded = new TextEncoder().encode(pin);
utf8Encoded[utf8Encoded.length - 1] == 0) { if (utf8Encoded.length < 4) {
return this.i18n('securityKeysPINTooLong'); return this.i18n('securityKeysPINTooShort');
} }
if (utf8Encoded.length > 63 ||
// A PIN must contain at least four code-points. Javascript strings are // If the PIN somehow has a NUL at the end then it's invalid, but this
// UCS-2 and the |length| property counts UCS-2 elements, not code-points. // is so obscure that we don't try to message it. Rather we just say
// (For example, '\u{1f6b4}'.length == 2, but it's a single code-point.) // that it's too long because trimming the final character is the best
// Therefore, iterate over the string (which does yield codepoints) and // response by the user.
// check that four or more were seen. utf8Encoded[utf8Encoded.length - 1] == 0) {
let length = 0; return this.i18n('securityKeysPINTooLong');
for (const codepoint of pin) { }
length++;
} // A PIN must contain at least four code-points. Javascript strings are
// UCS-2 and the |length| property counts UCS-2 elements, not code-points.
if (length < 4) { // (For example, '\u{1f6b4}'.length == 2, but it's a single code-point.)
return this.i18n('securityKeysPINTooShort'); // Therefore, iterate over the string (which does yield codepoints) and
} // check that four or more were seen.
let length = 0;
return ''; for (const codepoint of pin) {
}, length++;
}
/** @private */
errorChanged_() { if (length < 4) {
// Make screen readers announce changes to the PIN validation error return this.i18n('securityKeysPINTooShort');
// label. }
this.fire('iron-announce', {text: this.error_});
}, return '';
},
/** @private */
errorChanged_() {
// Make screen readers announce changes to the PIN validation error
// label.
this.fire('iron-announce', {text: this.error_});
},
});
return {
PINFieldSubmitFunc: PINFieldSubmitFunc,
};
}); });
...@@ -19,147 +19,141 @@ cr.define('settings', function() { ...@@ -19,147 +19,141 @@ cr.define('settings', function() {
}; };
return { Polymer({
ResetDialogPage: ResetDialogPage, is: 'settings-security-keys-reset-dialog',
};
}); behaviors: [I18nBehavior],
(function() { properties: {
'use strict'; /**
* A CTAP error code for when the specific error was not recognised.
* @private
*/
errorCode_: Number,
/**
* True iff the process has completed, successfully or otherwise.
* @private
*/
complete_: {
type: Boolean,
value: false,
},
/**
* The id of an element on the page that is currently shown.
* @private {!settings.ResetDialogPage}
*/
shown_: {
type: String,
value: ResetDialogPage.INITIAL,
},
/**
* @private
*/
title_: String,
},
const ResetDialogPage = settings.ResetDialogPage; /** @private {?settings.SecurityKeysResetBrowserProxy} */
browserProxy_: null,
/** @override */
attached() {
this.title_ = this.i18n('securityKeysResetTitle');
this.browserProxy_ =
settings.SecurityKeysResetBrowserProxyImpl.getInstance();
this.$.dialog.showModal();
this.browserProxy_.reset().then(code => {
// code is a CTAP error code. See
// https://fidoalliance.org/specs/fido-v2.0-rd-20180702/fido-client-to-authenticator-protocol-v2.0-rd-20180702.html#error-responses
if (code == 1 /* INVALID_COMMAND */) {
this.shown_ = ResetDialogPage.NO_RESET;
this.finish_();
} else if (code != 0 /* unknown error */) {
this.errorCode_ = code;
this.shown_ = ResetDialogPage.RESET_FAILED;
this.finish_();
} else {
this.title_ = this.i18n('securityKeysResetConfirmTitle');
this.shown_ = ResetDialogPage.RESET_CONFIRM;
this.browserProxy_.completeReset().then(code => {
this.title_ = this.i18n('securityKeysResetTitle');
if (code == 0 /* SUCCESS */) {
this.shown_ = ResetDialogPage.RESET_SUCCESS;
} else if (code == 48 /* NOT_ALLOWED */) {
this.shown_ = ResetDialogPage.RESET_NOT_ALLOWED;
} else /* unknown error */ {
this.errorCode_ = code;
this.shown_ = ResetDialogPage.RESET_FAILED;
}
this.finish_();
});
}
});
},
Polymer({ /** @private */
is: 'settings-security-keys-reset-dialog', closeDialog_() {
this.$.dialog.close();
this.finish_();
},
behaviors: [I18nBehavior], /** @private */
finish_() {
if (this.complete_) {
return;
}
this.complete_ = true;
this.browserProxy_.close();
},
properties: {
/** /**
* A CTAP error code for when the specific error was not recognised. * @param {!Event} e
* @private * @private
*/ */
errorCode_: Number, onIronSelect_(e) {
// Prevent this event from bubbling since it is unnecessarily triggering
// the listener within settings-animated-pages.
e.stopPropagation();
},
/** /**
* True iff the process has completed, successfully or otherwise. @param {number} code CTAP error code.
* @private @return {string} Contents of the error string that may be displayed
to the user. Used automatically by Polymer.
@private
*/ */
complete_: { resetFailed_(code) {
type: Boolean, if (code === null) {
value: false, return '';
}
return this.i18n('securityKeysResetError', code.toString());
}, },
/** /**
* The id of an element on the page that is currently shown. * @param {boolean} complete Whether the dialog process is complete.
* @private {!settings.ResetDialogPage} * @return {string} The label of the dialog button. Used automatically by
* Polymer.
* @private
*/ */
shown_: { closeText_(complete) {
type: String, return this.i18n(complete ? 'ok' : 'cancel');
value: ResetDialogPage.INITIAL,
}, },
/** /**
* @param {boolean} complete Whether the dialog process is complete.
* @return {string} The class of the dialog button. Used automatically by
* Polymer.
* @private * @private
*/ */
title_: String, maybeActionButton_(complete) {
}, return complete ? 'action-button' : 'cancel-button';
},
/** @private {?settings.SecurityKeysResetBrowserProxy} */ });
browserProxy_: null,
return {
/** @override */ ResetDialogPage: ResetDialogPage,
attached() { };
this.title_ = this.i18n('securityKeysResetTitle');
this.browserProxy_ =
settings.SecurityKeysResetBrowserProxyImpl.getInstance();
this.$.dialog.showModal();
this.browserProxy_.reset().then(code => {
// code is a CTAP error code. See
// https://fidoalliance.org/specs/fido-v2.0-rd-20180702/fido-client-to-authenticator-protocol-v2.0-rd-20180702.html#error-responses
if (code == 1 /* INVALID_COMMAND */) {
this.shown_ = ResetDialogPage.NO_RESET;
this.finish_();
} else if (code != 0 /* unknown error */) {
this.errorCode_ = code;
this.shown_ = ResetDialogPage.RESET_FAILED;
this.finish_();
} else {
this.title_ = this.i18n('securityKeysResetConfirmTitle');
this.shown_ = ResetDialogPage.RESET_CONFIRM;
this.browserProxy_.completeReset().then(code => {
this.title_ = this.i18n('securityKeysResetTitle');
if (code == 0 /* SUCCESS */) {
this.shown_ = ResetDialogPage.RESET_SUCCESS;
} else if (code == 48 /* NOT_ALLOWED */) {
this.shown_ = ResetDialogPage.RESET_NOT_ALLOWED;
} else /* unknown error */ {
this.errorCode_ = code;
this.shown_ = ResetDialogPage.RESET_FAILED;
}
this.finish_();
});
}
});
},
/** @private */
closeDialog_() {
this.$.dialog.close();
this.finish_();
},
/** @private */
finish_() {
if (this.complete_) {
return;
}
this.complete_ = true;
this.browserProxy_.close();
},
/**
* @param {!Event} e
* @private
*/
onIronSelect_(e) {
// Prevent this event from bubbling since it is unnecessarily triggering the
// listener within settings-animated-pages.
e.stopPropagation();
},
/**
@param {number} code CTAP error code.
@return {string} Contents of the error string that may be displayed
to the user. Used automatically by Polymer.
@private
*/
resetFailed_(code) {
if (code === null) {
return '';
}
return this.i18n('securityKeysResetError', code.toString());
},
/**
* @param {boolean} complete Whether the dialog process is complete.
* @return {string} The label of the dialog button. Used automatically by
* Polymer.
* @private
*/
closeText_(complete) {
return this.i18n(complete ? 'ok' : 'cancel');
},
/**
* @param {boolean} complete Whether the dialog process is complete.
* @return {string} The class of the dialog button. Used automatically by
* Polymer.
* @private
*/
maybeActionButton_(complete) {
return complete ? 'action-button' : 'cancel-button';
},
}); });
})();
...@@ -2,55 +2,51 @@ ...@@ -2,55 +2,51 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
(function() { cr.define('settings.WebsiteUsagePrivateApi', function() {
'use strict'; Polymer({
is: 'website-usage-private-api',
properties: {
/**
* The amount of data used by the given website.
*/
websiteDataUsage: {
type: String,
notify: true,
},
/**
* The number of cookies used by the given website.
*/
websiteCookieUsage: {
type: String,
notify: true,
},
},
Polymer({ /** @override */
is: 'website-usage-private-api', attached() {
settings.WebsiteUsagePrivateApi.websiteUsagePolymerInstance = this;
},
properties: { /** @param {string} host */
/** fetchUsageTotal(host) {
* The amount of data used by the given website. settings.WebsiteUsagePrivateApi.fetchUsageTotal(host);
*/
websiteDataUsage: {
type: String,
notify: true,
}, },
/** /**
* The number of cookies used by the given website. * @param {string} origin
*/ */
websiteCookieUsage: { clearUsage(origin) {
type: String, settings.WebsiteUsagePrivateApi.clearUsage(origin);
notify: true,
}, },
},
/** @override */
attached() {
settings.WebsiteUsagePrivateApi.websiteUsagePolymerInstance = this;
},
/** @param {string} host */ /** @param {string} origin */
fetchUsageTotal(host) { notifyUsageDeleted(origin) {
settings.WebsiteUsagePrivateApi.fetchUsageTotal(host); this.fire('usage-deleted', {origin: origin});
}, },
});
/**
* @param {string} origin
*/
clearUsage(origin) {
settings.WebsiteUsagePrivateApi.clearUsage(origin);
},
/** @param {string} origin */
notifyUsageDeleted(origin) {
this.fire('usage-deleted', {origin: origin});
},
});
})();
cr.define('settings.WebsiteUsagePrivateApi', function() {
/** /**
* @type {Object} An instance of the polymer object defined above. * @type {Object} An instance of the polymer object defined above.
* All data will be set here. * All data will be set here.
......
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