| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview | 6 * @fileoverview |
| 7 * 'add-site-dialog' provides a dialog to add exceptions for a given Content | 7 * 'add-site-dialog' provides a dialog to add exceptions for a given Content |
| 8 * Settings category. | 8 * Settings category. |
| 9 */ | 9 */ |
| 10 Polymer({ | 10 Polymer({ |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 allowException: Boolean, | 25 allowException: Boolean, |
| 26 }, | 26 }, |
| 27 | 27 |
| 28 /** | 28 /** |
| 29 * Opens the dialog. | 29 * Opens the dialog. |
| 30 * @param {string} type Whether this was launched from an Allow list or a | 30 * @param {string} type Whether this was launched from an Allow list or a |
| 31 * Block list. | 31 * Block list. |
| 32 */ | 32 */ |
| 33 open: function(type) { | 33 open: function(type) { |
| 34 this.allowException = type == settings.PermissionValues.ALLOW; | 34 this.allowException = type == settings.PermissionValues.ALLOW; |
| 35 this.$.dialog.open(); | 35 this.$.dialog.showModal(); |
| 36 }, | 36 }, |
| 37 | 37 |
| 38 /** | 38 /** |
| 39 * Validates that the pattern entered is valid. | 39 * Validates that the pattern entered is valid. |
| 40 * @private | 40 * @private |
| 41 */ | 41 */ |
| 42 validate_: function() { | 42 validate_: function() { |
| 43 var pattern = this.addPatternWildcard_(this.site_); | 43 var pattern = this.addPatternWildcard_(this.site_); |
| 44 this.browserProxy.isPatternValid(pattern).then(function(isValid) { | 44 this.browserProxy.isPatternValid(pattern).then(function(isValid) { |
| 45 this.$.add.disabled = !isValid; | 45 this.$.add.disabled = !isValid; |
| 46 }.bind(this)); | 46 }.bind(this)); |
| 47 }, | 47 }, |
| 48 | 48 |
| 49 /** | 49 /** |
| 50 * The tap handler for the Add [Site] button (adds the pattern and closes | 50 * The tap handler for the Add [Site] button (adds the pattern and closes |
| 51 * the dialog). | 51 * the dialog). |
| 52 * @private | 52 * @private |
| 53 */ | 53 */ |
| 54 onSubmit_: function() { | 54 onSubmit_: function() { |
| 55 if (this.$.add.disabled) | 55 if (this.$.add.disabled) |
| 56 return; // Can happen when Enter is pressed. | 56 return; // Can happen when Enter is pressed. |
| 57 var pattern = this.addPatternWildcard_(this.site_); | 57 var pattern = this.addPatternWildcard_(this.site_); |
| 58 this.setCategoryPermissionForOrigin( | 58 this.setCategoryPermissionForOrigin( |
| 59 pattern, '', this.category, this.allowException ? | 59 pattern, '', this.category, this.allowException ? |
| 60 settings.PermissionValues.ALLOW : settings.PermissionValues.BLOCK); | 60 settings.PermissionValues.ALLOW : settings.PermissionValues.BLOCK); |
| 61 this.$.dialog.close(); | 61 this.$.dialog.close(); |
| 62 }, | 62 }, |
| 63 }); | 63 }); |
| OLD | NEW |