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 19 matching lines...) Expand all Loading... | |
| 30 * @private | 30 * @private |
| 31 */ | 31 */ |
| 32 validate_: function() { | 32 validate_: function() { |
| 33 var pattern = this.addPatternWildcard_(this.site_); | 33 var pattern = this.addPatternWildcard_(this.site_); |
| 34 this.browserProxy.isPatternValid(pattern).then(function(isValid) { | 34 this.browserProxy.isPatternValid(pattern).then(function(isValid) { |
| 35 this.$.add.disabled = !isValid; | 35 this.$.add.disabled = !isValid; |
| 36 }.bind(this)); | 36 }.bind(this)); |
| 37 }, | 37 }, |
| 38 | 38 |
| 39 /** | 39 /** |
| 40 * Adds the wildcard prefix to a pattern string. | |
| 41 * @param {string} pattern The pattern to add the wildcard to. | |
| 42 * @return {string} The resulting pattern. | |
| 43 * @private | |
| 44 */ | |
| 45 addPatternWildcard_: function(pattern) { | |
| 46 if (pattern.startsWith('http://')) | |
| 47 return pattern.replace('http://', 'http://[*.]'); | |
| 48 else if (pattern.startsWith('https://')) | |
| 49 return pattern.replace('https://', 'https://[*.]'); | |
| 50 else | |
| 51 return '[*.]' + pattern; | |
| 52 }, | |
|
Finnur
2016/05/31 21:59:55
Moved to the behavior.
| |
| 53 | |
| 54 /** | |
| 55 * The tap handler for the Add [Site] button (adds the pattern and closes | 40 * The tap handler for the Add [Site] button (adds the pattern and closes |
| 56 * the dialog). | 41 * the dialog). |
| 57 * @private | 42 * @private |
| 58 */ | 43 */ |
| 59 onAddTap_: function() { | 44 onAddTap_: function() { |
| 60 var pattern = this.addPatternWildcard_(this.site_); | 45 var pattern = this.addPatternWildcard_(this.site_); |
| 61 this.setCategoryPermissionForOrigin( | 46 this.setCategoryPermissionForOrigin( |
| 62 pattern, pattern, this.category, settings.PermissionValues.ALLOW); | 47 pattern, '', this.category, settings.PermissionValues.ALLOW); |
|
Finnur
2016/05/31 21:59:55
I found that the old settings UI just added entrie
| |
| 63 this.$.dialog.close(); | 48 this.$.dialog.close(); |
| 64 }, | 49 }, |
| 65 }); | 50 }); |
| OLD | NEW |