2014-06-25 09:12:07 +04:00
|
|
|
// -*- indent-tabs-mode: nil; js-indent-level: 4 -*-
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2008-09-07 10:54:06 +04:00
|
|
|
|
2017-08-01 18:36:00 +03:00
|
|
|
/* globals LoadContextInfo, FormHistory, Accounts */
|
2015-06-25 09:11:11 +03:00
|
|
|
|
2015-09-15 21:19:45 +03:00
|
|
|
var Cc = Components.classes;
|
|
|
|
var Ci = Components.interfaces;
|
|
|
|
var Cu = Components.utils;
|
2013-02-06 04:08:02 +04:00
|
|
|
|
2013-06-05 02:59:50 +04:00
|
|
|
Cu.import("resource://gre/modules/Services.jsm");
|
|
|
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
2013-09-24 23:31:12 +04:00
|
|
|
Cu.import("resource://gre/modules/LoadContextInfo.jsm");
|
|
|
|
Cu.import("resource://gre/modules/FormHistory.jsm");
|
2014-12-23 00:14:32 +03:00
|
|
|
Cu.import("resource://gre/modules/Task.jsm");
|
|
|
|
Cu.import("resource://gre/modules/Downloads.jsm");
|
|
|
|
Cu.import("resource://gre/modules/osfile.jsm");
|
2015-05-04 15:08:31 +03:00
|
|
|
Cu.import("resource://gre/modules/Accounts.jsm");
|
2013-02-06 04:08:02 +04:00
|
|
|
|
2015-08-11 23:33:57 +03:00
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, "DownloadIntegration",
|
|
|
|
"resource://gre/modules/DownloadIntegration.jsm");
|
Bug 1321418 - Use GekcoBundle events in GeckoApp/BrowserApp; r=snorp r=sebastian r=gbrown
Bug 1321418 - 1. Use GekcoBundle events in GeckoApp; r=snorp r=sebastian
Switch GeckoApp to using GeckoBundle events everywhere. UI or Gecko
events are used if the event requires the UI or Gecko thread,
respectively, and background events are used for all other events.
There are changes to some other Java classes, such as SnackbarBuilder
and GeckoAccessibility, due to the switch to GeckoBundle.
For "Snackbar:Show", we need the global EventDispatcher because the
event can be sent to both GeckoApp and GeckoPreferences. Howveer, we
only want one listener registered at the same time, so we register and
unregister in GeckoApp's and GeckoPreferences's onPause and onResume
methods.
Bug 1321418 - 2. Use appropriate JS EventDispatcher to send GeckoApp events; r=snorp r=sebastian
Change JS code that sends events to GeckoApp to use either the global
EventDispatcher or the per-window EventDispatcher.
"Session:StatePurged" is not used so it's removed. "Gecko:Ready" in
geckoview.js is not necessary because it's only used for GeckoApp, so
it's removed from geckoview.js.
Bug 1321418 - 3. Use GeckoBundle events in BrowserApp; r=snorp r=sebastian
Switch BrowserApp to using GeckoBundle events, in a similar vein as
GeckoApp. UI or Gecko events are used if the event handlers required UI
or Gecko thread, respectively, and background events are used for all
other events.
Some other Java classes also have to be modified as a result of
switching to GeckoBundle.
Bug 1321418 - 4. Use global EventDispatcher to send BrowserApp events; r=snorp r=sebastian
Change JS code that sends events to BrowserApp to use the global
EventDispatcher instead of "Messaging".
Bug 1321418 - 5. Update usages of events in tests; r=gbrown
Update cases where we use or wait for events in tests.
2016-12-09 20:32:45 +03:00
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, "EventDispatcher",
|
|
|
|
"resource://gre/modules/Messaging.jsm");
|
2017-03-08 22:17:06 +03:00
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, "TelemetryStopwatch",
|
|
|
|
"resource://gre/modules/TelemetryStopwatch.jsm");
|
2015-08-11 23:33:57 +03:00
|
|
|
|
2013-02-06 04:08:02 +04:00
|
|
|
function dump(a) {
|
2013-08-08 19:05:48 +04:00
|
|
|
Services.console.logStringMessage(a);
|
2013-02-06 04:08:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
this.EXPORTED_SYMBOLS = ["Sanitizer"];
|
|
|
|
|
2008-09-07 10:54:06 +04:00
|
|
|
function Sanitizer() {}
|
|
|
|
Sanitizer.prototype = {
|
2017-08-13 21:55:42 +03:00
|
|
|
clearItem: function(aItemName, startTime) {
|
|
|
|
// Only a subset of items support deletion with startTime.
|
|
|
|
// Those who do not will be rejected with error message.
|
|
|
|
if (typeof startTime != "undefined") {
|
|
|
|
switch (aItemName) {
|
|
|
|
// Normal call to DownloadFiles remove actual data from storage, but our web-extension consumer
|
|
|
|
// deletes only download history. So, for this reason we are passing a flag 'deleteFiles'.
|
|
|
|
case "downloadHistory":
|
2017-09-07 20:27:01 +03:00
|
|
|
return this._clear("downloadFiles", { startTime, deleteFiles: false });
|
2017-06-19 18:23:00 +03:00
|
|
|
case "formdata":
|
2017-09-07 20:27:01 +03:00
|
|
|
return this._clear(aItemName, { startTime });
|
2017-08-13 21:55:42 +03:00
|
|
|
default:
|
|
|
|
return Promise.reject({message: `Invalid argument: ${aItemName} does not support startTime argument.`});
|
|
|
|
}
|
|
|
|
} else {
|
2017-09-07 20:27:01 +03:00
|
|
|
return this._clear(aItemName);
|
2017-08-13 21:55:42 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_clear: function(aItemName, options) {
|
2013-06-05 02:59:50 +04:00
|
|
|
let item = this.items[aItemName];
|
|
|
|
let canClear = item.canClear;
|
|
|
|
if (typeof canClear == "function") {
|
|
|
|
canClear(function clearCallback(aCanClear) {
|
|
|
|
if (aCanClear)
|
2017-08-13 21:55:42 +03:00
|
|
|
return item.clear(options);
|
2013-06-05 02:59:50 +04:00
|
|
|
});
|
|
|
|
} else if (canClear) {
|
2017-08-13 21:55:42 +03:00
|
|
|
return item.clear(options);
|
2013-06-05 02:59:50 +04:00
|
|
|
}
|
2008-09-07 10:54:06 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
items: {
|
|
|
|
cache: {
|
2017-08-01 18:43:56 +03:00
|
|
|
clear: function() {
|
2014-06-19 11:04:00 +04:00
|
|
|
return new Promise(function(resolve, reject) {
|
2017-03-08 22:17:06 +03:00
|
|
|
let refObj = {};
|
|
|
|
TelemetryStopwatch.start("FX_SANITIZE_CACHE", refObj);
|
|
|
|
|
2014-06-19 11:04:00 +04:00
|
|
|
var cache = Cc["@mozilla.org/netwerk/cache-storage-service;1"].getService(Ci.nsICacheStorageService);
|
|
|
|
try {
|
|
|
|
cache.clear();
|
2017-08-01 18:34:11 +03:00
|
|
|
} catch (er) {}
|
2014-06-19 11:04:00 +04:00
|
|
|
|
|
|
|
let imageCache = Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools)
|
|
|
|
.getImgCacheForDocument(null);
|
|
|
|
try {
|
|
|
|
imageCache.clearCache(false); // true=chrome, false=content
|
2017-08-01 18:34:11 +03:00
|
|
|
} catch (er) {}
|
2014-06-19 11:04:00 +04:00
|
|
|
|
2017-03-08 22:17:06 +03:00
|
|
|
TelemetryStopwatch.finish("FX_SANITIZE_CACHE", refObj);
|
2014-06-19 11:04:00 +04:00
|
|
|
resolve();
|
|
|
|
});
|
2008-09-07 10:54:06 +04:00
|
|
|
},
|
2012-04-20 23:49:47 +04:00
|
|
|
|
2017-08-01 18:43:56 +03:00
|
|
|
get canClear() {
|
2008-09-07 10:54:06 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
},
|
2012-04-20 23:49:47 +04:00
|
|
|
|
2008-09-07 10:54:06 +04:00
|
|
|
cookies: {
|
2017-08-01 18:43:56 +03:00
|
|
|
clear: function() {
|
2014-06-19 11:04:00 +04:00
|
|
|
return new Promise(function(resolve, reject) {
|
2017-03-08 22:17:06 +03:00
|
|
|
let refObj = {};
|
|
|
|
TelemetryStopwatch.start("FX_SANITIZE_COOKIES_2", refObj);
|
|
|
|
|
2014-06-19 11:04:00 +04:00
|
|
|
Services.cookies.removeAll();
|
2017-03-08 22:17:06 +03:00
|
|
|
|
|
|
|
TelemetryStopwatch.finish("FX_SANITIZE_COOKIES_2", refObj);
|
2014-06-19 11:04:00 +04:00
|
|
|
resolve();
|
|
|
|
});
|
2009-05-30 05:28:12 +04:00
|
|
|
},
|
2012-04-20 23:49:47 +04:00
|
|
|
|
2017-08-01 18:43:56 +03:00
|
|
|
get canClear() {
|
2009-05-30 05:28:12 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
siteSettings: {
|
2016-06-08 00:02:55 +03:00
|
|
|
clear: Task.async(function* () {
|
2017-03-08 22:17:06 +03:00
|
|
|
let refObj = {};
|
|
|
|
TelemetryStopwatch.start("FX_SANITIZE_SITESETTINGS", refObj);
|
|
|
|
|
2016-06-08 00:02:55 +03:00
|
|
|
// Clear site-specific permissions like "Allow this site to open popups"
|
|
|
|
Services.perms.removeAll();
|
|
|
|
|
|
|
|
// Clear site-specific settings like page-zoom level
|
|
|
|
Cc["@mozilla.org/content-pref/service;1"]
|
|
|
|
.getService(Ci.nsIContentPrefService2)
|
|
|
|
.removeAllDomains(null);
|
|
|
|
|
|
|
|
// Clear site security settings
|
|
|
|
var sss = Cc["@mozilla.org/ssservice;1"]
|
|
|
|
.getService(Ci.nsISiteSecurityService);
|
|
|
|
sss.clearAll();
|
|
|
|
|
|
|
|
// Clear push subscriptions
|
|
|
|
yield new Promise((resolve, reject) => {
|
|
|
|
let push = Cc["@mozilla.org/push/Service;1"]
|
|
|
|
.getService(Ci.nsIPushService);
|
|
|
|
push.clearForDomain("*", status => {
|
|
|
|
if (Components.isSuccessCode(status)) {
|
|
|
|
resolve();
|
|
|
|
} else {
|
|
|
|
reject(new Error("Error clearing push subscriptions: " +
|
|
|
|
status));
|
|
|
|
}
|
|
|
|
});
|
2014-06-19 11:04:00 +04:00
|
|
|
});
|
2017-03-08 22:17:06 +03:00
|
|
|
TelemetryStopwatch.finish("FX_SANITIZE_SITESETTINGS", refObj);
|
2016-06-08 00:02:55 +03:00
|
|
|
}),
|
2009-05-30 05:28:12 +04:00
|
|
|
|
2017-08-01 18:43:56 +03:00
|
|
|
get canClear() {
|
2009-05-30 05:28:12 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2008-09-07 10:54:06 +04:00
|
|
|
offlineApps: {
|
2017-08-01 18:43:56 +03:00
|
|
|
clear: function() {
|
2014-06-19 11:04:00 +04:00
|
|
|
return new Promise(function(resolve, reject) {
|
|
|
|
var cacheService = Cc["@mozilla.org/netwerk/cache-storage-service;1"].getService(Ci.nsICacheStorageService);
|
|
|
|
var appCacheStorage = cacheService.appCacheStorage(LoadContextInfo.default, null);
|
|
|
|
try {
|
|
|
|
appCacheStorage.asyncEvictStorage(null);
|
2017-08-01 18:34:11 +03:00
|
|
|
} catch (er) {}
|
2014-06-19 11:04:00 +04:00
|
|
|
|
|
|
|
resolve();
|
|
|
|
});
|
2008-09-07 10:54:06 +04:00
|
|
|
},
|
|
|
|
|
2017-08-01 18:43:56 +03:00
|
|
|
get canClear() {
|
2008-09-07 10:54:06 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
history: {
|
2017-08-01 18:43:56 +03:00
|
|
|
clear: function() {
|
2017-03-08 22:17:06 +03:00
|
|
|
let refObj = {};
|
|
|
|
TelemetryStopwatch.start("FX_SANITIZE_HISTORY", refObj);
|
|
|
|
|
Bug 1321418 - Use GekcoBundle events in GeckoApp/BrowserApp; r=snorp r=sebastian r=gbrown
Bug 1321418 - 1. Use GekcoBundle events in GeckoApp; r=snorp r=sebastian
Switch GeckoApp to using GeckoBundle events everywhere. UI or Gecko
events are used if the event requires the UI or Gecko thread,
respectively, and background events are used for all other events.
There are changes to some other Java classes, such as SnackbarBuilder
and GeckoAccessibility, due to the switch to GeckoBundle.
For "Snackbar:Show", we need the global EventDispatcher because the
event can be sent to both GeckoApp and GeckoPreferences. Howveer, we
only want one listener registered at the same time, so we register and
unregister in GeckoApp's and GeckoPreferences's onPause and onResume
methods.
Bug 1321418 - 2. Use appropriate JS EventDispatcher to send GeckoApp events; r=snorp r=sebastian
Change JS code that sends events to GeckoApp to use either the global
EventDispatcher or the per-window EventDispatcher.
"Session:StatePurged" is not used so it's removed. "Gecko:Ready" in
geckoview.js is not necessary because it's only used for GeckoApp, so
it's removed from geckoview.js.
Bug 1321418 - 3. Use GeckoBundle events in BrowserApp; r=snorp r=sebastian
Switch BrowserApp to using GeckoBundle events, in a similar vein as
GeckoApp. UI or Gecko events are used if the event handlers required UI
or Gecko thread, respectively, and background events are used for all
other events.
Some other Java classes also have to be modified as a result of
switching to GeckoBundle.
Bug 1321418 - 4. Use global EventDispatcher to send BrowserApp events; r=snorp r=sebastian
Change JS code that sends events to BrowserApp to use the global
EventDispatcher instead of "Messaging".
Bug 1321418 - 5. Update usages of events in tests; r=gbrown
Update cases where we use or wait for events in tests.
2016-12-09 20:32:45 +03:00
|
|
|
return EventDispatcher.instance.sendRequestForResult({ type: "Sanitize:ClearHistory" })
|
2014-09-04 21:31:13 +04:00
|
|
|
.catch(e => Cu.reportError("Java-side history clearing failed: " + e))
|
2014-09-03 02:53:30 +04:00
|
|
|
.then(function() {
|
2017-03-08 22:17:06 +03:00
|
|
|
TelemetryStopwatch.finish("FX_SANITIZE_HISTORY", refObj);
|
2014-06-19 11:04:00 +04:00
|
|
|
try {
|
2017-04-14 22:51:39 +03:00
|
|
|
Services.obs.notifyObservers(null, "browser:purge-session-history");
|
2017-08-01 18:43:56 +03:00
|
|
|
} catch (e) { }
|
2014-06-19 11:04:00 +04:00
|
|
|
|
|
|
|
try {
|
|
|
|
var predictor = Cc["@mozilla.org/network/predictor;1"].getService(Ci.nsINetworkPredictor);
|
|
|
|
predictor.reset();
|
|
|
|
} catch (e) { }
|
|
|
|
});
|
2008-09-07 10:54:06 +04:00
|
|
|
},
|
2012-04-20 23:49:47 +04:00
|
|
|
|
2017-08-01 18:43:56 +03:00
|
|
|
get canClear() {
|
2008-09-07 10:54:06 +04:00
|
|
|
// bug 347231: Always allow clearing history due to dependencies on
|
|
|
|
// the browser:purge-session-history notification. (like error console)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
},
|
2012-04-20 23:49:47 +04:00
|
|
|
|
2016-12-29 09:22:45 +03:00
|
|
|
openTabs: {
|
2017-08-01 18:43:56 +03:00
|
|
|
clear: function() {
|
2017-03-08 22:17:06 +03:00
|
|
|
let refObj = {};
|
|
|
|
TelemetryStopwatch.start("FX_SANITIZE_OPENWINDOWS", refObj);
|
|
|
|
|
2016-12-29 09:22:45 +03:00
|
|
|
return EventDispatcher.instance.sendRequestForResult({ type: "Sanitize:OpenTabs" })
|
|
|
|
.catch(e => Cu.reportError("Java-side tab clearing failed: " + e))
|
|
|
|
.then(function() {
|
|
|
|
try {
|
|
|
|
// clear "Recently Closed" tabs in Android App
|
2017-04-14 22:51:39 +03:00
|
|
|
Services.obs.notifyObservers(null, "browser:purge-session-tabs");
|
2017-08-01 18:43:56 +03:00
|
|
|
} catch (e) { }
|
2017-03-08 22:17:06 +03:00
|
|
|
TelemetryStopwatch.finish("FX_SANITIZE_OPENWINDOWS", refObj);
|
2016-12-29 09:22:45 +03:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2017-08-01 18:43:56 +03:00
|
|
|
get canClear() {
|
2016-12-29 09:22:45 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-03-30 21:20:00 +03:00
|
|
|
searchHistory: {
|
2017-08-01 18:43:56 +03:00
|
|
|
clear: function() {
|
Bug 1321418 - Use GekcoBundle events in GeckoApp/BrowserApp; r=snorp r=sebastian r=gbrown
Bug 1321418 - 1. Use GekcoBundle events in GeckoApp; r=snorp r=sebastian
Switch GeckoApp to using GeckoBundle events everywhere. UI or Gecko
events are used if the event requires the UI or Gecko thread,
respectively, and background events are used for all other events.
There are changes to some other Java classes, such as SnackbarBuilder
and GeckoAccessibility, due to the switch to GeckoBundle.
For "Snackbar:Show", we need the global EventDispatcher because the
event can be sent to both GeckoApp and GeckoPreferences. Howveer, we
only want one listener registered at the same time, so we register and
unregister in GeckoApp's and GeckoPreferences's onPause and onResume
methods.
Bug 1321418 - 2. Use appropriate JS EventDispatcher to send GeckoApp events; r=snorp r=sebastian
Change JS code that sends events to GeckoApp to use either the global
EventDispatcher or the per-window EventDispatcher.
"Session:StatePurged" is not used so it's removed. "Gecko:Ready" in
geckoview.js is not necessary because it's only used for GeckoApp, so
it's removed from geckoview.js.
Bug 1321418 - 3. Use GeckoBundle events in BrowserApp; r=snorp r=sebastian
Switch BrowserApp to using GeckoBundle events, in a similar vein as
GeckoApp. UI or Gecko events are used if the event handlers required UI
or Gecko thread, respectively, and background events are used for all
other events.
Some other Java classes also have to be modified as a result of
switching to GeckoBundle.
Bug 1321418 - 4. Use global EventDispatcher to send BrowserApp events; r=snorp r=sebastian
Change JS code that sends events to BrowserApp to use the global
EventDispatcher instead of "Messaging".
Bug 1321418 - 5. Update usages of events in tests; r=gbrown
Update cases where we use or wait for events in tests.
2016-12-09 20:32:45 +03:00
|
|
|
return EventDispatcher.instance.sendRequestForResult({ type: "Sanitize:ClearHistory", clearSearchHistory: true })
|
2017-10-15 21:50:30 +03:00
|
|
|
.catch(e => Cu.reportError("Java-side search history clearing failed: " + e));
|
2015-03-30 21:20:00 +03:00
|
|
|
},
|
|
|
|
|
2017-08-01 18:43:56 +03:00
|
|
|
get canClear() {
|
2015-03-30 21:20:00 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2008-09-07 10:54:06 +04:00
|
|
|
formdata: {
|
2017-06-19 18:23:00 +03:00
|
|
|
clear: function({ startTime = 0 } = {}) {
|
2014-06-19 11:04:00 +04:00
|
|
|
return new Promise(function(resolve, reject) {
|
2017-03-08 22:17:06 +03:00
|
|
|
let refObj = {};
|
|
|
|
TelemetryStopwatch.start("FX_SANITIZE_FORMDATA", refObj);
|
|
|
|
|
2017-06-19 18:23:00 +03:00
|
|
|
// Conver time to microseconds
|
|
|
|
let time = startTime * 1000;
|
|
|
|
FormHistory.update({
|
|
|
|
op: "remove",
|
|
|
|
firstUsedStart: time
|
|
|
|
});
|
2017-03-08 22:17:06 +03:00
|
|
|
|
|
|
|
TelemetryStopwatch.finish("FX_SANITIZE_FORMDATA", refObj);
|
2014-06-19 11:04:00 +04:00
|
|
|
resolve();
|
|
|
|
});
|
2008-09-07 10:54:06 +04:00
|
|
|
},
|
2012-04-20 23:49:47 +04:00
|
|
|
|
2017-08-01 18:43:56 +03:00
|
|
|
canClear: function(aCallback) {
|
2013-06-05 02:59:50 +04:00
|
|
|
let count = 0;
|
|
|
|
let countDone = {
|
|
|
|
handleResult: function(aResult) { count = aResult; },
|
|
|
|
handleError: function(aError) { Cu.reportError(aError); },
|
|
|
|
handleCompletion: function(aReason) { aCallback(aReason == 0 && count > 0); }
|
|
|
|
};
|
|
|
|
FormHistory.count({}, countDone);
|
2008-09-07 10:54:06 +04:00
|
|
|
}
|
|
|
|
},
|
2012-04-20 23:49:47 +04:00
|
|
|
|
2013-02-06 04:08:03 +04:00
|
|
|
downloadFiles: {
|
2017-08-13 21:55:42 +03:00
|
|
|
clear: Task.async(function* ({ startTime = 0, deleteFiles = true} = {}) {
|
2017-03-08 22:17:06 +03:00
|
|
|
let refObj = {};
|
|
|
|
TelemetryStopwatch.start("FX_SANITIZE_DOWNLOADS", refObj);
|
|
|
|
|
2014-12-23 00:14:32 +03:00
|
|
|
let list = yield Downloads.getList(Downloads.ALL);
|
|
|
|
let downloads = yield list.getAll();
|
2015-08-11 23:33:57 +03:00
|
|
|
var finalizePromises = [];
|
2014-12-23 00:14:32 +03:00
|
|
|
|
|
|
|
// Logic copied from DownloadList.removeFinished. Ideally, we would
|
|
|
|
// just use that method directly, but we want to be able to remove the
|
|
|
|
// downloaded files as well.
|
|
|
|
for (let download of downloads) {
|
|
|
|
// Remove downloads that have been canceled, even if the cancellation
|
|
|
|
// operation hasn't completed yet so we don't check "stopped" here.
|
2017-08-13 21:55:42 +03:00
|
|
|
// Failed downloads with partial data are also removed. The startTime
|
|
|
|
// check is provided for addons that may want to delete only recent downloads.
|
|
|
|
if (download.stopped && (!download.hasPartialData || download.error) &&
|
|
|
|
download.startTime.getTime() >= startTime) {
|
2014-12-23 00:14:32 +03:00
|
|
|
// Remove the download first, so that the views don't get the change
|
|
|
|
// notifications that may occur during finalization.
|
|
|
|
yield list.remove(download);
|
|
|
|
// Ensure that the download is stopped and no partial data is kept.
|
|
|
|
// This works even if the download state has changed meanwhile. We
|
|
|
|
// don't need to wait for the procedure to be complete before
|
|
|
|
// processing the other downloads in the list.
|
2015-08-11 23:33:57 +03:00
|
|
|
finalizePromises.push(download.finalize(true).then(() => null, Cu.reportError));
|
2014-12-23 00:14:32 +03:00
|
|
|
|
2017-08-13 21:55:42 +03:00
|
|
|
if (deleteFiles) {
|
|
|
|
// Delete the downloaded files themselves.
|
|
|
|
OS.File.remove(download.target.path).then(() => null, ex => {
|
|
|
|
if (!(ex instanceof OS.File.Error && ex.becauseNoSuchFile)) {
|
|
|
|
Cu.reportError(ex);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2014-12-23 00:14:32 +03:00
|
|
|
}
|
|
|
|
}
|
2015-08-11 23:33:57 +03:00
|
|
|
|
|
|
|
yield Promise.all(finalizePromises);
|
|
|
|
yield DownloadIntegration.forceSave();
|
2017-03-08 22:17:06 +03:00
|
|
|
TelemetryStopwatch.finish("FX_SANITIZE_DOWNLOADS", refObj);
|
2014-12-23 00:14:32 +03:00
|
|
|
}),
|
2008-09-07 10:54:06 +04:00
|
|
|
|
2017-08-01 18:43:56 +03:00
|
|
|
get canClear() {
|
2014-12-23 00:14:32 +03:00
|
|
|
return true;
|
2008-09-07 10:54:06 +04:00
|
|
|
}
|
|
|
|
},
|
2012-04-20 23:49:47 +04:00
|
|
|
|
2008-09-07 10:54:06 +04:00
|
|
|
passwords: {
|
2017-08-01 18:43:56 +03:00
|
|
|
clear: function() {
|
2014-06-19 11:04:00 +04:00
|
|
|
return new Promise(function(resolve, reject) {
|
|
|
|
Services.logins.removeAllLogins();
|
|
|
|
resolve();
|
|
|
|
});
|
2008-09-07 10:54:06 +04:00
|
|
|
},
|
2012-04-20 23:49:47 +04:00
|
|
|
|
2017-08-01 18:43:56 +03:00
|
|
|
get canClear() {
|
2012-03-20 03:51:29 +04:00
|
|
|
let count = Services.logins.countLogins("", "", ""); // count all logins
|
2008-09-07 10:54:06 +04:00
|
|
|
return (count > 0);
|
|
|
|
}
|
|
|
|
},
|
2012-04-20 23:49:47 +04:00
|
|
|
|
2008-09-07 10:54:06 +04:00
|
|
|
sessions: {
|
2017-08-01 18:43:56 +03:00
|
|
|
clear: function() {
|
2014-06-19 11:04:00 +04:00
|
|
|
return new Promise(function(resolve, reject) {
|
2017-03-08 22:17:06 +03:00
|
|
|
let refObj = {};
|
|
|
|
TelemetryStopwatch.start("FX_SANITIZE_SESSIONS", refObj);
|
|
|
|
|
2014-06-19 11:04:00 +04:00
|
|
|
// clear all auth tokens
|
|
|
|
var sdr = Cc["@mozilla.org/security/sdr;1"].getService(Ci.nsISecretDecoderRing);
|
|
|
|
sdr.logoutAndTeardown();
|
|
|
|
|
|
|
|
// clear FTP and plain HTTP auth sessions
|
2017-04-14 22:51:39 +03:00
|
|
|
Services.obs.notifyObservers(null, "net:clear-active-logins");
|
2008-09-07 10:54:06 +04:00
|
|
|
|
2017-03-08 22:17:06 +03:00
|
|
|
TelemetryStopwatch.finish("FX_SANITIZE_SESSIONS", refObj);
|
2014-06-19 11:04:00 +04:00
|
|
|
resolve();
|
|
|
|
});
|
2008-09-07 10:54:06 +04:00
|
|
|
},
|
2012-04-20 23:49:47 +04:00
|
|
|
|
2017-08-01 18:43:56 +03:00
|
|
|
get canClear() {
|
2008-09-07 10:54:06 +04:00
|
|
|
return true;
|
|
|
|
}
|
2015-05-04 15:08:31 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
syncedTabs: {
|
2017-08-01 18:43:56 +03:00
|
|
|
clear: function() {
|
Bug 1321418 - Use GekcoBundle events in GeckoApp/BrowserApp; r=snorp r=sebastian r=gbrown
Bug 1321418 - 1. Use GekcoBundle events in GeckoApp; r=snorp r=sebastian
Switch GeckoApp to using GeckoBundle events everywhere. UI or Gecko
events are used if the event requires the UI or Gecko thread,
respectively, and background events are used for all other events.
There are changes to some other Java classes, such as SnackbarBuilder
and GeckoAccessibility, due to the switch to GeckoBundle.
For "Snackbar:Show", we need the global EventDispatcher because the
event can be sent to both GeckoApp and GeckoPreferences. Howveer, we
only want one listener registered at the same time, so we register and
unregister in GeckoApp's and GeckoPreferences's onPause and onResume
methods.
Bug 1321418 - 2. Use appropriate JS EventDispatcher to send GeckoApp events; r=snorp r=sebastian
Change JS code that sends events to GeckoApp to use either the global
EventDispatcher or the per-window EventDispatcher.
"Session:StatePurged" is not used so it's removed. "Gecko:Ready" in
geckoview.js is not necessary because it's only used for GeckoApp, so
it's removed from geckoview.js.
Bug 1321418 - 3. Use GeckoBundle events in BrowserApp; r=snorp r=sebastian
Switch BrowserApp to using GeckoBundle events, in a similar vein as
GeckoApp. UI or Gecko events are used if the event handlers required UI
or Gecko thread, respectively, and background events are used for all
other events.
Some other Java classes also have to be modified as a result of
switching to GeckoBundle.
Bug 1321418 - 4. Use global EventDispatcher to send BrowserApp events; r=snorp r=sebastian
Change JS code that sends events to BrowserApp to use the global
EventDispatcher instead of "Messaging".
Bug 1321418 - 5. Update usages of events in tests; r=gbrown
Update cases where we use or wait for events in tests.
2016-12-09 20:32:45 +03:00
|
|
|
return EventDispatcher.instance.sendRequestForResult({ type: "Sanitize:ClearSyncedTabs" })
|
2015-05-04 15:08:31 +03:00
|
|
|
.catch(e => Cu.reportError("Java-side synced tabs clearing failed: " + e));
|
|
|
|
},
|
|
|
|
|
2017-08-01 18:43:56 +03:00
|
|
|
canClear: function(aCallback) {
|
2015-05-04 15:08:31 +03:00
|
|
|
Accounts.anySyncAccountsExist().then(aCallback)
|
|
|
|
.catch(function(err) {
|
2017-10-15 21:50:30 +03:00
|
|
|
Cu.reportError("Java-side synced tabs clearing failed: " + err);
|
2015-05-04 15:08:31 +03:00
|
|
|
aCallback(false);
|
|
|
|
});
|
|
|
|
}
|
2008-09-07 10:54:06 +04:00
|
|
|
}
|
2015-05-04 15:08:31 +03:00
|
|
|
|
2008-09-07 10:54:06 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-02-06 04:08:02 +04:00
|
|
|
this.Sanitizer = new Sanitizer();
|