| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 this.onIncognitoStatusChanged_.bind(this)); | 48 this.onIncognitoStatusChanged_.bind(this)); |
| 49 this.browserProxy.updateIncognitoStatus(); | 49 this.browserProxy.updateIncognitoStatus(); |
| 50 this.$.dialog.showModal(); | 50 this.$.dialog.showModal(); |
| 51 }, | 51 }, |
| 52 | 52 |
| 53 /** | 53 /** |
| 54 * Validates that the pattern entered is valid. | 54 * Validates that the pattern entered is valid. |
| 55 * @private | 55 * @private |
| 56 */ | 56 */ |
| 57 validate_: function() { | 57 validate_: function() { |
| 58 // If input is empty, disable the action button, but don't show the red |
| 59 // invalid message. |
| 60 if (this.$.site.value.trim() == '') { |
| 61 this.$.site.invalid = false; |
| 62 this.$.add.disabled = true; |
| 63 return; |
| 64 } |
| 65 |
| 58 this.browserProxy.isPatternValid(this.site_).then(function(isValid) { | 66 this.browserProxy.isPatternValid(this.site_).then(function(isValid) { |
| 67 this.$.site.invalid = !isValid; |
| 59 this.$.add.disabled = !isValid; | 68 this.$.add.disabled = !isValid; |
| 60 }.bind(this)); | 69 }.bind(this)); |
| 61 }, | 70 }, |
| 62 | 71 |
| 63 /** @private */ | 72 /** @private */ |
| 64 onCancelTap_: function() { | 73 onCancelTap_: function() { |
| 65 this.$.dialog.cancel(); | 74 this.$.dialog.cancel(); |
| 66 }, | 75 }, |
| 67 | 76 |
| 68 /** | 77 /** |
| (...skipping 16 matching lines...) Expand all Loading... |
| 85 */ | 94 */ |
| 86 onSubmit_: function() { | 95 onSubmit_: function() { |
| 87 if (this.$.add.disabled) | 96 if (this.$.add.disabled) |
| 88 return; // Can happen when Enter is pressed. | 97 return; // Can happen when Enter is pressed. |
| 89 this.browserProxy.setCategoryPermissionForOrigin( | 98 this.browserProxy.setCategoryPermissionForOrigin( |
| 90 this.site_, this.site_, this.category, this.contentSetting, | 99 this.site_, this.site_, this.category, this.contentSetting, |
| 91 this.$.incognito.checked); | 100 this.$.incognito.checked); |
| 92 this.$.dialog.close(); | 101 this.$.dialog.close(); |
| 93 }, | 102 }, |
| 94 }); | 103 }); |
| OLD | NEW |