Chromium Code Reviews| Index: chrome/browser/resources/settings/site_settings/edit_exception_dialog.js |
| diff --git a/chrome/browser/resources/settings/site_settings/edit_exception_dialog.js b/chrome/browser/resources/settings/site_settings/edit_exception_dialog.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8262aebab172dc9e231ae5625175135ecfe86083 |
| --- /dev/null |
| +++ b/chrome/browser/resources/settings/site_settings/edit_exception_dialog.js |
| @@ -0,0 +1,78 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
|
dschuyler
2017/02/23 22:24:50
nit: copyright year.
dpapad
2017/02/24 00:17:19
Done.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +/** |
| + * @fileoverview 'settings-edit-exception-dialog' is a component for editing a |
| + * site exception entry. |
| + */ |
| +Polymer({ |
| + is: 'settings-edit-exception-dialog', |
| + |
| + properties: { |
| + /** |
| + * @type {!SiteException} |
| + */ |
| + model: Object, |
| + |
| + /** @private */ |
| + origin_: String, |
| + }, |
| + |
| + /** @private {!settings.SiteSettingsPrefsBrowserProxy} */ |
| + browserProxy_: null, |
| + |
| + /** @override */ |
| + attached: function() { |
| + this.browserProxy_ = |
| + settings.SiteSettingsPrefsBrowserProxyImpl.getInstance(); |
| + this.origin_ = this.model.origin; |
| + |
| + this.$.dialog.showModal(); |
| + }, |
| + |
| + /** @private */ |
| + onCancelTap_: function() { |
| + this.$.dialog.close(); |
| + }, |
| + |
| + /** @private */ |
| + onActionButtonTap_: function() { |
| + if (this.model.origin != this.origin_) { |
| + // TODO(dpapad): Only COOKIES category can be edited currently, |
| + // crbug.com/695578. |
| + var category = settings.ContentSettingsTypes.COOKIES; |
| + |
|
dschuyler
2017/02/23 22:24:50
nit: Maybe a comment about why the reset* before t
dpapad
2017/02/24 00:17:19
Done.
|
| + this.browserProxy_.resetCategoryPermissionForOrigin( |
| + this.model.origin, |
| + this.model.embeddingOrigin, |
| + category, |
| + this.model.incognito); |
| + |
| + this.browserProxy_.setCategoryPermissionForOrigin( |
| + this.origin_, |
| + this.origin_, |
| + category, |
| + this.model.setting, |
| + this.model.incognito); |
| + } |
| + |
| + this.$.dialog.close(); |
| + }, |
| + |
| + /** |
| + * @param {!KeyboardEvent} e |
| + * @private |
| + */ |
| + onKeypress_: function(e) { |
| + if (e.key == 'Enter' && !this.$.actionButton.disabled) |
| + this.onActionButtonTap_(); |
| + }, |
| + |
| + /** @private */ |
| + validate_: function() { |
| + this.browserProxy_.isPatternValid(this.origin_).then(function(isValid) { |
| + this.$.actionButton.disabled = !isValid; |
| + }.bind(this)); |
| + }, |
| +}); |