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

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

Issue 2936003003: MD Settings: Set all content setting values in Site Details Javascript. (Closed)
Patch Set: Convert getCategoryPermissionForOrigin to getOriginPermissions Created 3 years, 5 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 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * 'site-details' show the details (permissions and usage) for a given origin 7 * 'site-details' show the details (permissions and usage) for a given origin
8 * under Site Settings. 8 * under Site Settings.
9 */ 9 */
10 Polymer({ 10 Polymer({
11 is: 'site-details', 11 is: 'site-details',
12 12
13 behaviors: [SiteSettingsBehavior, settings.RouteObserverBehavior], 13 behaviors: [SiteSettingsBehavior, settings.RouteObserverBehavior],
14 14
15 properties: { 15 properties: {
16 /** 16 /**
17 * The site that this widget is showing details for. 17 * The origin that this widget is showing details for.
18 * @type {SiteException} 18 * @private
19 */ 19 */
20 site: { 20 origin: {
21 type: Object, 21 type: String,
22 observer: 'onSiteChanged_', 22 observer: 'onOriginChanged_',
23 }, 23 },
24 24
25 /** 25 /**
26 * The amount of data stored for the origin. 26 * The amount of data stored for the origin.
27 * @private 27 * @private
28 */ 28 */
29 storedData_: { 29 storedData_: {
30 type: String, 30 type: String,
31 value: '', 31 value: '',
32 }, 32 },
(...skipping 19 matching lines...) Expand all
52 52
53 /** 53 /**
54 * settings.RouteObserverBehavior 54 * settings.RouteObserverBehavior
55 * @param {!settings.Route} route 55 * @param {!settings.Route} route
56 * @protected 56 * @protected
57 */ 57 */
58 currentRouteChanged: function(route) { 58 currentRouteChanged: function(route) {
59 var site = settings.getQueryParameters().get('site'); 59 var site = settings.getQueryParameters().get('site');
60 if (!site) 60 if (!site)
61 return; 61 return;
62 this.browserProxy.getSiteDetails(site).then(function(siteInfo) { 62 this.origin = site;
63 this.site = this.expandSiteException(siteInfo);
64 }.bind(this));
65 }, 63 },
66 64
67 /** 65 /**
68 * Handler for when the origin changes. 66 * Handler for when the origin changes.
69 * @private 67 * @private
70 */ 68 */
71 onSiteChanged_: function() { 69 onOriginChanged_: function() {
72 // origin may be initially undefined if the user follows a direct 70 this.$.usageApi.fetchUsageTotal(this.toUrl(this.origin).hostname);
73 // link (URL) to this page. 71
74 var origin = this.site.origin; 72 var siteDetailsPermissions = /** @type{!NodeList<!SiteDetailsPermission>} */
75 if (origin !== undefined) 73 this.root.querySelectorAll('site-details-permission');
dschuyler 2017/06/28 23:55:52 I thought a type case like: /** @type ... */ (foo)
Patti Lor 2017/06/29 02:11:07 Oops, yes, you're totally right. Parens added and
76 this.$.usageApi.fetchUsageTotal(this.toUrl(origin).hostname); 74 var categoryList =
75 /** @type{!NodeList<!string>} */ Array.prototype.map.call(
76 siteDetailsPermissions, function(element) {
77 return element.category;
78 });
79
80 this.browserProxy.getOriginPermissions(this.origin, categoryList)
81 .then(function(exceptionList) {
82 exceptionList.forEach(function(exception, i) {
83 // |exceptionList| should be in the same order as |categoryList|,
84 // which is in the same order as |siteDetailsPermissions|.
85 var element = siteDetailsPermissions[i];
86 element.site = element.expandSiteException(exception);
87 });
88 });
77 }, 89 },
78 90
79 /** @private */ 91 /** @private */
80 onCloseDialog_: function() { 92 onCloseDialog_: function() {
81 this.$.confirmDeleteDialog.close(); 93 this.$.confirmDeleteDialog.close();
82 }, 94 },
83 95
84 /** 96 /**
85 * Confirms the deletion of storage for a site. 97 * Confirms the deletion of storage for a site.
86 * @param {!Event} e 98 * @param {!Event} e
87 * @private 99 * @private
88 */ 100 */
89 onConfirmClearStorage_: function(e) { 101 onConfirmClearStorage_: function(e) {
90 e.preventDefault(); 102 e.preventDefault();
91 this.confirmationDeleteMsg_ = loadTimeData.getStringF( 103 this.confirmationDeleteMsg_ = loadTimeData.getStringF(
92 'siteSettingsSiteRemoveConfirmation', 104 'siteSettingsSiteRemoveConfirmation', this.toUrl(this.origin).href);
93 this.toUrl(this.site.origin).href);
94 this.$.confirmDeleteDialog.showModal(); 105 this.$.confirmDeleteDialog.showModal();
95 }, 106 },
96 107
97 /** 108 /**
98 * Clears all data stored for the current origin. 109 * Clears all data stored for the current origin.
99 * @private 110 * @private
100 */ 111 */
101 onClearStorage_: function() { 112 onClearStorage_: function() {
102 this.$.usageApi.clearUsage( 113 this.$.usageApi.clearUsage(this.toUrl(this.origin).href, this.storageType_);
103 this.toUrl(this.site.origin).href, this.storageType_);
104 }, 114 },
105 115
106 /** 116 /**
107 * Called when usage has been deleted for an origin. 117 * Called when usage has been deleted for an origin.
108 * @param {!{detail: !{origin: string}}} event 118 * @param {!{detail: !{origin: string}}} event
109 * @private 119 * @private
110 */ 120 */
111 onUsageDeleted_: function(event) { 121 onUsageDeleted_: function(event) {
112 if (event.detail.origin == this.toUrl(this.site.origin).href) { 122 if (event.detail.origin == this.toUrl(this.origin).href) {
113 this.storedData_ = ''; 123 this.storedData_ = '';
114 this.navigateBackIfNoData_(); 124 this.navigateBackIfNoData_();
115 } 125 }
116 }, 126 },
117 127
118 /** 128 /**
119 * Resets all permissions and clears all data stored for the current origin. 129 * Resets all permissions and clears all data stored for the current origin.
120 * @private 130 * @private
121 */ 131 */
122 onClearAndReset_: function() { 132 onClearAndReset_: function() {
123 Array.prototype.forEach.call( 133 this.root.querySelectorAll('site-details-permission')
124 this.root.querySelectorAll('site-details-permission'), 134 .forEach(function(element) {
125 function(element) {
126 element.resetPermission(); 135 element.resetPermission();
127 }); 136 });
128 137
129 if (this.storedData_ != '') 138 if (this.storedData_ != '')
130 this.onClearStorage_(); 139 this.onClearStorage_();
131 else 140 else
132 this.navigateBackIfNoData_(); 141 this.navigateBackIfNoData_();
133 }, 142 },
134 143
135 /** 144 /**
(...skipping 10 matching lines...) Expand all
146 * @private 155 * @private
147 */ 156 */
148 permissionShowing_: function() { 157 permissionShowing_: function() {
149 return Array.prototype.some.call( 158 return Array.prototype.some.call(
150 this.root.querySelectorAll('site-details-permission'), 159 this.root.querySelectorAll('site-details-permission'),
151 function(element) { 160 function(element) {
152 return element.offsetHeight > 0; 161 return element.offsetHeight > 0;
153 }); 162 });
154 }, 163 },
155 }); 164 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698