| 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 26 matching lines...) Expand all Loading... |
| 37 /** | 37 /** |
| 38 * The site that was selected by the user in the dropdown list. | 38 * The site that was selected by the user in the dropdown list. |
| 39 * @type {SiteException} | 39 * @type {SiteException} |
| 40 */ | 40 */ |
| 41 selectedSite: { | 41 selectedSite: { |
| 42 type: Object, | 42 type: Object, |
| 43 notify: true, | 43 notify: true, |
| 44 }, | 44 }, |
| 45 | 45 |
| 46 /** | 46 /** |
| 47 * The site serving as the model for the currenly open action menu. |
| 48 * @private {?SiteException} |
| 49 */ |
| 50 actionMenuSite_: Object, |
| 51 |
| 52 /** |
| 47 * Array of sites to display in the widget. | 53 * Array of sites to display in the widget. |
| 48 * @type {!Array<SiteException>} | 54 * @type {!Array<SiteException>} |
| 49 */ | 55 */ |
| 50 sites: { | 56 sites: { |
| 51 type: Array, | 57 type: Array, |
| 52 value: function() { return []; }, | 58 value: function() { return []; }, |
| 53 }, | 59 }, |
| 54 | 60 |
| 55 /** | 61 /** |
| 56 * Whether this list is for the All Sites category. | 62 * Whether this list is for the All Sites category. |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 this.showAllowAction_ = | 362 this.showAllowAction_ = |
| 357 this.categorySubtype != settings.PermissionValues.ALLOW; | 363 this.categorySubtype != settings.PermissionValues.ALLOW; |
| 358 this.showBlockAction_ = | 364 this.showBlockAction_ = |
| 359 this.categorySubtype != settings.PermissionValues.BLOCK; | 365 this.categorySubtype != settings.PermissionValues.BLOCK; |
| 360 this.showSessionOnlyAction_ = | 366 this.showSessionOnlyAction_ = |
| 361 this.categorySubtype != settings.PermissionValues.SESSION_ONLY && | 367 this.categorySubtype != settings.PermissionValues.SESSION_ONLY && |
| 362 this.category == settings.ContentSettingsTypes.COOKIES; | 368 this.category == settings.ContentSettingsTypes.COOKIES; |
| 363 }, | 369 }, |
| 364 | 370 |
| 365 /** | 371 /** |
| 366 * Whether to show the Session Only menu item for a given site. | 372 * @return {boolean} Whether to show the "Session Only" menu item for the |
| 367 * @param {SiteException} site The site in question. | 373 * currently active site. |
| 368 * @return {boolean} Whether to show the menu item. | 374 * @private |
| 369 */ | 375 */ |
| 370 showSessionOnlyActionForSite_: function(site) { | 376 showSessionOnlyActionForSite_: function() { |
| 371 // It makes no sense to show "clear on exit" for exceptions that only apply | 377 // It makes no sense to show "clear on exit" for exceptions that only apply |
| 372 // to incognito. It gives the impression that they might under some | 378 // to incognito. It gives the impression that they might under some |
| 373 // circumstances not be cleared on exit, which isn't true. | 379 // circumstances not be cleared on exit, which isn't true. |
| 374 if (site.incognito) | 380 if (!this.actionMenuSite_ || this.actionMenuSite_.incognito) |
| 375 return false; | 381 return false; |
| 376 | 382 |
| 377 return this.showSessionOnlyAction_; | 383 return this.showSessionOnlyAction_; |
| 378 }, | 384 }, |
| 379 | 385 |
| 380 /** | 386 /** |
| 381 * A handler for selecting a site (by clicking on the origin). | 387 * A handler for selecting a site (by clicking on the origin). |
| 388 * @param {!{model: !{item: !SiteException}}} event |
| 382 * @private | 389 * @private |
| 383 */ | 390 */ |
| 384 onOriginTap_: function(event) { | 391 onOriginTap_: function(event) { |
| 385 if (!this.enableSiteSettings_) | 392 if (!this.enableSiteSettings_) |
| 386 return; | 393 return; |
| 387 this.selectedSite = event.model.item; | 394 this.selectedSite = event.model.item; |
| 388 settings.navigateTo(settings.Route.SITE_SETTINGS_SITE_DETAILS, | 395 settings.navigateTo(settings.Route.SITE_SETTINGS_SITE_DETAILS, |
| 389 new URLSearchParams('site=' + this.selectedSite.origin)); | 396 new URLSearchParams('site=' + this.selectedSite.origin)); |
| 390 }, | 397 }, |
| 391 | 398 |
| 392 /** | 399 /** |
| 393 * A handler for activating one of the menu action items. | 400 * A handler for activating one of the menu action items. |
| 394 * @param {!{model: !{item: !{origin: string}}}} event | |
| 395 * @param {string} action The permission to set (Allow, Block, SessionOnly, | 401 * @param {string} action The permission to set (Allow, Block, SessionOnly, |
| 396 * etc). | 402 * etc). |
| 397 * @private | 403 * @private |
| 398 */ | 404 */ |
| 399 onActionMenuActivate_: function(event, action) { | 405 onActionMenuActivate_: function(action) { |
| 400 var origin = event.model.item.origin; | 406 var origin = this.actionMenuSite_.origin; |
| 401 var incognito = event.model.item.incognito; | 407 var incognito = this.actionMenuSite_.incognito; |
| 402 var embeddingOrigin = event.model.item.embeddingOrigin; | 408 var embeddingOrigin = this.actionMenuSite_.embeddingOrigin; |
| 403 if (action == settings.PermissionValues.DEFAULT) { | 409 if (action == settings.PermissionValues.DEFAULT) { |
| 404 this.browserProxy.resetCategoryPermissionForOrigin( | 410 this.browserProxy.resetCategoryPermissionForOrigin( |
| 405 origin, embeddingOrigin, this.category, incognito); | 411 origin, embeddingOrigin, this.category, incognito); |
| 406 } else { | 412 } else { |
| 407 this.browserProxy.setCategoryPermissionForOrigin( | 413 this.browserProxy.setCategoryPermissionForOrigin( |
| 408 origin, embeddingOrigin, this.category, action, incognito); | 414 origin, embeddingOrigin, this.category, action, incognito); |
| 409 } | 415 } |
| 410 }, | 416 }, |
| 411 | 417 |
| 412 /** @private */ | 418 /** @private */ |
| 413 onAllowTap_: function(event) { | 419 onAllowTap_: function() { |
| 414 this.onActionMenuActivate_(event, settings.PermissionValues.ALLOW); | 420 this.onActionMenuActivate_(settings.PermissionValues.ALLOW); |
| 421 this.closeActionMenu_(); |
| 415 }, | 422 }, |
| 416 | 423 |
| 417 /** @private */ | 424 /** @private */ |
| 418 onBlockTap_: function(event) { | 425 onBlockTap_: function() { |
| 419 this.onActionMenuActivate_(event, settings.PermissionValues.BLOCK); | 426 this.onActionMenuActivate_(settings.PermissionValues.BLOCK); |
| 427 this.closeActionMenu_(); |
| 420 }, | 428 }, |
| 421 | 429 |
| 422 /** @private */ | 430 /** @private */ |
| 423 onSessionOnlyTap_: function(event) { | 431 onSessionOnlyTap_: function() { |
| 424 this.onActionMenuActivate_(event, settings.PermissionValues.SESSION_ONLY); | 432 this.onActionMenuActivate_(settings.PermissionValues.SESSION_ONLY); |
| 433 this.closeActionMenu_(); |
| 425 }, | 434 }, |
| 426 | 435 |
| 427 /** @private */ | 436 /** @private */ |
| 428 onResetTap_: function(event) { | 437 onResetTap_: function() { |
| 429 this.onActionMenuActivate_(event, settings.PermissionValues.DEFAULT); | 438 this.onActionMenuActivate_(settings.PermissionValues.DEFAULT); |
| 439 this.closeActionMenu_(); |
| 430 }, | 440 }, |
| 431 | 441 |
| 432 /** | 442 /** |
| 433 * Returns the appropriate site description to display. This can, for example, | 443 * Returns the appropriate site description to display. This can, for example, |
| 434 * be blank, an 'embedded on <site>' or 'Current incognito session' (or a | 444 * be blank, an 'embedded on <site>' or 'Current incognito session' (or a |
| 435 * mix of the last two). | 445 * mix of the last two). |
| 436 * @param {SiteException} item The site exception entry. | 446 * @param {SiteException} item The site exception entry. |
| 437 * @return {string} The site description. | 447 * @return {string} The site description. |
| 438 */ | 448 */ |
| 439 computeSiteDescription_: function(item) { | 449 computeSiteDescription_: function(item) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 // The Block list is only shown when the category is set to Allow since it | 485 // The Block list is only shown when the category is set to Allow since it |
| 476 // is redundant to also list all the sites that are blocked. | 486 // is redundant to also list all the sites that are blocked. |
| 477 if (this.isAllowList_()) | 487 if (this.isAllowList_()) |
| 478 return true; | 488 return true; |
| 479 | 489 |
| 480 if (this.isSessionOnlyList_()) | 490 if (this.isSessionOnlyList_()) |
| 481 return siteList.length > 0; | 491 return siteList.length > 0; |
| 482 | 492 |
| 483 return toggleState; | 493 return toggleState; |
| 484 }, | 494 }, |
| 495 |
| 496 /** |
| 497 * @param {!{model: !{item: !SiteException}}} e |
| 498 * @private |
| 499 */ |
| 500 onShowActionMenuTap_: function(e) { |
| 501 this.actionMenuSite_ = e.model.item; |
| 502 /** @type {!SettingsActionMenuElement} */ ( |
| 503 this.$$('dialog[is=settings-action-menu]')).showAt( |
| 504 /** @type {!Element} */ ( |
| 505 Polymer.dom(/** @type {!Event} */ (e)).localTarget)); |
| 506 }, |
| 507 |
| 508 /** @private */ |
| 509 closeActionMenu_: function() { |
| 510 this.actionMenuSite_ = null; |
| 511 /** @type {!SettingsActionMenuElement} */ ( |
| 512 this.$$('dialog[is=settings-action-menu]')).close(); |
| 513 }, |
| 485 }); | 514 }); |
| OLD | NEW |