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, WebUIListenerBehavior], |
| 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 | 21 |
| 22 /** | 22 /** |
| 23 * Whether this is an allow exception this dialog is adding. | 23 * Whether this is an allow exception this dialog is adding. |
| 24 */ | 24 */ |
| 25 allowException: Boolean, | 25 allowException: Boolean, |
| 26 }, | 26 }, |
| 27 | 27 |
| 28 /** | 28 /** |
| 29 * Opens the dialog. | 29 * Opens the dialog. |
| 30 * @param {string} type Whether this was launched from an Allow list or a | 30 * @param {string} type Whether this was launched from an Allow list or a |
| 31 * Block list. | 31 * Block list. |
| 32 */ | 32 */ |
| 33 open: function(type) { | 33 open: function(type) { |
| 34 this.addWebUIListener('onIncognitoStatusChanged', | |
| 35 this.onIncognitoStatusChanged_.bind(this)); | |
| 34 this.allowException = type == settings.PermissionValues.ALLOW; | 36 this.allowException = type == settings.PermissionValues.ALLOW; |
| 37 this.browserProxy.updateIncognitoStatus(); | |
|
dschuyler
2016/09/01 23:13:49
Optional: does the UI going into the dialog
flicke
Finnur
2016/09/02 15:44:14
No, I haven't noticed that but I'll keep an eye on
| |
| 35 this.$.dialog.showModal(); | 38 this.$.dialog.showModal(); |
| 36 }, | 39 }, |
| 37 | 40 |
| 38 /** | 41 /** |
| 39 * Validates that the pattern entered is valid. | 42 * Validates that the pattern entered is valid. |
| 40 * @private | 43 * @private |
| 41 */ | 44 */ |
| 42 validate_: function() { | 45 validate_: function() { |
| 43 var pattern = this.addPatternWildcard(this.site_); | 46 var pattern = this.addPatternWildcard(this.site_); |
| 44 this.browserProxy.isPatternValid(pattern).then(function(isValid) { | 47 this.browserProxy.isPatternValid(pattern).then(function(isValid) { |
| 45 this.$.add.disabled = !isValid; | 48 this.$.add.disabled = !isValid; |
| 46 }.bind(this)); | 49 }.bind(this)); |
| 47 }, | 50 }, |
| 48 | 51 |
| 49 /** @private */ | 52 /** @private */ |
| 50 onCancelTap_: function() { | 53 onCancelTap_: function() { |
| 51 this.$.dialog.cancel(); | 54 this.$.dialog.cancel(); |
| 52 }, | 55 }, |
| 53 | 56 |
| 54 /** | 57 /** |
| 58 * A handler for when we get notified of the current profile creating or | |
| 59 * destroying their incognito counterpart. | |
| 60 * @param {boolean} incognitoEnabled Whether the current profile has an | |
| 61 * incognito profile. | |
| 62 * @private | |
| 63 */ | |
| 64 onIncognitoStatusChanged_: function(incognitoEnabled) { | |
| 65 this.$.incognito.disabled = !incognitoEnabled; | |
| 66 if (!incognitoEnabled) | |
| 67 this.$.incognito.checked = false; | |
| 68 }, | |
| 69 | |
| 70 /** | |
| 55 * The tap handler for the Add [Site] button (adds the pattern and closes | 71 * The tap handler for the Add [Site] button (adds the pattern and closes |
| 56 * the dialog). | 72 * the dialog). |
| 57 * @private | 73 * @private |
| 58 */ | 74 */ |
| 59 onSubmit_: function() { | 75 onSubmit_: function() { |
| 60 if (this.$.add.disabled) | 76 if (this.$.add.disabled) |
| 61 return; // Can happen when Enter is pressed. | 77 return; // Can happen when Enter is pressed. |
| 62 var pattern = this.addPatternWildcard(this.site_); | 78 var pattern = this.addPatternWildcard(this.site_); |
| 63 this.setCategoryPermissionForOrigin( | 79 this.browserProxy.setCategoryPermissionForOrigin( |
| 64 pattern, pattern, this.category, this.allowException ? | 80 pattern, pattern, this.category, this.allowException ? |
| 65 settings.PermissionValues.ALLOW : settings.PermissionValues.BLOCK); | 81 settings.PermissionValues.ALLOW : settings.PermissionValues.BLOCK, |
| 82 this.$.incognito.checked); | |
| 66 this.$.dialog.close(); | 83 this.$.dialog.close(); |
| 67 }, | 84 }, |
| 68 }); | 85 }); |
| OLD | NEW |