Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1322)

Side by Side Diff: chrome/browser/resources/settings/site_settings/site_data_details_subpage.js

Issue 2617663002: WIP: run clang-format-js on lots of things (Closed)
Patch Set: merge Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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. 18 * The browser proxy used to retrieve and change cookies.
19 * @type {settings.SiteSettingsPrefsBrowserProxy} 19 * @type {settings.SiteSettingsPrefsBrowserProxy}
20 */ 20 */
21 browserProxy: Object, 21 browserProxy: Object,
22
23 /**
24 * The cookie entries for the given site.
25 * @type {!Array<!CookieDataItem>}
26 * @private
27 */
28 entries_: Array,
29
30 /** Set the page title on the settings-subpage parent. */
31 pageTitle: {
32 type: String,
33 notify: true,
34 },
35
36 /** @private */
37 site_: String,
38
39 /** @private */
40 siteId_: String,
41 },
42
43 /** @override */
44 ready: function() {
45 this.browserProxy =
46 settings.SiteSettingsPrefsBrowserProxyImpl.getInstance();
47
48 this.addWebUIListener(
49 'onTreeItemRemoved', this.getCookieDetails_.bind(this));
50 },
22 51
23 /** 52 /**
24 * The cookie entries for the given site. 53 * settings.RouteObserverBehavior
25 * @type {!Array<!CookieDataItem>} 54 * @param {!settings.Route} route
26 * @private 55 * @protected
27 */ 56 */
28 entries_: Array, 57 currentRouteChanged: function(route) {
29 58 if (settings.getCurrentRoute() !=
30 /** Set the page title on the settings-subpage parent. */ 59 settings.Route.SITE_SETTINGS_DATA_DETAILS)
31 pageTitle: { 60 return;
32 type: String, 61 var site = settings.getQueryParameters().get('site');
33 notify: true, 62 if (!site || site == this.site_)
63 return;
64 this.site_ = site;
65 this.pageTitle =
66 loadTimeData.getStringF('siteSettingsCookieSubpage', site);
67 this.getCookieDetails_();
34 }, 68 },
35 69
36 /** @private */ 70 /** @private */
37 site_: String, 71 getCookieDetails_: function() {
72 if (!this.site_)
73 return;
74 this.browserProxy.getCookieDetails(this.site_)
75 .then(
76 this.onCookiesLoaded_.bind(this),
77 this.onCookiesLoadFailed_.bind(this));
78 },
38 79
39 /** @private */ 80 /**
40 siteId_: String,
41 },
42
43 /** @override */
44 ready: function() {
45 this.browserProxy =
46 settings.SiteSettingsPrefsBrowserProxyImpl.getInstance();
47
48 this.addWebUIListener('onTreeItemRemoved',
49 this.getCookieDetails_.bind(this));
50 },
51
52 /**
53 * settings.RouteObserverBehavior
54 * @param {!settings.Route} route
55 * @protected
56 */
57 currentRouteChanged: function(route) {
58 if (settings.getCurrentRoute() != settings.Route.SITE_SETTINGS_DATA_DETAILS)
59 return;
60 var site = settings.getQueryParameters().get('site');
61 if (!site || site == this.site_)
62 return;
63 this.site_ = site;
64 this.pageTitle = loadTimeData.getStringF('siteSettingsCookieSubpage', site);
65 this.getCookieDetails_();
66 },
67
68 /** @private */
69 getCookieDetails_: function() {
70 if (!this.site_)
71 return;
72 this.browserProxy.getCookieDetails(this.site_).then(
73 this.onCookiesLoaded_.bind(this),
74 this.onCookiesLoadFailed_.bind(this));
75 },
76
77 /**
78 * @return {!Array<!CookieDataForDisplay>} 81 * @return {!Array<!CookieDataForDisplay>}
79 * @private 82 * @private
80 */ 83 */
81 getCookieNodes_: function(node) { 84 getCookieNodes_: function(node) {
82 return getCookieData(node); 85 return getCookieData(node);
83 }, 86 },
84 87
85 /** 88 /**
86 * @param {!CookieDataSummaryItem} cookies 89 * @param {!CookieDataSummaryItem} cookies
87 * @private 90 * @private
88 */ 91 */
89 onCookiesLoaded_: function(cookies) { 92 onCookiesLoaded_: function(cookies) {
90 this.siteId_ = cookies.id; 93 this.siteId_ = cookies.id;
91 this.entries_ = cookies.children; 94 this.entries_ = cookies.children;
92 // Set up flag for expanding cookie details. 95 // Set up flag for expanding cookie details.
93 this.entries_.map(function(e) { return e.expanded_ = false; }); 96 this.entries_.map(function(e) {
94 }, 97 return e.expanded_ = false;
98 });
99 },
95 100
96 /** 101 /**
97 * The site was not found. E.g. The site data may have been deleted or the 102 * The site was not found. E.g. The site data may have been deleted or the
98 * site URL parameter may be mistyped. 103 * site URL parameter may be mistyped.
99 * @private 104 * @private
100 */ 105 */
101 onCookiesLoadFailed_: function() { 106 onCookiesLoadFailed_: function() {
102 this.siteId_ = ''; 107 this.siteId_ = '';
103 this.entries_ = []; 108 this.entries_ = [];
104 }, 109 },
105 110
106 /** 111 /**
107 * A handler for when the user opts to remove a single cookie. 112 * A handler for when the user opts to remove a single cookie.
108 * @param {!CookieDetails} item 113 * @param {!CookieDetails} item
109 * @return {string} 114 * @return {string}
110 * @private 115 * @private
111 */ 116 */
112 getEntryDescription_: function(item) { 117 getEntryDescription_: function(item) {
113 // Frequently there are multiple cookies per site. To avoid showing a list 118 // Frequently there are multiple cookies per site. To avoid showing a list
114 // of '1 cookie', '1 cookie', ... etc, it is better to show the title of the 119 // of '1 cookie', '1 cookie', ... etc, it is better to show the title of
115 // cookie to differentiate them. 120 // the
116 if (item.type == 'cookie') 121 // cookie to differentiate them.
117 return item.title; 122 if (item.type == 'cookie')
118 return getCookieDataCategoryText(item.type, item.totalUsage); 123 return item.title;
119 }, 124 return getCookieDataCategoryText(item.type, item.totalUsage);
125 },
120 126
121 /** 127 /**
122 * A handler for when the user opts to remove a single cookie. 128 * A handler for when the user opts to remove a single cookie.
123 * @param {!Event} event 129 * @param {!Event} event
124 * @private 130 * @private
125 */ 131 */
126 onRemove_: function(event) { 132 onRemove_: function(event) {
127 this.browserProxy.removeCookie( 133 this.browserProxy.removeCookie(
128 /** @type {!CookieDetails} */(event.currentTarget.dataset).idPath); 134 /** @type {!CookieDetails} */ (event.currentTarget.dataset).idPath);
129 }, 135 },
130 136
131 /** 137 /**
132 * A handler for when the user opts to remove all cookies. 138 * A handler for when the user opts to remove all cookies.
133 */ 139 */
134 removeAll: function() { 140 removeAll: function() {
135 this.browserProxy.removeCookie(this.siteId_); 141 this.browserProxy.removeCookie(this.siteId_);
136 }, 142 },
137 }); 143 });
138 144
139 })(); 145 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698