Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: chrome/browser/resources/settings/site_settings/add_site_dialog.js

Issue 2298283002: Site Settings Desktop: Support adding exceptions for incognito mode. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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();
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 /**
55 * The tap handler for the Add [Site] button (adds the pattern and closes 58 * The tap handler for the Add [Site] button (adds the pattern and closes
56 * the dialog). 59 * the dialog).
57 * @private 60 * @private
58 */ 61 */
59 onSubmit_: function() { 62 onSubmit_: function() {
60 if (this.$.add.disabled) 63 if (this.$.add.disabled)
61 return; // Can happen when Enter is pressed. 64 return; // Can happen when Enter is pressed.
62 var pattern = this.addPatternWildcard(this.site_); 65 var pattern = this.addPatternWildcard(this.site_);
63 this.setCategoryPermissionForOrigin( 66 this.browserProxy.setCategoryPermissionForOrigin(
64 pattern, pattern, this.category, this.allowException ? 67 pattern, pattern, this.category, this.allowException ?
65 settings.PermissionValues.ALLOW : settings.PermissionValues.BLOCK); 68 settings.PermissionValues.ALLOW : settings.PermissionValues.BLOCK,
69 this.$.incognito.checked);
66 this.$.dialog.close(); 70 this.$.dialog.close();
67 }, 71 },
72
73 /**
74 * A handler for when we get notified of the current profile creating or
75 * destroying their incognito counterpart.
76 * @param {boolean} incognitoEnabled Whether the current profile has an
77 * incognito profile.
78 * @private
79 */
dschuyler 2016/08/31 21:48:52 nit: This function could sort alphabetically above
Finnur 2016/09/01 11:10:15 Done.
80 onIncognitoStatusChanged_: function(incognitoEnabled) {
81 this.$.incognito.disabled = !incognitoEnabled;
82 if (!incognitoEnabled)
83 this.$.incognito.checked = false;
84 },
68 }); 85 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698