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 * @fileoverview | 6 * @fileoverview |
7 * 'site-list' shows a list of Allowed and Blocked sites for a given | 7 * 'site-list' shows a list of Allowed and Blocked sites for a given |
8 * category. | 8 * category. |
9 */ | 9 */ |
10 Polymer({ | 10 Polymer({ |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 /** | 103 /** |
104 * The element to return focus to, when the currently active dialog is closed. | 104 * The element to return focus to, when the currently active dialog is closed. |
105 * @private {?HTMLElement} | 105 * @private {?HTMLElement} |
106 */ | 106 */ |
107 activeDialogAnchor_: null, | 107 activeDialogAnchor_: null, |
108 | 108 |
109 observers: ['configureWidget_(category, categorySubtype)'], | 109 observers: ['configureWidget_(category, categorySubtype)'], |
110 | 110 |
111 /** @override */ | 111 /** @override */ |
112 ready: function() { | 112 ready: function() { |
113 this.addWebUIListener('contentSettingSitePermissionChanged', | 113 this.addWebUIListener( |
| 114 'contentSettingSitePermissionChanged', |
114 this.siteWithinCategoryChanged_.bind(this)); | 115 this.siteWithinCategoryChanged_.bind(this)); |
115 this.addWebUIListener('onIncognitoStatusChanged', | 116 this.addWebUIListener( |
116 this.onIncognitoStatusChanged_.bind(this)); | 117 'onIncognitoStatusChanged', this.onIncognitoStatusChanged_.bind(this)); |
117 }, | 118 }, |
118 | 119 |
119 /** | 120 /** |
120 * Called when a site changes permission. | 121 * Called when a site changes permission. |
121 * @param {string} category The category of the site that changed. | 122 * @param {string} category The category of the site that changed. |
122 * @param {string} site The site that changed. | 123 * @param {string} site The site that changed. |
123 * @private | 124 * @private |
124 */ | 125 */ |
125 siteWithinCategoryChanged_: function(category, site) { | 126 siteWithinCategoryChanged_: function(category, site) { |
126 if (category == this.category) | 127 if (category == this.category) |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 }, | 256 }, |
256 | 257 |
257 /** | 258 /** |
258 * Converts a list of exceptions received from the C++ handler to | 259 * Converts a list of exceptions received from the C++ handler to |
259 * full SiteException objects. | 260 * full SiteException objects. |
260 * @param {!Array<RawSiteException>} sites A list of sites to convert. | 261 * @param {!Array<RawSiteException>} sites A list of sites to convert. |
261 * @return {!Array<SiteException>} A list of full SiteExceptions. | 262 * @return {!Array<SiteException>} A list of full SiteExceptions. |
262 * @private | 263 * @private |
263 */ | 264 */ |
264 toSiteArray_: function(sites) { | 265 toSiteArray_: function(sites) { |
265 var results = /** @type {!Array<SiteException>} */([]); | 266 var results = /** @type {!Array<SiteException>} */ ([]); |
266 var lastOrigin = ''; | 267 var lastOrigin = ''; |
267 var lastEmbeddingOrigin = ''; | 268 var lastEmbeddingOrigin = ''; |
268 for (var i = 0; i < sites.length; ++i) { | 269 for (var i = 0; i < sites.length; ++i) { |
269 /** @type {!SiteException} */ | 270 /** @type {!SiteException} */ |
270 var siteException = this.expandSiteException(sites[i]); | 271 var siteException = this.expandSiteException(sites[i]); |
271 | 272 |
272 results.push(siteException); | 273 results.push(siteException); |
273 lastOrigin = siteException.origin; | 274 lastOrigin = siteException.origin; |
274 lastEmbeddingOrigin = siteException.embeddingOrigin; | 275 lastEmbeddingOrigin = siteException.embeddingOrigin; |
275 } | 276 } |
(...skipping 30 matching lines...) Expand all Loading... |
306 }, | 307 }, |
307 | 308 |
308 /** | 309 /** |
309 * A handler for selecting a site (by clicking on the origin). | 310 * A handler for selecting a site (by clicking on the origin). |
310 * @param {!{model: !{item: !SiteException}}} event | 311 * @param {!{model: !{item: !SiteException}}} event |
311 * @private | 312 * @private |
312 */ | 313 */ |
313 onOriginTap_: function(event) { | 314 onOriginTap_: function(event) { |
314 if (!this.enableSiteSettings_) | 315 if (!this.enableSiteSettings_) |
315 return; | 316 return; |
316 settings.navigateTo(settings.Route.SITE_SETTINGS_SITE_DETAILS, | 317 settings.navigateTo( |
| 318 settings.Route.SITE_SETTINGS_SITE_DETAILS, |
317 new URLSearchParams('site=' + event.model.item.origin)); | 319 new URLSearchParams('site=' + event.model.item.origin)); |
318 }, | 320 }, |
319 | 321 |
320 /** | 322 /** |
321 * @param {?SiteException} site | 323 * @param {?SiteException} site |
322 * @private | 324 * @private |
323 */ | 325 */ |
324 resetPermissionForOrigin_: function(site) { | 326 resetPermissionForOrigin_: function(site) { |
325 assert(site); | 327 assert(site); |
326 this.browserProxy.resetCategoryPermissionForOrigin( | 328 this.browserProxy.resetCategoryPermissionForOrigin( |
(...skipping 27 matching lines...) Expand all Loading... |
354 onSessionOnlyTap_: function() { | 356 onSessionOnlyTap_: function() { |
355 this.setPermissionForActionMenuSite_( | 357 this.setPermissionForActionMenuSite_( |
356 settings.PermissionValues.SESSION_ONLY); | 358 settings.PermissionValues.SESSION_ONLY); |
357 this.closeActionMenu_(); | 359 this.closeActionMenu_(); |
358 }, | 360 }, |
359 | 361 |
360 /** @private */ | 362 /** @private */ |
361 onEditTap_: function() { | 363 onEditTap_: function() { |
362 // Close action menu without resetting |this.actionMenuSite_| since it is | 364 // Close action menu without resetting |this.actionMenuSite_| since it is |
363 // bound to the dialog. | 365 // bound to the dialog. |
364 /** @type {!CrActionMenuElement} */ ( | 366 /** @type {!CrActionMenuElement} */ (this.$$('dialog[is=cr-action-menu]')) |
365 this.$$('dialog[is=cr-action-menu]')).close(); | 367 .close(); |
366 this.showEditExceptionDialog_ = true; | 368 this.showEditExceptionDialog_ = true; |
367 }, | 369 }, |
368 | 370 |
369 /** @private */ | 371 /** @private */ |
370 onEditExceptionDialogClosed_: function() { | 372 onEditExceptionDialogClosed_: function() { |
371 this.showEditExceptionDialog_ = false; | 373 this.showEditExceptionDialog_ = false; |
372 this.actionMenuSite_ = null; | 374 this.actionMenuSite_ = null; |
373 this.activeDialogAnchor_.focus(); | 375 this.activeDialogAnchor_.focus(); |
374 this.activeDialogAnchor_ = null; | 376 this.activeDialogAnchor_ = null; |
375 }, | 377 }, |
376 | 378 |
377 /** @private */ | 379 /** @private */ |
378 onResetTap_: function() { | 380 onResetTap_: function() { |
379 this.resetPermissionForOrigin_(this.actionMenuSite_); | 381 this.resetPermissionForOrigin_(this.actionMenuSite_); |
380 this.closeActionMenu_(); | 382 this.closeActionMenu_(); |
381 }, | 383 }, |
382 | 384 |
383 /** | 385 /** |
384 * Returns the appropriate site description to display. This can, for example, | 386 * Returns the appropriate site description to display. This can, for example, |
385 * be blank, an 'embedded on <site>' or 'Current incognito session' (or a | 387 * be blank, an 'embedded on <site>' or 'Current incognito session' (or a |
386 * mix of the last two). | 388 * mix of the last two). |
387 * @param {SiteException} item The site exception entry. | 389 * @param {SiteException} item The site exception entry. |
388 * @return {string} The site description. | 390 * @return {string} The site description. |
389 */ | 391 */ |
390 computeSiteDescription_: function(item) { | 392 computeSiteDescription_: function(item) { |
391 if (item.incognito && item.embeddingDisplayName.length > 0) { | 393 if (item.incognito && item.embeddingDisplayName.length > 0) { |
392 return loadTimeData.getStringF('embeddedIncognitoSite', | 394 return loadTimeData.getStringF( |
393 item.embeddingDisplayName); | 395 'embeddedIncognitoSite', item.embeddingDisplayName); |
394 } | 396 } |
395 | 397 |
396 if (item.incognito) | 398 if (item.incognito) |
397 return loadTimeData.getString('incognitoSite'); | 399 return loadTimeData.getString('incognitoSite'); |
398 return item.embeddingDisplayName; | 400 return item.embeddingDisplayName; |
399 }, | 401 }, |
400 | 402 |
401 /** | 403 /** |
402 * @param {!{model: !{item: !SiteException}}} e | 404 * @param {!{model: !{item: !SiteException}}} e |
403 * @private | 405 * @private |
404 */ | 406 */ |
405 onResetButtonTap_: function(e) { | 407 onResetButtonTap_: function(e) { |
406 this.resetPermissionForOrigin_(e.model.item); | 408 this.resetPermissionForOrigin_(e.model.item); |
407 }, | 409 }, |
408 | 410 |
409 /** | 411 /** |
410 * @param {!{model: !{item: !SiteException}}} e | 412 * @param {!{model: !{item: !SiteException}}} e |
411 * @private | 413 * @private |
412 */ | 414 */ |
413 onShowActionMenuTap_: function(e) { | 415 onShowActionMenuTap_: function(e) { |
414 this.activeDialogAnchor_ = /** @type {!HTMLElement} */ ( | 416 this.activeDialogAnchor_ = /** @type {!HTMLElement} */ ( |
415 Polymer.dom(/** @type {!Event} */ (e)).localTarget); | 417 Polymer.dom(/** @type {!Event} */ (e)).localTarget); |
416 | 418 |
417 this.actionMenuSite_ = e.model.item; | 419 this.actionMenuSite_ = e.model.item; |
418 /** @type {!CrActionMenuElement} */ ( | 420 /** @type {!CrActionMenuElement} */ (this.$$('dialog[is=cr-action-menu]')) |
419 this.$$('dialog[is=cr-action-menu]')).showAt(this.activeDialogAnchor_); | 421 .showAt(this.activeDialogAnchor_); |
420 }, | 422 }, |
421 | 423 |
422 /** @private */ | 424 /** @private */ |
423 closeActionMenu_: function() { | 425 closeActionMenu_: function() { |
424 this.actionMenuSite_ = null; | 426 this.actionMenuSite_ = null; |
425 this.activeDialogAnchor_ = null; | 427 this.activeDialogAnchor_ = null; |
426 var actionMenu = /** @type {!CrActionMenuElement} */ ( | 428 var actionMenu = /** @type {!CrActionMenuElement} */ ( |
427 this.$$('dialog[is=cr-action-menu]')); | 429 this.$$('dialog[is=cr-action-menu]')); |
428 if (actionMenu.open) | 430 if (actionMenu.open) |
429 actionMenu.close(); | 431 actionMenu.close(); |
430 }, | 432 }, |
431 }); | 433 }); |
OLD | NEW |