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: { |
(...skipping 21 matching lines...) Expand all Loading... |
38 * The browser proxy used to retrieve and change cookies. | 38 * The browser proxy used to retrieve and change cookies. |
39 * @private {?settings.SiteSettingsPrefsBrowserProxy} | 39 * @private {?settings.SiteSettingsPrefsBrowserProxy} |
40 */ | 40 */ |
41 browserProxy_: null, | 41 browserProxy_: null, |
42 | 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( |
49 this.getCookieDetails_.bind(this)); | 49 'onTreeItemRemoved', 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_) |
73 this.onCookiesLoaded_.bind(this), | 73 .then( |
74 this.onCookiesLoadFailed_.bind(this)); | 74 this.onCookiesLoaded_.bind(this), |
| 75 this.onCookiesLoadFailed_.bind(this)); |
75 }, | 76 }, |
76 | 77 |
77 /** | 78 /** |
78 * @return {!Array<!CookieDataForDisplay>} | 79 * @return {!Array<!CookieDataForDisplay>} |
79 * @private | 80 * @private |
80 */ | 81 */ |
81 getCookieNodes_: function(node) { | 82 getCookieNodes_: function(node) { |
82 return getCookieData(node); | 83 return getCookieData(node); |
83 }, | 84 }, |
84 | 85 |
85 /** | 86 /** |
86 * @param {!CookieList} cookies | 87 * @param {!CookieList} cookies |
87 * @private | 88 * @private |
88 */ | 89 */ |
89 onCookiesLoaded_: function(cookies) { | 90 onCookiesLoaded_: function(cookies) { |
90 this.siteId_ = cookies.id; | 91 this.siteId_ = cookies.id; |
91 this.entries_ = cookies.children; | 92 this.entries_ = cookies.children; |
92 // Set up flag for expanding cookie details. | 93 // Set up flag for expanding cookie details. |
93 this.entries_.forEach(function(e) { e.expanded_ = false; }); | 94 this.entries_.forEach(function(e) { |
| 95 e.expanded_ = false; |
| 96 }); |
94 }, | 97 }, |
95 | 98 |
96 /** | 99 /** |
97 * The site was not found. E.g. The site data may have been deleted or the | 100 * The site was not found. E.g. The site data may have been deleted or the |
98 * site URL parameter may be mistyped. | 101 * site URL parameter may be mistyped. |
99 * @private | 102 * @private |
100 */ | 103 */ |
101 onCookiesLoadFailed_: function() { | 104 onCookiesLoadFailed_: function() { |
102 this.siteId_ = ''; | 105 this.siteId_ = ''; |
103 this.entries_ = []; | 106 this.entries_ = []; |
(...skipping 14 matching lines...) Expand all Loading... |
118 return getCookieDataCategoryText(item.type, item.totalUsage); | 121 return getCookieDataCategoryText(item.type, item.totalUsage); |
119 }, | 122 }, |
120 | 123 |
121 /** | 124 /** |
122 * A handler for when the user opts to remove a single cookie. | 125 * A handler for when the user opts to remove a single cookie. |
123 * @param {!Event} event | 126 * @param {!Event} event |
124 * @private | 127 * @private |
125 */ | 128 */ |
126 onRemove_: function(event) { | 129 onRemove_: function(event) { |
127 this.browserProxy_.removeCookie( | 130 this.browserProxy_.removeCookie( |
128 /** @type {!CookieDetails} */(event.currentTarget.dataset).idPath); | 131 /** @type {!CookieDetails} */ (event.currentTarget.dataset).idPath); |
129 }, | 132 }, |
130 | 133 |
131 /** | 134 /** |
132 * A handler for when the user opts to remove all cookies. | 135 * A handler for when the user opts to remove all cookies. |
133 */ | 136 */ |
134 removeAll: function() { | 137 removeAll: function() { |
135 this.browserProxy_.removeCookie(this.siteId_); | 138 this.browserProxy_.removeCookie(this.siteId_); |
136 }, | 139 }, |
137 }); | 140 }); |
138 | 141 |
139 })(); | 142 })(); |
OLD | NEW |