| 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 (function() { | 5 (function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * 'site-data-details-subpage' Display cookie contents. | 9 * 'site-data-details-subpage' Display cookie contents. |
| 10 */ | 10 */ |
| 11 Polymer({ | 11 Polymer({ |
| 12 is: 'site-data-details-subpage', | 12 is: 'site-data-details-subpage', |
| 13 | 13 |
| 14 behaviors: [settings.RouteObserverBehavior, WebUIListenerBehavior], | 14 behaviors: [settings.RouteObserverBehavior, WebUIListenerBehavior], |
| 15 | 15 |
| 16 properties: { | 16 properties: { |
| 17 /** | 17 /** |
| 18 * The browser proxy used to retrieve and change cookies. | |
| 19 * @type {settings.SiteSettingsPrefsBrowserProxy} | |
| 20 */ | |
| 21 browserProxy: Object, | |
| 22 | |
| 23 /** | |
| 24 * The cookie entries for the given site. | 18 * The cookie entries for the given site. |
| 25 * @type {!Array<!CookieDetails>} | 19 * @type {!Array<!CookieDetails>} |
| 26 * @private | 20 * @private |
| 27 */ | 21 */ |
| 28 entries_: Array, | 22 entries_: Array, |
| 29 | 23 |
| 30 /** Set the page title on the settings-subpage parent. */ | 24 /** Set the page title on the settings-subpage parent. */ |
| 31 pageTitle: { | 25 pageTitle: { |
| 32 type: String, | 26 type: String, |
| 33 notify: true, | 27 notify: true, |
| 34 }, | 28 }, |
| 35 | 29 |
| 36 /** @private */ | 30 /** @private */ |
| 37 site_: String, | 31 site_: String, |
| 38 | 32 |
| 39 /** @private */ | 33 /** @private */ |
| 40 siteId_: String, | 34 siteId_: String, |
| 41 }, | 35 }, |
| 42 | 36 |
| 37 /** |
| 38 * The browser proxy used to retrieve and change cookies. |
| 39 * @private {?settings.SiteSettingsPrefsBrowserProxy} |
| 40 */ |
| 41 browserProxy_: null, |
| 42 |
| 43 /** @override */ | 43 /** @override */ |
| 44 ready: function() { | 44 ready: function() { |
| 45 this.browserProxy = | 45 this.browserProxy_ = |
| 46 settings.SiteSettingsPrefsBrowserProxyImpl.getInstance(); | 46 settings.SiteSettingsPrefsBrowserProxyImpl.getInstance(); |
| 47 | 47 |
| 48 this.addWebUIListener('onTreeItemRemoved', | 48 this.addWebUIListener('onTreeItemRemoved', |
| 49 this.getCookieDetails_.bind(this)); | 49 this.getCookieDetails_.bind(this)); |
| 50 }, | 50 }, |
| 51 | 51 |
| 52 /** | 52 /** |
| 53 * settings.RouteObserverBehavior | 53 * settings.RouteObserverBehavior |
| 54 * @param {!settings.Route} route | 54 * @param {!settings.Route} route |
| 55 * @protected | 55 * @protected |
| 56 */ | 56 */ |
| 57 currentRouteChanged: function(route) { | 57 currentRouteChanged: function(route) { |
| 58 if (settings.getCurrentRoute() != settings.Route.SITE_SETTINGS_DATA_DETAILS) | 58 if (settings.getCurrentRoute() != settings.Route.SITE_SETTINGS_DATA_DETAILS) |
| 59 return; | 59 return; |
| 60 var site = settings.getQueryParameters().get('site'); | 60 var site = settings.getQueryParameters().get('site'); |
| 61 if (!site || site == this.site_) | 61 if (!site || site == this.site_) |
| 62 return; | 62 return; |
| 63 this.site_ = site; | 63 this.site_ = site; |
| 64 this.pageTitle = loadTimeData.getStringF('siteSettingsCookieSubpage', site); | 64 this.pageTitle = loadTimeData.getStringF('siteSettingsCookieSubpage', site); |
| 65 this.getCookieDetails_(); | 65 this.getCookieDetails_(); |
| 66 }, | 66 }, |
| 67 | 67 |
| 68 /** @private */ | 68 /** @private */ |
| 69 getCookieDetails_: function() { | 69 getCookieDetails_: function() { |
| 70 if (!this.site_) | 70 if (!this.site_) |
| 71 return; | 71 return; |
| 72 this.browserProxy.getCookieDetails(this.site_).then( | 72 this.browserProxy_.getCookieDetails(this.site_).then( |
| 73 this.onCookiesLoaded_.bind(this), | 73 this.onCookiesLoaded_.bind(this), |
| 74 this.onCookiesLoadFailed_.bind(this)); | 74 this.onCookiesLoadFailed_.bind(this)); |
| 75 }, | 75 }, |
| 76 | 76 |
| 77 /** | 77 /** |
| 78 * @return {!Array<!CookieDataForDisplay>} | 78 * @return {!Array<!CookieDataForDisplay>} |
| 79 * @private | 79 * @private |
| 80 */ | 80 */ |
| 81 getCookieNodes_: function(node) { | 81 getCookieNodes_: function(node) { |
| 82 return getCookieData(node); | 82 return getCookieData(node); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 return item.title; | 117 return item.title; |
| 118 return getCookieDataCategoryText(item.type, item.totalUsage); | 118 return getCookieDataCategoryText(item.type, item.totalUsage); |
| 119 }, | 119 }, |
| 120 | 120 |
| 121 /** | 121 /** |
| 122 * A handler for when the user opts to remove a single cookie. | 122 * A handler for when the user opts to remove a single cookie. |
| 123 * @param {!Event} event | 123 * @param {!Event} event |
| 124 * @private | 124 * @private |
| 125 */ | 125 */ |
| 126 onRemove_: function(event) { | 126 onRemove_: function(event) { |
| 127 this.browserProxy.removeCookie( | 127 this.browserProxy_.removeCookie( |
| 128 /** @type {!CookieDetails} */(event.currentTarget.dataset).idPath); | 128 /** @type {!CookieDetails} */(event.currentTarget.dataset).idPath); |
| 129 }, | 129 }, |
| 130 | 130 |
| 131 /** | 131 /** |
| 132 * A handler for when the user opts to remove all cookies. | 132 * A handler for when the user opts to remove all cookies. |
| 133 */ | 133 */ |
| 134 removeAll: function() { | 134 removeAll: function() { |
| 135 this.browserProxy.removeCookie(this.siteId_); | 135 this.browserProxy_.removeCookie(this.siteId_); |
| 136 }, | 136 }, |
| 137 }); | 137 }); |
| 138 | 138 |
| 139 })(); | 139 })(); |
| OLD | NEW |