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() {
*/
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.
* TODO(crbug.com/776538): Update the strings to say that some items are only
* changed and not removed.
*
* Example:
*
* <!-- Items list initially shows |CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW|
* items. If there are more than |CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW|
* items on the list, then a "show more" link is shown; tapping on it
* expands the list. -->
* <items-to-remove-list
* title="Files and programs:"
* items-to-show="[[filesToShow]]">
* </items-to-remove-list>
*/
Polymer({
is: 'items-to-remove-list',
properties: {
title: {
type: String,
value: '',
/**
* @fileoverview
* 'items-to-remove-list' represents a list of items to
* 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
* changed and not removed.
*
* Example:
*
* <!-- Items list initially shows |CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW|
* items. If there are more than
* |CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW| items on the list, then a "show
* more" link is shown; tapping on it expands the list. -->
* <items-to-remove-list
* title="Files and programs:"
* items-to-show="[[filesToShow]]">
* </items-to-remove-list>
*/
Polymer({
is: 'items-to-remove-list',
properties: {
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>} */
itemsToShow: {
type: Array,
observer: 'updateVisibleState_',
/** @private */
expandList_() {
this.expanded_ = true;
this.moreItemsLinkText_ = '';
},
/**
* If true, all items from |itemsToShow| will be presented on the card,
* and the "show more" link will be omitted.
* 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
*/
expanded_: {
type: Boolean,
value: false,
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;
});
},
/**
* 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>}
* Returns the class for the <li> elements that correspond to the items
* hidden in the default view.
* @param {boolean} expanded
*/
remainingItems_: Array,
remainingItemsClass_(expanded) {
return expanded ? 'visible-item' : 'hidden-item';
},
/**
* The text for the "show more" link available if not all files are visible
* in the card.
* @param {settings.ChromeCleanupRemovalListItem} item
* @return {boolean} Whether a highlight suffix exists.
* @private
*/
moreItemsLinkText_: {
type: String,
value: '',
hasHighlightSuffix_(item) {
return item.highlightSuffix !== null;
},
},
/** @private */
expandList_() {
this.expanded_ = true;
this.moreItemsLinkText_ = '';
},
});
/**
* 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;
},
return {ChromeCleanupRemovalListItem, CHROME_CLEANUP_DEFAULT_ITEMS_TO_SHOW};
});
......@@ -35,6 +35,5 @@
<cr-button on-click="onDisableTap_">$i18n{disable}</cr-button>
</template>
</template>
<script src="extension_controlled_indicator.js"></script>
</dom-module>
<script src="extension_controlled_indicator.js"></script>
......@@ -16,192 +16,193 @@ cr.define('settings', function() {
*/
let PINFieldSubmitFunc;
return {
PINFieldSubmitFunc: PINFieldSubmitFunc,
};
});
Polymer({
is: 'settings-security-keys-pin-field',
Polymer({
is: 'settings-security-keys-pin-field',
behaviors: [
I18nBehavior,
],
behaviors: [
I18nBehavior,
],
properties: {
/* @private */
error_: {
type: String,
observer: 'errorChanged_',
},
properties: {
/* @private */
error_: {
type: String,
observer: 'errorChanged_',
},
/* @private */
value_: String,
/* @private */
value_: String,
/* @private */
inputVisible_: {
type: Boolean,
value: false,
/* @private */
inputVisible_: {
type: Boolean,
value: false,
},
},
},
/** @override */
attached() {
Polymer.RenderStatus.afterNextRender(this, function() {
Polymer.IronA11yAnnouncer.requestAvailability();
});
},
/** @override */
attached() {
Polymer.RenderStatus.afterNextRender(this, function() {
Polymer.IronA11yAnnouncer.requestAvailability();
});
},
/** Focuses the PIN input field. */
focus() {
this.$.pin.focus();
},
/** Focuses the PIN input field. */
focus() {
this.$.pin.focus();
},
/**
* Validates the PIN and sets the validation error if it is not valid.
* @return {boolean} True iff the PIN is valid.
* @private
*/
validate_() {
const error = this.isValidPIN_(this.value_);
if (error != '') {
this.error_ = error;
return false;
}
return true;
},
/**
* Validates the PIN and sets the validation error if it is not valid.
* @return {boolean} True iff the PIN is valid.
* @private
*/
validate_() {
const error = this.isValidPIN_(this.value_);
if (error != '') {
this.error_ = error;
return false;
}
return true;
},
/**
* Attempts submission of the PIN by invoking |submitFunc|. Updates the UI to
* show an error if the PIN was incorrect.
* @param {!settings.PINFieldSubmitFunc} submitFunc
* @return {!Promise} resolves if the PIN was correct, else rejects
*/
trySubmit(submitFunc) {
if (!this.validate_()) {
this.focus();
return Promise.reject();
}
return submitFunc(this.value_).then(retries => {
if (retries != null) {
this.showIncorrectPINError_(retries);
/**
* Attempts submission of the PIN by invoking |submitFunc|. Updates the UI
* to show an error if the PIN was incorrect.
* @param {!settings.PINFieldSubmitFunc} submitFunc
* @return {!Promise} resolves if the PIN was correct, else rejects
*/
trySubmit(submitFunc) {
if (!this.validate_()) {
this.focus();
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.
* @param {number} retries The number of retries remaining.
* @private
*/
showIncorrectPINError_(retries) {
// Warn the user if the number of retries is getting low.
let error;
if (1 < retries && retries <= 3) {
error =
this.i18n('securityKeysPINIncorrectRetriesPl', retries.toString());
} else if (retries == 1) {
error = this.i18n('securityKeysPINIncorrectRetriesSin');
} else {
error = this.i18n('securityKeysPINIncorrect');
}
this.error_ = error;
},
/** @private */
onPINInput_() {
// Typing in the PIN box after an error makes the error message
// disappear.
this.error_ = '';
},
/**
* Sets the validation error to indicate the PIN was incorrect.
* @param {number} retries The number of retries remaining.
* @private
*/
showIncorrectPINError_(retries) {
// Warn the user if the number of retries is getting low.
let error;
if (1 < retries && retries <= 3) {
error =
this.i18n('securityKeysPINIncorrectRetriesPl', retries.toString());
} else if (retries == 1) {
error = this.i18n('securityKeysPINIncorrectRetriesSin');
} else {
error = this.i18n('securityKeysPINIncorrect');
}
this.error_ = error;
},
/**
* Polymer helper function to detect when an error string is empty.
* @param {string} s Arbitrary string
* @return {boolean} True iff |s| is non-empty.
* @private
*/
isNonEmpty_(s) {
return s != '';
},
/** @private */
onPINInput_() {
// Typing in the PIN box after an error makes the error message
// disappear.
this.error_ = '';
},
/**
* @return {string} The PIN-input element type.
* @private
*/
inputType_() {
return this.inputVisible_ ? 'text' : 'password';
},
/**
* Polymer helper function to detect when an error string is empty.
* @param {string} s Arbitrary string
* @return {boolean} True iff |s| is non-empty.
* @private
*/
isNonEmpty_(s) {
return s != '';
},
/**
* @return {string} The class (and thus icon) to be displayed.
* @private
*/
showButtonClass_() {
return 'icon-visibility' + (this.inputVisible_ ? '-off' : '');
},
/**
* @return {string} The PIN-input element type.
* @private
*/
inputType_() {
return this.inputVisible_ ? 'text' : 'password';
},
/**
* @return {string} The tooltip for the icon.
* @private
*/
showButtonTitle_() {
return this.i18n(
this.inputVisible_ ? 'securityKeysHidePINs' : 'securityKeysShowPINs');
},
/**
* @return {string} The class (and thus icon) to be displayed.
* @private
*/
showButtonClass_() {
return 'icon-visibility' + (this.inputVisible_ ? '-off' : '');
},
/**
* onClick handler for the show/hide icon.
* @private
*/
showButtonClick_() {
this.inputVisible_ = !this.inputVisible_;
},
/**
* @return {string} The tooltip for the icon.
* @private
*/
showButtonTitle_() {
return this.i18n(
this.inputVisible_ ? 'securityKeysHidePINs' : 'securityKeysShowPINs');
},
/**
* @param {string} pin A candidate PIN.
* @return {string} An error string or else '' to indicate validity.
* @private
*/
isValidPIN_(pin) {
// 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) {
return this.i18n('securityKeysPINTooShort');
}
if (utf8Encoded.length > 63 ||
// If the PIN somehow has a NUL at the end then it's invalid, but this
// is so obscure that we don't try to message it. Rather we just say
// that it's too long because trimming the final character is the best
// response by the user.
utf8Encoded[utf8Encoded.length - 1] == 0) {
return this.i18n('securityKeysPINTooLong');
}
// 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.
// (For example, '\u{1f6b4}'.length == 2, but it's a single code-point.)
// Therefore, iterate over the string (which does yield codepoints) and
// check that four or more were seen.
let length = 0;
for (const codepoint of pin) {
length++;
}
if (length < 4) {
return this.i18n('securityKeysPINTooShort');
}
return '';
},
/** @private */
errorChanged_() {
// Make screen readers announce changes to the PIN validation error
// label.
this.fire('iron-announce', {text: this.error_});
},
/**
* onClick handler for the show/hide icon.
* @private
*/
showButtonClick_() {
this.inputVisible_ = !this.inputVisible_;
},
/**
* @param {string} pin A candidate PIN.
* @return {string} An error string or else '' to indicate validity.
* @private
*/
isValidPIN_(pin) {
// 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) {
return this.i18n('securityKeysPINTooShort');
}
if (utf8Encoded.length > 63 ||
// If the PIN somehow has a NUL at the end then it's invalid, but this
// is so obscure that we don't try to message it. Rather we just say
// that it's too long because trimming the final character is the best
// response by the user.
utf8Encoded[utf8Encoded.length - 1] == 0) {
return this.i18n('securityKeysPINTooLong');
}
// 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.
// (For example, '\u{1f6b4}'.length == 2, but it's a single code-point.)
// Therefore, iterate over the string (which does yield codepoints) and
// check that four or more were seen.
let length = 0;
for (const codepoint of pin) {
length++;
}
if (length < 4) {
return this.i18n('securityKeysPINTooShort');
}
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() {
};
return {
ResetDialogPage: ResetDialogPage,
};
});
(function() {
'use strict';
Polymer({
is: 'settings-security-keys-reset-dialog',
behaviors: [I18nBehavior],
properties: {
/**
* 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({
is: 'settings-security-keys-reset-dialog',
/** @private */
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
*/
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.
* @private
@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
*/
complete_: {
type: Boolean,
value: false,
resetFailed_(code) {
if (code === null) {
return '';
}
return this.i18n('securityKeysResetError', code.toString());
},
/**
* The id of an element on the page that is currently shown.
* @private {!settings.ResetDialogPage}
* @param {boolean} complete Whether the dialog process is complete.
* @return {string} The label of the dialog button. Used automatically by
* Polymer.
* @private
*/
shown_: {
type: String,
value: ResetDialogPage.INITIAL,
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
*/
title_: String,
},
/** @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_();
});
}
});
},
/** @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';
},
maybeActionButton_(complete) {
return complete ? 'action-button' : 'cancel-button';
},
});
return {
ResetDialogPage: ResetDialogPage,
};
});
})();
......@@ -2,55 +2,51 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(function() {
'use strict';
cr.define('settings.WebsiteUsagePrivateApi', function() {
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({
is: 'website-usage-private-api',
/** @override */
attached() {
settings.WebsiteUsagePrivateApi.websiteUsagePolymerInstance = this;
},
properties: {
/**
* The amount of data used by the given website.
*/
websiteDataUsage: {
type: String,
notify: true,
/** @param {string} host */
fetchUsageTotal(host) {
settings.WebsiteUsagePrivateApi.fetchUsageTotal(host);
},
/**
* The number of cookies used by the given website.
* @param {string} origin
*/
websiteCookieUsage: {
type: String,
notify: true,
clearUsage(origin) {
settings.WebsiteUsagePrivateApi.clearUsage(origin);
},
},
/** @override */
attached() {
settings.WebsiteUsagePrivateApi.websiteUsagePolymerInstance = this;
},
/** @param {string} host */
fetchUsageTotal(host) {
settings.WebsiteUsagePrivateApi.fetchUsageTotal(host);
},
/**
* @param {string} origin
*/
clearUsage(origin) {
settings.WebsiteUsagePrivateApi.clearUsage(origin);
},
/** @param {string} origin */
notifyUsageDeleted(origin) {
this.fire('usage-deleted', {origin: 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.
* 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