Bug 1312372 - List sites using storage in Settings of Site Data, r=jaws
MozReview-Commit-ID: HqaiLW5R8Qv
This commit is contained in:
@@ -4,6 +4,7 @@ const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "OfflineAppCacheHelper",
|
||||
"resource:///modules/offlineAppCache.jsm");
|
||||
@@ -177,5 +178,28 @@ this.SiteDataManager = {
|
||||
Services.cookies.removeAll();
|
||||
OfflineAppCacheHelper.clear();
|
||||
this.updateSites();
|
||||
},
|
||||
|
||||
getSites() {
|
||||
return Promise.all([this._updateQuotaPromise, this._updateDiskCachePromise])
|
||||
.then(() => {
|
||||
let list = [];
|
||||
for (let [origin, site] of this._sites) {
|
||||
let cache = null;
|
||||
let usage = site.quotaUsage;
|
||||
for (cache of site.appCacheList) {
|
||||
usage += cache.usage;
|
||||
}
|
||||
for (cache of site.diskCacheList) {
|
||||
usage += cache.dataSize;
|
||||
}
|
||||
list.push({
|
||||
usage,
|
||||
status: site.status,
|
||||
uri: NetUtil.newURI(origin)
|
||||
});
|
||||
}
|
||||
return list;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -60,6 +60,8 @@ var gAdvancedPane = {
|
||||
SiteDataManager.updateSites();
|
||||
setEventListener("clearSiteDataButton", "command",
|
||||
gAdvancedPane.clearSiteData);
|
||||
setEventListener("siteDataSettings", "command",
|
||||
gAdvancedPane.showSiteDataSettings);
|
||||
}
|
||||
|
||||
setEventListener("layers.acceleration.disabled", "change",
|
||||
@@ -339,6 +341,10 @@ var gAdvancedPane = {
|
||||
gSubDialog.open("chrome://browser/content/preferences/connection.xul");
|
||||
},
|
||||
|
||||
showSiteDataSettings: function() {
|
||||
gSubDialog.open("chrome://browser/content/preferences/siteDataSettings.xul");
|
||||
},
|
||||
|
||||
updateTotalSiteDataSize: function() {
|
||||
SiteDataManager.getTotalUsage()
|
||||
.then(usage => {
|
||||
|
||||
@@ -338,6 +338,11 @@
|
||||
<button id="clearSiteDataButton" icon="clear"
|
||||
label="&clearSiteData.label;" accesskey="&clearSiteData.accesskey;"/>
|
||||
</hbox>
|
||||
<vbox align="end">
|
||||
<button id="siteDataSettings"
|
||||
label="&siteDataSettings.label;"
|
||||
accesskey="&siteDataSettings.accesskey;"/>
|
||||
</vbox>
|
||||
</groupbox>
|
||||
</tabpanel>
|
||||
|
||||
|
||||
@@ -27,5 +27,9 @@ browser.jar:
|
||||
content/browser/preferences/sanitize.js
|
||||
content/browser/preferences/selectBookmark.xul
|
||||
content/browser/preferences/selectBookmark.js
|
||||
content/browser/preferences/siteDataSettings.xul
|
||||
content/browser/preferences/siteDataSettings.js
|
||||
content/browser/preferences/siteDataSettings.css
|
||||
content/browser/preferences/siteListItem.xml
|
||||
content/browser/preferences/translation.xul
|
||||
content/browser/preferences/translation.js
|
||||
|
||||
15
browser/components/preferences/siteDataSettings.css
Normal file
15
browser/components/preferences/siteDataSettings.css
Normal file
@@ -0,0 +1,15 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#sitesList {
|
||||
min-height: 20em;
|
||||
}
|
||||
|
||||
#sitesList > richlistitem {
|
||||
-moz-binding: url("chrome://browser/content/preferences/siteListItem.xml#siteListItem");
|
||||
}
|
||||
|
||||
.item-box {
|
||||
padding: 5px 8px;
|
||||
}
|
||||
69
browser/components/preferences/siteDataSettings.js
Normal file
69
browser/components/preferences/siteDataSettings.js
Normal file
@@ -0,0 +1,69 @@
|
||||
/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
const { interfaces: Ci, utils: Cu } = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "SiteDataManager",
|
||||
"resource:///modules/SiteDataManager.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "DownloadUtils",
|
||||
"resource://gre/modules/DownloadUtils.jsm");
|
||||
|
||||
"use strict";
|
||||
|
||||
let gSiteDataSettings = {
|
||||
|
||||
// Array of meatdata of sites. Each array element is object holding:
|
||||
// - uri: uri of site; instance of nsIURI
|
||||
// - status: persistent-storage permission status
|
||||
// - usage: disk usage which site uses
|
||||
_sites: null,
|
||||
|
||||
_list: null,
|
||||
|
||||
init() {
|
||||
this._list = document.getElementById("sitesList");
|
||||
SiteDataManager.getSites().then(sites => {
|
||||
this._sites = sites;
|
||||
this._sortSites(this._sites, "decending");
|
||||
this._buildSitesList(this._sites);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Sort sites by usages
|
||||
*
|
||||
* @param sites {Array}
|
||||
* @param order {String} indicate to sort in the "decending" or "ascending" order
|
||||
*/
|
||||
_sortSites(sites, order) {
|
||||
sites.sort((a, b) => {
|
||||
if (order === "ascending") {
|
||||
return a.usage - b.usage;
|
||||
}
|
||||
return b.usage - a.usage;
|
||||
});
|
||||
},
|
||||
|
||||
_buildSitesList(sites) {
|
||||
// Clear old entries.
|
||||
while (this._list.childNodes.length > 1) {
|
||||
this._list.removeChild(this._list.lastChild);
|
||||
}
|
||||
|
||||
let prefStrBundle = document.getElementById("bundlePreferences");
|
||||
for (let data of sites) {
|
||||
let statusStrId = data.status === Ci.nsIPermissionManager.ALLOW_ACTION ? "important" : "default";
|
||||
let size = DownloadUtils.convertByteUnits(data.usage);
|
||||
let item = document.createElement("richlistitem");
|
||||
item.setAttribute("data-origin", data.uri.spec);
|
||||
item.setAttribute("host", data.uri.host);
|
||||
item.setAttribute("status", prefStrBundle.getString(statusStrId));
|
||||
item.setAttribute("usage", prefStrBundle.getFormattedString("siteUsage", size));
|
||||
this._list.appendChild(item);
|
||||
}
|
||||
}
|
||||
};
|
||||
38
browser/components/preferences/siteDataSettings.xul
Normal file
38
browser/components/preferences/siteDataSettings.xul
Normal file
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://browser/skin/preferences/preferences.css" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://browser/content/preferences/siteDataSettings.css" type="text/css"?>
|
||||
|
||||
<!DOCTYPE dialog SYSTEM "chrome://browser/locale/preferences/siteDataSettings.dtd" >
|
||||
|
||||
<window id="SiteDataSettingsDialog" windowtype="Browser:SiteDataSettings"
|
||||
class="windowDialog" title="&window.title;"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
style="width: 45em;"
|
||||
onload="gSiteDataSettings.init();"
|
||||
persist="screenX screenY width height">
|
||||
|
||||
<script src="chrome://browser/content/preferences/siteDataSettings.js"/>
|
||||
|
||||
<stringbundle id="bundlePreferences"
|
||||
src="chrome://browser/locale/preferences/preferences.properties"/>
|
||||
|
||||
<vbox flex="1">
|
||||
<description>&settings.description;</description>
|
||||
<separator class="thin"/>
|
||||
|
||||
<richlistbox id="sitesList" orient="vertical" flex="1">
|
||||
<listheader>
|
||||
<treecol flex="4" width="50" label="&hostCol.label;"/>
|
||||
<treecol flex="2" width="50" label="&statusCol.label;"/>
|
||||
<treecol flex="1" width="50" label="&usageCol.label;"/>
|
||||
</listheader>
|
||||
</richlistbox>
|
||||
</vbox>
|
||||
|
||||
</window>
|
||||
36
browser/components/preferences/siteListItem.xml
Normal file
36
browser/components/preferences/siteListItem.xml
Normal file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
<!-- import-globals-from siteDataSettings.js -->
|
||||
|
||||
<!DOCTYPE overlay [
|
||||
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
|
||||
<!ENTITY % applicationsDTD SYSTEM "chrome://browser/locale/preferences/siteDataSettings.dtd">
|
||||
%brandDTD;
|
||||
%applicationsDTD;
|
||||
]>
|
||||
|
||||
<bindings id="siteListItemBindings"
|
||||
xmlns="http://www.mozilla.org/xbl"
|
||||
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
xmlns:xbl="http://www.mozilla.org/xbl">
|
||||
|
||||
<binding id="siteListItem" extends="chrome://global/content/bindings/richlistbox.xml#richlistitem">
|
||||
<content>
|
||||
<xul:hbox flex="1">
|
||||
<xul:hbox flex="4" width="50" class="item-box" align="center" xbl:inherits="tooltiptext=host">
|
||||
<xul:label flex="1" crop="end" xbl:inherits="value=host"/>
|
||||
</xul:hbox>
|
||||
<xul:hbox flex="2" width="50" class="item-box" align="center" xbl:inherits="tooltiptext=status">
|
||||
<xul:label flex="1" crop="end" xbl:inherits="value=status"/>
|
||||
</xul:hbox>
|
||||
<xul:hbox flex="1" width="50" class="item-box" align="center" xbl:inherits="tooltiptext=usage">
|
||||
<xul:label flex="1" crop="end" xbl:inherits="value=usage"/>
|
||||
</xul:hbox>
|
||||
</xul:hbox>
|
||||
</content>
|
||||
</binding>
|
||||
|
||||
</bindings>
|
||||
@@ -61,6 +61,8 @@
|
||||
<!ENTITY siteData.label "Site Data">
|
||||
<!ENTITY clearSiteData.label "Clear All Data">
|
||||
<!ENTITY clearSiteData.accesskey "l">
|
||||
<!ENTITY siteDataSettings.label "Settings…">
|
||||
<!ENTITY siteDataSettings.accesskey "i">
|
||||
|
||||
<!-- LOCALIZATION NOTE:
|
||||
The entities limitCacheSizeBefore.label and limitCacheSizeAfter.label appear on a single
|
||||
|
||||
@@ -173,6 +173,9 @@ totalSiteDataSize=Your stored site data is currently using %1$S %2$S of disk spa
|
||||
clearSiteDataPromptTitle=Clear all cookies and site data
|
||||
clearSiteDataPromptText=Selecting ‘Clear Now’ will clear all cookies and site data stored by Firefox. This may sign you out of websites and remove offline web content.
|
||||
clearSiteDataNow=Clear Now
|
||||
important=Important
|
||||
default=Default
|
||||
siteUsage=%1$S %2$S
|
||||
|
||||
syncUnlink.title=Do you want to unlink your device?
|
||||
syncUnlink.label=This device will no longer be associated with your Sync account. All of your personal data, both on this device and in your Sync account, will remain intact.
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<!ENTITY window.title "Settings - Site Data">
|
||||
<!ENTITY settings.description "The following websites asked to store site data in your disk. You can specify which websites are allowed to store site data. Default site data is temporary and could be deleted automatically.">
|
||||
<!ENTITY hostCol.label "Site">
|
||||
<!ENTITY statusCol.label "Status">
|
||||
<!ENTITY usageCol.label "Storage">
|
||||
@@ -82,6 +82,7 @@
|
||||
locale/browser/preferences/sync.dtd (%chrome/browser/preferences/sync.dtd)
|
||||
locale/browser/preferences/tabs.dtd (%chrome/browser/preferences/tabs.dtd)
|
||||
locale/browser/preferences/search.dtd (%chrome/browser/preferences/search.dtd)
|
||||
locale/browser/preferences/siteDataSettings.dtd (%chrome/browser/preferences/siteDataSettings.dtd)
|
||||
locale/browser/preferences/translation.dtd (%chrome/browser/preferences/translation.dtd)
|
||||
locale/browser/syncBrand.dtd (%chrome/browser/syncBrand.dtd)
|
||||
locale/browser/syncSetup.dtd (%chrome/browser/syncSetup.dtd)
|
||||
|
||||
Reference in New Issue
Block a user