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

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

Issue 2338163004: [MD settings] add getSiteDetails to site settings browser proxy (Closed)
Patch Set: added comment Created 4 years, 3 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], 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 site that this widget is showing details for.
18 * @type {SiteException} 18 * @type {SiteException}
19 */ 19 */
20 site: { 20 site: {
21 type: Object, 21 type: Object,
22 observer: 'onSiteChanged_', 22 observer: 'onSiteChanged_',
23 }, 23 },
(...skipping 14 matching lines...) Expand all
38 38
39 listeners: { 39 listeners: {
40 'usage-deleted': 'onUsageDeleted', 40 'usage-deleted': 'onUsageDeleted',
41 }, 41 },
42 42
43 ready: function() { 43 ready: function() {
44 this.ContentSettingsTypes = settings.ContentSettingsTypes; 44 this.ContentSettingsTypes = settings.ContentSettingsTypes;
45 }, 45 },
46 46
47 /** 47 /**
48 * settings.RouteObserverBehavior
49 * @param {!settings.Route} route
50 * @protected
51 */
52 currentRouteChanged: function(route) {
53 var site = settings.getQueryParameters().get('site');
54 if (!site)
55 return;
56 this.browserProxy.getSiteDetails(site).then(function(siteInfo) {
57 this.site = siteInfo;
58 // TODO(dschuyler): set originForDisplay for fetchUsageTotal.
59 // TODO(dschuyler): set the page title to originForDisplay.
60 }.bind(this));
61 },
62
63 /**
48 * Handler for when the origin changes. 64 * Handler for when the origin changes.
49 */ 65 */
50 onSiteChanged_: function() { 66 onSiteChanged_: function() {
51 // Using originForDisplay avoids the [*.] prefix that some exceptions use. 67 // originForDisplay may be initially undefined if the user follows a direct
52 var url = new URL(this.ensureUrlHasScheme(this.site.originForDisplay)); 68 // link (URL) to this page.
53 this.$.usageApi.fetchUsageTotal(url.hostname); 69 if (this.site.originForDisplay !== undefined) {
70 // Using originForDisplay avoids the [*.] prefix that some exceptions use.
71 var url = new URL(this.ensureUrlHasScheme(this.site.originForDisplay));
72 this.$.usageApi.fetchUsageTotal(url.hostname);
Finnur 2016/09/15 12:51:11 So, this code runs, for example, on refresh of Sit
dschuyler 2016/09/15 20:35:27 It /will/ do so after the originForDisplay is set,
73 }
54 }, 74 },
55 75
56 /** 76 /**
57 * Clears all data stored for the current origin. 77 * Clears all data stored for the current origin.
58 */ 78 */
59 onClearStorage_: function() { 79 onClearStorage_: function() {
60 this.$.usageApi.clearUsage(this.site.origin, this.storageType_); 80 this.$.usageApi.clearUsage(this.site.origin, this.storageType_);
61 }, 81 },
62 82
63 /** 83 /**
(...skipping 30 matching lines...) Expand all
94 114
95 /** 115 /**
96 * Returns true if one or more permission is showing. 116 * Returns true if one or more permission is showing.
97 */ 117 */
98 permissionShowing_: function() { 118 permissionShowing_: function() {
99 return Array.prototype.some.call( 119 return Array.prototype.some.call(
100 this.root.querySelectorAll('site-details-permission'), 120 this.root.querySelectorAll('site-details-permission'),
101 function(element) { return element.offsetHeight > 0; }); 121 function(element) { return element.offsetHeight > 0; });
102 }, 122 },
103 }); 123 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698