Bug 1134553 - Disable downloads in guest session. r=rnewman

This commit is contained in:
Margaret Leibovic 2015-03-12 11:26:12 -07:00
parent 4e08a02354
commit 5a7457bdc4

View File

@ -16,6 +16,9 @@ XPCOMUtils.defineLazyModuleGetter(this, "Notifications", "resource://gre/modules
XPCOMUtils.defineLazyModuleGetter(this, "OS", "resource://gre/modules/osfile.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Services", "resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "ParentalControls",
"@mozilla.org/parental-controls-service;1", "nsIParentalControlsService");
let Log = Cu.import("resource://gre/modules/AndroidLog.jsm", {}).AndroidLog.i.bind(null, "DownloadNotifications");
XPCOMUtils.defineLazyGetter(this, "strings",
@ -58,6 +61,13 @@ var DownloadNotifications = {
return;
}
if (!ParentalControls.isAllowed(ParentalControls.DOWNLOAD)) {
download.cancel().catch(Cu.reportError);
download.removePartialData().catch(Cu.reportError);
window.NativeWindow.toast.show(strings.GetStringFromName("downloads.disabledInGuest"), "long");
return;
}
let notification = new DownloadNotification(download);
notifications.set(download, notification);
notification.showOrUpdate();