Bug 399528: Add 'never for this site' option to the offline-app notification bar. r=mconnor, ui-r=beltzner, blocking-firefox3=mconnor

This commit is contained in:
dcamp%mozilla.com 2008-02-22 06:34:16 +00:00
Родитель c2bbaae5e4
Коммит 7d76aeb7c2
9 изменённых файлов: 86 добавлений и 8 удалений

Просмотреть файл

@ -692,6 +692,10 @@ pref("browser.ssl_override_behavior", 1);
// 2 - show full domain (e.g. bugzilla.mozilla.org)
pref("browser.identity.ssl_domain_display", 0);
// True if the user should be prompted when a web application supports
// offline apps.
pref("browser.offline-apps.notify", true);
// if true, use full page zoom instead of text zoom
pref("browser.zoom.full", true);

Просмотреть файл

@ -5014,6 +5014,10 @@ var OfflineApps = {
},
offlineAppRequested: function(aContentWindow) {
if (!gPrefService.getBoolPref("browser.offline-apps.notify")) {
return;
}
var browserWindow = this._getBrowserWindowForContentWindow(aContentWindow);
var browser = this._getBrowserForContentWindow(browserWindow,
aContentWindow);
@ -5045,6 +5049,14 @@ var OfflineApps = {
label: bundle_browser.getString("offlineApps.allow"),
accessKey: bundle_browser.getString("offlineApps.allowAccessKey"),
callback: function() { OfflineApps.allowSite(); }
},{
label: bundle_browser.getString("offlineApps.never"),
accessKey: bundle_browser.getString("offlineApps.neverAccessKey"),
callback: function() { OfflineApps.disallowSite(); }
},{
label: bundle_browser.getString("offlineApps.notNow"),
accessKey: bundle_browser.getString("offlineApps.notNowAccessKey"),
callback: function() { /* noop */ }
}];
const priority = notificationBox.PRIORITY_INFO_LOW;
@ -5068,6 +5080,13 @@ var OfflineApps = {
this._startFetching();
},
disallowSite: function() {
var currentURI = gBrowser.selectedBrowser.webNavigation.currentURI;
var pm = Cc["@mozilla.org/permissionmanager;1"].
getService(Ci.nsIPermissionManager);
pm.add(currentURI, "offline-app", Ci.nsIPermissionManager.DENY_ACTION);
},
_startFetching: function() {
var manifest = content.document.documentElement.getAttribute("manifest");
if (!manifest)

Просмотреть файл

@ -180,6 +180,30 @@ var gAdvancedPane = {
} catch(ex) {}
},
readOfflineNotify: function()
{
var pref = document.getElementById("browser.offline-apps.notify");
var button = document.getElementById("offlineNotifyExceptions");
button.disabled = !pref.value;
return pref.value;
},
showOfflineExceptions: function()
{
var bundlePreferences = document.getElementById("bundlePreferences");
var params = { blockVisible : false,
sessionVisible : false,
allowVisible : false,
prefilledHost : "",
permissionType : "offline-app",
manageCapability : Ci.nsIPermissionManager.DENY_ACTION,
windowTitle : bundlePreferences.getString("offlinepermissionstitle"),
introText : bundlePreferences.getString("offlinepermissionstext") };
document.documentElement.openWindow("Browser:Permissions",
"chrome://browser/content/preferences/permissions.xul",
"", params);
},
/**
* Updates the list of offline applications
*/

Просмотреть файл

@ -83,7 +83,7 @@
<!-- Network tab -->
<preference id="browser.cache.disk.capacity" name="browser.cache.disk.capacity" type="int"/>
<preference id="browser.offline-apps.notify" name="browser.offline-apps.notify" type="bool"/>
<!-- Update tab -->
<preference id="app.update.enabled" name="app.update.enabled" type="bool"
@ -232,6 +232,16 @@
label="&clearCacheNow.label;" accesskey="&clearCacheNow.accesskey;"
oncommand="gAdvancedPane.clearCache();"/>
</hbox>
<hbox>
<checkbox id="offlineNotify" flex="1"
label="&offlineNotify.label;" accesskey="&offlineNotify.accesskey;"
preference="browser.offline-apps.notify"
onsyncfrompreference="return gAdvancedPane.readOfflineNotify();"/>
<button id="offlineNotifyExceptions"
label="&offlineNotifyExceptions.label;"
accesskey="&offlineNotifyExceptions.accesskey;"
oncommand="gAdvancedPane.showOfflineExceptions();"/>
</hbox>
<hbox>
<vbox flex="1">

