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 25 matching lines...) Expand all Loading... |
36 }, | 36 }, |
37 | 37 |
38 /** @override */ | 38 /** @override */ |
39 attached: function() { | 39 attached: function() { |
40 assert(this.category); | 40 assert(this.category); |
41 assert(this.contentSetting); | 41 assert(this.contentSetting); |
42 }, | 42 }, |
43 | 43 |
44 /** Open the dialog. */ | 44 /** Open the dialog. */ |
45 open: function() { | 45 open: function() { |
46 this.addWebUIListener('onIncognitoStatusChanged', function(hasIncognito) { | 46 this.addWebUIListener('onIncognitoStatusChanged', hasIncognito => { |
47 this.$.incognito.checked = false; | 47 this.$.incognito.checked = false; |
48 this.showIncognitoSessionOnly_ = hasIncognito && | 48 this.showIncognitoSessionOnly_ = hasIncognito && |
49 !loadTimeData.getBoolean('isGuest') && | 49 !loadTimeData.getBoolean('isGuest') && |
50 this.contentSetting != settings.ContentSetting.SESSION_ONLY; | 50 this.contentSetting != settings.ContentSetting.SESSION_ONLY; |
51 }.bind(this)); | 51 }); |
52 this.browserProxy.updateIncognitoStatus(); | 52 this.browserProxy.updateIncognitoStatus(); |
53 this.$.dialog.showModal(); | 53 this.$.dialog.showModal(); |
54 }, | 54 }, |
55 | 55 |
56 /** | 56 /** |
57 * Validates that the pattern entered is valid. | 57 * Validates that the pattern entered is valid. |
58 * @private | 58 * @private |
59 */ | 59 */ |
60 validate_: function() { | 60 validate_: function() { |
61 // If input is empty, disable the action button, but don't show the red | 61 // If input is empty, disable the action button, but don't show the red |
62 // invalid message. | 62 // invalid message. |
63 if (this.$.site.value.trim() == '') { | 63 if (this.$.site.value.trim() == '') { |
64 this.$.site.invalid = false; | 64 this.$.site.invalid = false; |
65 this.$.add.disabled = true; | 65 this.$.add.disabled = true; |
66 return; | 66 return; |
67 } | 67 } |
68 | 68 |
69 this.browserProxy.isPatternValid(this.site_).then(function(isValid) { | 69 this.browserProxy.isPatternValid(this.site_).then(isValid => { |
70 this.$.site.invalid = !isValid; | 70 this.$.site.invalid = !isValid; |
71 this.$.add.disabled = !isValid; | 71 this.$.add.disabled = !isValid; |
72 }.bind(this)); | 72 }); |
73 }, | 73 }, |
74 | 74 |
75 /** @private */ | 75 /** @private */ |
76 onCancelTap_: function() { | 76 onCancelTap_: function() { |
77 this.$.dialog.cancel(); | 77 this.$.dialog.cancel(); |
78 }, | 78 }, |
79 | 79 |
80 /** | 80 /** |
81 * The tap handler for the Add [Site] button (adds the pattern and closes | 81 * The tap handler for the Add [Site] button (adds the pattern and closes |
82 * the dialog). | 82 * the dialog). |
83 * @private | 83 * @private |
84 */ | 84 */ |
85 onSubmit_: function() { | 85 onSubmit_: function() { |
86 if (this.$.add.disabled) | 86 if (this.$.add.disabled) |
87 return; // Can happen when Enter is pressed. | 87 return; // Can happen when Enter is pressed. |
88 this.browserProxy.setCategoryPermissionForOrigin( | 88 this.browserProxy.setCategoryPermissionForOrigin( |
89 this.site_, this.site_, this.category, this.contentSetting, | 89 this.site_, this.site_, this.category, this.contentSetting, |
90 this.$.incognito.checked); | 90 this.$.incognito.checked); |
91 this.$.dialog.close(); | 91 this.$.dialog.close(); |
92 }, | 92 }, |
93 }); | 93 }); |
OLD | NEW |