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({ |
| 11 is: 'add-site-dialog', | 11 is: 'add-site-dialog', |
| 12 | 12 |
| 13 behaviors: [SiteSettingsBehavior], | 13 behaviors: [SiteSettingsBehavior], |
| 14 | 14 |
| 15 properties: { | 15 properties: { |
| 16 /** | 16 /** |
| 17 * The site to add an exception for. | 17 * The site to add an exception for. |
| 18 * @private | 18 * @private |
| 19 */ | 19 */ |
| 20 site_: String, | 20 site_: String, |
| 21 | |
| 22 /** | |
| 23 * Whether this is an allow exception this dialog is adding. | |
| 24 */ | |
| 25 allowException: Boolean, | |
| 21 }, | 26 }, |
| 22 | 27 |
| 23 /** Opens the dialog. */ | 28 /** |
| 24 open: function() { | 29 * Opens the dialog. |
| 30 * @param {string} type Whether this was launched from an Allow list or a | |
| 31 * Block list. | |
| 32 */ | |
| 33 open: function(type) { | |
| 34 this.allowException = type == settings.PermissionValues.ALLOW; | |
| 25 this.$.dialog.open(); | 35 this.$.dialog.open(); |
| 26 }, | 36 }, |
| 27 | 37 |
| 28 /** | 38 /** |
| 29 * Validates that the pattern entered is valid. | 39 * Validates that the pattern entered is valid. |
| 30 * @private | 40 * @private |
| 31 */ | 41 */ |
| 32 validate_: function() { | 42 validate_: function() { |
| 33 var pattern = this.addPatternWildcard_(this.site_); | 43 var pattern = this.addPatternWildcard_(this.site_); |
| 34 this.browserProxy.isPatternValid(pattern).then(function(isValid) { | 44 this.browserProxy.isPatternValid(pattern).then(function(isValid) { |
| 35 this.$.add.disabled = !isValid; | 45 this.$.add.disabled = !isValid; |
| 36 }.bind(this)); | 46 }.bind(this)); |
| 37 }, | 47 }, |
| 38 | 48 |
| 39 /** | 49 /** |
| 50 * Handles Enter key presses for the paper-input. | |
| 51 */ | |
|
michaelpg
2016/06/09 17:38:00
@private
Finnur
2016/06/09 21:53:08
Done.
| |
| 52 onEnterPressed_: function(e) { | |
| 53 this.onAddTap_(); | |
| 54 }, | |
| 55 | |
| 56 /** | |
| 40 * The tap handler for the Add [Site] button (adds the pattern and closes | 57 * The tap handler for the Add [Site] button (adds the pattern and closes |
| 41 * the dialog). | 58 * the dialog). |
| 42 * @private | 59 * @private |
| 43 */ | 60 */ |
| 44 onAddTap_: function() { | 61 onAddTap_: function() { |
|
michaelpg
2016/06/09 17:38:00
maybe rename "onSubmit_" or something, and make bo
Finnur
2016/06/09 21:53:08
Renamed. But... both HTML events? I presume you me
michaelpg
2016/06/09 22:31:05
I meant to additionally change
on-keys-pressed=
| |
| 62 if (this.$.add.disabled) | |
| 63 return; // Can happen when Enter is pressed. | |
| 45 var pattern = this.addPatternWildcard_(this.site_); | 64 var pattern = this.addPatternWildcard_(this.site_); |
| 46 this.setCategoryPermissionForOrigin( | 65 this.setCategoryPermissionForOrigin( |
| 47 pattern, '', this.category, settings.PermissionValues.ALLOW); | 66 pattern, '', this.category, this.allowException ? |
| 67 settings.PermissionValues.ALLOW : settings.PermissionValues.BLOCK); | |
| 48 this.$.dialog.close(); | 68 this.$.dialog.close(); |
| 49 }, | 69 }, |
| 50 }); | 70 }); |
| OLD | NEW |