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, WebUIListenerBehavior], | 13 behaviors: [SiteSettingsBehavior, WebUIListenerBehavior], |
| 14 | 14 |
| 15 properties: { | 15 properties: { |
| 16 /* What kind of setting, e.g. Location, Camera, Cookies, and so on. */ | |
| 17 category: String, | |
| 18 | |
| 19 /* Whether this is about an Allow, Block, SessionOnly, or other. */ | |
| 20 contentSetting: String, | |
|
dpapad
2016/11/08 00:12:32
As discussed, could this be typed as an enum inste
dschuyler
2016/11/08 00:40:50
Done.
| |
| 21 | |
| 16 /** | 22 /** |
| 17 * The site to add an exception for. | 23 * The site to add an exception for. |
| 18 * @private | 24 * @private |
| 19 */ | 25 */ |
| 20 site_: String, | 26 site_: String, |
| 27 }, | |
| 21 | 28 |
| 22 /** | 29 /** @override */ |
| 23 * Whether this is an allow exception this dialog is adding. | 30 attached: function() { |
| 24 */ | 31 assert(this.category); |
| 25 allowException: Boolean, | 32 assert(this.contentSetting); |
| 26 }, | 33 }, |
| 27 | 34 |
| 28 /** | 35 /** |
| 29 * Opens the dialog. | 36 * Opens the dialog. |
| 30 * @param {string} type Whether this was launched from an Allow list or a | 37 * @param {string} type Whether this was launched from an Allow list or a |
| 31 * Block list. | 38 * Block list. |
| 32 */ | 39 */ |
| 33 open: function(type) { | 40 open: function(type) { |
| 34 this.addWebUIListener('onIncognitoStatusChanged', | 41 this.addWebUIListener('onIncognitoStatusChanged', |
| 35 this.onIncognitoStatusChanged_.bind(this)); | 42 this.onIncognitoStatusChanged_.bind(this)); |
| 36 this.allowException = type == settings.PermissionValues.ALLOW; | |
| 37 this.browserProxy.updateIncognitoStatus(); | 43 this.browserProxy.updateIncognitoStatus(); |
| 38 this.$.dialog.showModal(); | 44 this.$.dialog.showModal(); |
| 39 }, | 45 }, |
| 40 | 46 |
| 41 /** | 47 /** |
| 42 * Validates that the pattern entered is valid. | 48 * Validates that the pattern entered is valid. |
| 43 * @private | 49 * @private |
| 44 */ | 50 */ |
| 45 validate_: function() { | 51 validate_: function() { |
| 46 this.browserProxy.isPatternValid(this.site_).then(function(isValid) { | 52 this.browserProxy.isPatternValid(this.site_).then(function(isValid) { |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 69 /** | 75 /** |
| 70 * The tap handler for the Add [Site] button (adds the pattern and closes | 76 * The tap handler for the Add [Site] button (adds the pattern and closes |
| 71 * the dialog). | 77 * the dialog). |
| 72 * @private | 78 * @private |
| 73 */ | 79 */ |
| 74 onSubmit_: function() { | 80 onSubmit_: function() { |
| 75 if (this.$.add.disabled) | 81 if (this.$.add.disabled) |
| 76 return; // Can happen when Enter is pressed. | 82 return; // Can happen when Enter is pressed. |
| 77 var pattern = this.addPatternWildcard(this.site_); | 83 var pattern = this.addPatternWildcard(this.site_); |
| 78 this.browserProxy.setCategoryPermissionForOrigin( | 84 this.browserProxy.setCategoryPermissionForOrigin( |
| 79 pattern, pattern, this.category, this.allowException ? | 85 pattern, pattern, this.category, this.contentSetting, |
| 80 settings.PermissionValues.ALLOW : settings.PermissionValues.BLOCK, | |
| 81 this.$.incognito.checked); | 86 this.$.incognito.checked); |
| 82 this.$.dialog.close(); | 87 this.$.dialog.close(); |
| 83 }, | 88 }, |
| 84 }); | 89 }); |
| OLD | NEW |