Просмотреть файл

@ -177,6 +177,7 @@ var gPermissionManager = {
}
this._type = aParams.permissionType;
this._manageCapability = aParams.manageCapability;
var permissionsText = document.getElementById("permissionsText");
while (permissionsText.hasChildNodes())
@ -188,12 +189,18 @@ var gPermissionManager = {
document.getElementById("btnBlock").hidden = !aParams.blockVisible;
document.getElementById("btnSession").hidden = !aParams.sessionVisible;
document.getElementById("btnAllow").hidden = !aParams.allowVisible;
var urlFieldVisible = (aParams.blockVisible || aParams.sessionVisible || aParams.allowVisible);
var urlField = document.getElementById("url");
urlField.value = aParams.prefilledHost;
urlField.hidden = !urlFieldVisible;
this.onHostInput(urlField);
var urlLabel = document.getElementById("urlLabel");
urlLabel.hidden = !urlFieldVisible;
var os = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
os.addObserver(this, "perm-changed", false);
@ -334,7 +341,10 @@ var gPermissionManager = {
_addPermissionToList: function (aPermission)
{
if (aPermission.type == this._type) {
if (aPermission.type == this._type &&
(!this._manageCapability ||
(aPermission.capability == this._manageCapability))) {
var host = aPermission.host;
var capabilityString = this._getCapabilityString(aPermission.capability);
var p = new Permission(host,

Просмотреть файл

@ -66,7 +66,7 @@
<vbox class="contentPane" flex="1">
<description id="permissionsText" control="url"/>
<separator class="thin"/>
<label control="url" value="&address.label;"/>
<label id="urlLabel" control="url" value="&address.label;"/>
<hbox align="start">
<textbox id="url" flex="1"
oninput="gPermissionManager.onHostInput(event.target);"

Просмотреть файл

@ -97,9 +97,13 @@ starButtonOn.tooltip=Edit this bookmark
starButtonOff.tooltip=Bookmark this page
# Offline web applications
offlineApps.available=This website (%S) is offering to store data on your computer for offline use.
offlineApps.available=This website (%S) is asking to store data on your computer for offline use.
offlineApps.allow=Allow
offlineApps.allowAccessKey=A
offlineApps.never=Never for This Site
offlineApps.neverAccessKey=e
offlineApps.notNow=Not Now
offlineApps.notNowAccessKey=N
identity.identified.verifier=Verified by: %S
identity.identified.verified_by_you=You have added a security exception for this site

Просмотреть файл

@ -67,7 +67,12 @@
<!ENTITY updateHistory.label "Show Update History">
<!ENTITY updateHistory.accesskey "p">
<!ENTITY offlineAppsList.label "The following websites have data installed for offline use:">
<!ENTITY offlineNotify.label "Tell me when a website asks to store data for offline use">
<!ENTITY offlineNotify.accesskey "T">
<!ENTITY offlineNotifyExceptions.label "Exceptions…">
<!ENTITY offlineNotifyExceptions.accesskey "x">
<!ENTITY offlineAppsList.label "The following websites have stored data for offline use:">
<!ENTITY offlineAppsList.height "7em">
<!ENTITY offlineAppsListRemove.label "Remove…">
<!ENTITY offlineAppsListRemove.accesskey "R">

Просмотреть файл

@ -97,3 +97,5 @@ removeCookie=Remove Cookie
offlineAppRemoveTitle=Remove offline website data
offlineAppRemovePrompt=After removing this data, %S will not be available offline. Are you sure you want to remove this offline website?
offlineAppRemoveConfirm=Remove offline data
offlinepermissionstext=The following websites are not allowed to store data for offline use:
offlinepermissionstitle=Offline Data