Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 * Enumeration mapping all possible controlled-by values for exceptions to | 6 * Enumeration mapping all possible controlled-by values for exceptions to |
| 7 * icons. | 7 * icons. |
| 8 * @enum {string} | 8 * @enum {string} |
| 9 */ | 9 */ |
| 10 var iconControlledBy = { | 10 var iconControlledBy = { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 * @private | 55 * @private |
| 56 */ | 56 */ |
| 57 showEditExceptionDialog_: Boolean, | 57 showEditExceptionDialog_: Boolean, |
| 58 | 58 |
| 59 /** | 59 /** |
| 60 * Array of sites to display in the widget. | 60 * Array of sites to display in the widget. |
| 61 * @type {!Array<SiteException>} | 61 * @type {!Array<SiteException>} |
| 62 */ | 62 */ |
| 63 sites: { | 63 sites: { |
| 64 type: Array, | 64 type: Array, |
| 65 value: function() { return []; }, | 65 value: function() { |
| 66 return []; | |
| 67 }, | |
| 66 }, | 68 }, |
| 67 | 69 |
| 68 /** | 70 /** |
| 69 * Whether this list is for the All Sites category. | 71 * Whether this list is for the All Sites category. |
| 70 */ | 72 */ |
| 71 allSites: { | 73 allSites: { |
| 72 type: Boolean, | 74 type: Boolean, |
| 73 value: false, | 75 value: false, |
| 74 }, | 76 }, |
| 75 | 77 |
| 76 /** | 78 /** |
| 77 * The type of category this widget is displaying data for. Normally | 79 * The type of category this widget is displaying data for. Normally |
| 78 * either 'allow' or 'block', representing which sites are allowed or | 80 * either 'allow' or 'block', representing which sites are allowed or |
| 79 * blocked respectively. | 81 * blocked respectively. |
| 80 */ | 82 */ |
| 81 categorySubtype: { | 83 categorySubtype: { |
| 82 type: String, | 84 type: String, |
| 83 value: settings.INVALID_CATEGORY_SUBTYPE, | 85 value: settings.INVALID_CATEGORY_SUBTYPE, |
| 84 }, | 86 }, |
| 85 | 87 |
| 86 /** | 88 /** |
| 87 * Whether to show the Allow action in the action menu. | 89 * Whether to show the Allow action in the action menu. |
| 88 * @private | 90 * @private |
| 89 */ | 91 */ |
| 90 showAllowAction_: Boolean, | 92 showAllowAction_: Boolean, |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 121 type: Object, | 123 type: Object, |
| 122 values: { | 124 values: { |
| 123 ALLOW: 'Allow', | 125 ALLOW: 'Allow', |
| 124 BLOCK: 'Block', | 126 BLOCK: 'Block', |
| 125 RESET: 'Reset', | 127 RESET: 'Reset', |
| 126 SESSION_ONLY: 'SessionOnly', | 128 SESSION_ONLY: 'SessionOnly', |
| 127 } | 129 } |
| 128 }, | 130 }, |
| 129 }, | 131 }, |
| 130 | 132 |
| 131 observers: [ | 133 observers: ['configureWidget_(category, categorySubtype)'], |
| 132 'configureWidget_(category, categorySubtype)' | |
| 133 ], | |
| 134 | 134 |
| 135 ready: function() { | 135 ready: function() { |
| 136 this.addWebUIListener('contentSettingSitePermissionChanged', | 136 this.addWebUIListener('contentSettingSitePermissionChanged', |
| 137 this.siteWithinCategoryChanged_.bind(this)); | 137 this.siteWithinCategoryChanged_.bind(this)); |
| 138 this.addWebUIListener('onIncognitoStatusChanged', | 138 this.addWebUIListener('onIncognitoStatusChanged', |
| 139 this.onIncognitoStatusChanged_.bind(this)); | 139 this.onIncognitoStatusChanged_.bind(this)); |
| 140 }, | 140 }, |
| 141 | 141 |
| 142 /** | 142 /** |
| 143 * Called when a site changes permission. | 143 * Called when a site changes permission. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 hasSites_: function() { | 207 hasSites_: function() { |
| 208 return !!this.sites.length; | 208 return !!this.sites.length; |
| 209 }, | 209 }, |
| 210 | 210 |
| 211 /** | 211 /** |
| 212 * @param {string} source Where the setting came from. | 212 * @param {string} source Where the setting came from. |
| 213 * @param {boolean} readOnlyList Whether the site exception list is read-only. | 213 * @param {boolean} readOnlyList Whether the site exception list is read-only. |
| 214 * @return {boolean} | 214 * @return {boolean} |
| 215 * @private | 215 * @private |
| 216 */ | 216 */ |
| 217 isResetButtonHidden_: function(source, readOnlyList) { | |
| 218 return this.isExceptionControlled_(source) || this.allSites || | |
| 219 !readOnlyList; | |
| 220 }, | |
| 221 | |
| 222 /** | |
| 223 * @param {string} source Where the setting came from. | |
| 224 * @param {boolean} readOnlyList Whether the site exception list is read-only. | |
| 225 * @return {boolean} | |
| 226 * @private | |
| 227 */ | |
| 217 isActionMenuHidden_: function(source, readOnlyList) { | 228 isActionMenuHidden_: function(source, readOnlyList) { |
| 218 return this.isExceptionControlled_(source) || this.allSites || readOnlyList; | 229 return this.isExceptionControlled_(source) || this.allSites || readOnlyList; |
| 219 }, | 230 }, |
| 220 | 231 |
| 221 /** | 232 /** |
| 222 * A handler for the Add Site button. | 233 * A handler for the Add Site button. |
| 223 * @param {!Event} e | 234 * @param {!Event} e |
| 224 * @private | 235 * @private |
| 225 */ | 236 */ |
| 226 onAddSiteTap_: function(e) { | 237 onAddSiteTap_: function(e) { |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 487 | 498 |
| 488 if (item.incognito) | 499 if (item.incognito) |
| 489 return loadTimeData.getString('incognitoSite'); | 500 return loadTimeData.getString('incognitoSite'); |
| 490 return item.embeddingDisplayName; | 501 return item.embeddingDisplayName; |
| 491 }, | 502 }, |
| 492 | 503 |
| 493 /** | 504 /** |
| 494 * @param {!{model: !{item: !SiteException}}} e | 505 * @param {!{model: !{item: !SiteException}}} e |
| 495 * @private | 506 * @private |
| 496 */ | 507 */ |
| 508 onResetButtonTap_: function(e) { | |
| 509 // Trigger same logic as opening the menu and choosing the Reset item. | |
| 510 this.actionMenuSite_ = e.model.item; | |
| 511 this.onActionMenuActivate_(settings.PermissionValues.DEFAULT); | |
| 512 this.actionMenuSite_ = null; | |
|
dschuyler
2017/03/22 21:19:19
Hmm, it looks like onActionMenuActivate_ is an eve
tommycli
2017/03/22 21:51:29
Done. Based on your feedback, I refactored it a bi
| |
| 513 }, | |
| 514 | |
| 515 /** | |
| 516 * @param {!{model: !{item: !SiteException}}} e | |
| 517 * @private | |
| 518 */ | |
| 497 onShowActionMenuTap_: function(e) { | 519 onShowActionMenuTap_: function(e) { |
| 498 this.actionMenuSite_ = e.model.item; | 520 this.actionMenuSite_ = e.model.item; |
| 499 /** @type {!CrActionMenuElement} */ ( | 521 /** @type {!CrActionMenuElement} */ ( |
| 500 this.$$('dialog[is=cr-action-menu]')).showAt( | 522 this.$$('dialog[is=cr-action-menu]')).showAt( |
| 501 /** @type {!Element} */ ( | 523 /** @type {!Element} */ ( |
| 502 Polymer.dom(/** @type {!Event} */ (e)).localTarget)); | 524 Polymer.dom(/** @type {!Event} */ (e)).localTarget)); |
| 503 }, | 525 }, |
| 504 | 526 |
| 505 /** @private */ | 527 /** @private */ |
| 506 closeActionMenu_: function() { | 528 closeActionMenu_: function() { |
| 507 this.actionMenuSite_ = null; | 529 this.actionMenuSite_ = null; |
| 508 var actionMenu = /** @type {!CrActionMenuElement} */ ( | 530 var actionMenu = /** @type {!CrActionMenuElement} */ ( |
| 509 this.$$('dialog[is=cr-action-menu]')); | 531 this.$$('dialog[is=cr-action-menu]')); |
| 510 if (actionMenu.open) | 532 if (actionMenu.open) |
| 511 actionMenu.close(); | 533 actionMenu.close(); |
| 512 }, | 534 }, |
| 513 }); | 535 }); |
| OLD | NEW |