Chromium Code Reviews| 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 22 matching lines...) Expand all Loading... | |
| 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.showModal(); | 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 this.browserProxy.isPatternValid(this.site_).then(function(isValid) { |
|
Finnur
2016/09/05 11:23:17
Adding the wildcard prefix during validate is wron
dschuyler
2016/09/06 18:20:29
Acknowledged.
| |
| 44 this.browserProxy.isPatternValid(pattern).then(function(isValid) { | |
| 45 this.$.add.disabled = !isValid; | 44 this.$.add.disabled = !isValid; |
| 46 }.bind(this)); | 45 }.bind(this)); |
| 47 }, | 46 }, |
| 48 | 47 |
| 49 /** @private */ | 48 /** @private */ |
| 50 onCancelTap_: function() { | 49 onCancelTap_: function() { |
| 51 this.$.dialog.cancel(); | 50 this.$.dialog.cancel(); |
| 52 }, | 51 }, |
| 53 | 52 |
| 54 /** | 53 /** |
| 55 * The tap handler for the Add [Site] button (adds the pattern and closes | 54 * The tap handler for the Add [Site] button (adds the pattern and closes |
| 56 * the dialog). | 55 * the dialog). |
| 57 * @private | 56 * @private |
| 58 */ | 57 */ |
| 59 onSubmit_: function() { | 58 onSubmit_: function() { |
| 60 if (this.$.add.disabled) | 59 if (this.$.add.disabled) |
| 61 return; // Can happen when Enter is pressed. | 60 return; // Can happen when Enter is pressed. |
| 62 var pattern = this.addPatternWildcard(this.site_); | 61 var pattern = this.addPatternWildcard(this.site_); |
| 63 this.setCategoryPermissionForOrigin( | 62 this.setCategoryPermissionForOrigin( |
| 64 pattern, pattern, this.category, this.allowException ? | 63 pattern, pattern, this.category, this.allowException ? |
| 65 settings.PermissionValues.ALLOW : settings.PermissionValues.BLOCK); | 64 settings.PermissionValues.ALLOW : settings.PermissionValues.BLOCK); |
| 66 this.$.dialog.close(); | 65 this.$.dialog.close(); |
| 67 }, | 66 }, |
| 68 }); | 67 }); |
| OLD | NEW |