| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * @fileoverview 'settings-edit-exception-dialog' is a component for editing a |
| 7 * site exception entry. |
| 8 */ |
| 9 Polymer({ |
| 10 is: 'settings-edit-exception-dialog', |
| 11 |
| 12 properties: { |
| 13 /** |
| 14 * @type {!SiteException} |
| 15 */ |
| 16 model: Object, |
| 17 |
| 18 /** @private */ |
| 19 origin_: String, |
| 20 }, |
| 21 |
| 22 /** @private {!settings.SiteSettingsPrefsBrowserProxy} */ |
| 23 browserProxy_: null, |
| 24 |
| 25 /** @override */ |
| 26 attached: function() { |
| 27 this.browserProxy_ = |
| 28 settings.SiteSettingsPrefsBrowserProxyImpl.getInstance(); |
| 29 this.origin_ = this.model.origin; |
| 30 |
| 31 this.$.dialog.showModal(); |
| 32 }, |
| 33 |
| 34 /** @private */ |
| 35 onCancelTap_: function() { |
| 36 this.$.dialog.close(); |
| 37 }, |
| 38 |
| 39 /** @private */ |
| 40 onActionButtonTap_: function() { |
| 41 if (this.model.origin != this.origin_) { |
| 42 // TODO(dpapad): Only COOKIES category can be edited currently, |
| 43 // crbug.com/695578. |
| 44 var category = settings.ContentSettingsTypes.COOKIES; |
| 45 |
| 46 // The way to "edit" an exception is to remove it and and a new one. |
| 47 this.browserProxy_.resetCategoryPermissionForOrigin( |
| 48 this.model.origin, |
| 49 this.model.embeddingOrigin, |
| 50 category, |
| 51 this.model.incognito); |
| 52 |
| 53 this.browserProxy_.setCategoryPermissionForOrigin( |
| 54 this.origin_, |
| 55 this.origin_, |
| 56 category, |
| 57 this.model.setting, |
| 58 this.model.incognito); |
| 59 } |
| 60 |
| 61 this.$.dialog.close(); |
| 62 }, |
| 63 |
| 64 /** |
| 65 * @param {!KeyboardEvent} e |
| 66 * @private |
| 67 */ |
| 68 onKeypress_: function(e) { |
| 69 if (e.key == 'Enter' && !this.$.actionButton.disabled) |
| 70 this.onActionButtonTap_(); |
| 71 }, |
| 72 |
| 73 /** @private */ |
| 74 validate_: function() { |
| 75 this.browserProxy_.isPatternValid(this.origin_).then(function(isValid) { |
| 76 this.$.actionButton.disabled = !isValid; |
| 77 }.bind(this)); |
| 78 }, |
| 79 }); |
| OLD | NEW |