defineModule("sanitizer", {
exports: ["Range", "Sanitizer", "sanitizer"],
use: ["config"],
- require: ["messages", "prefs", "services", "storage", "template", "util"],
+ require: ["messages", "prefs", "services", "storage", "template", "util"]
}, this);
let tmp = {};
get isEternity() this.max == null && this.min == null,
get isSession() this.max == null && this.min == sanitizer.sessionStart,
- get native() this.isEternity ? null : [range.min || 0, range.max == null ? Number.MAX_VALUE : range.max]
+ get native() this.isEternity ? null : [this.min || 0, this.max == null ? Number.MAX_VALUE : this.max]
});
var Item = Class("SanitizeItem", {
util.addObserver(this);
- services.add("contentprefs", "@mozilla.org/content-pref/service;1", Ci.nsIContentPrefService);
+ services.add("contentPrefs", "@mozilla.org/content-pref/service;1", Ci.nsIContentPrefService);
services.add("cookies", "@mozilla.org/cookiemanager;1", [Ci.nsICookieManager, Ci.nsICookieManager2,
Ci.nsICookieService]);
- services.add("loginmanager", "@mozilla.org/login-manager;1", Ci.nsILoginManager);
+ services.add("loginManager", "@mozilla.org/login-manager;1", Ci.nsILoginManager);
services.add("permissions", "@mozilla.org/permissionmanager;1", Ci.nsIPermissionManager);
this.itemMap = {};
action: function (range, host) {
if (host)
services.history.removePagesFromHost(host, true);
- else
- services.history.removeVisitsByTimeframe(this.range.min, this.range.max);
-
- if (!host)
+ else {
+ if (range.isEternity)
+ services.history.removeAllPages();
+ else
+ services.history.removeVisitsByTimeframe(range.native[0], Math.min(Date.now() * 1000, range.native[1])); // XXX
services.observer.notifyObservers(null, "browser:purge-session-history", "");
+ }
if (!host || util.isDomainURL(prefs.get("general.open_location.last_url"), host))
prefs.reset("general.open_location.last_url");
services.permissions.remove(util.createURI(p.host), p.type);
services.permissions.add(util.createURI(p.host), p.type, 0);
}
- for (let p in iter(services.contentprefs.getPrefs(util.createURI(host))))
- services.contentprefs.removePref(util.createURI(host), p.QueryInterface(Ci.nsIProperty).name);
+ for (let p in iter(services.contentPrefs.getPrefs(util.createURI(host))))
+ services.contentPrefs.removePref(util.createURI(host), p.QueryInterface(Ci.nsIProperty).name);
}
else {
// "Allow this site to open popups" ...
services.permissions.removeAll();
// Zoom level, ...
- services.contentprefs.removeGroupedPrefs();
+ services.contentPrefs.removeGroupedPrefs();
}
// "Never remember passwords" ...
- for each (let domain in services.loginmanager.getAllDisabledHosts())
+ for each (let domain in services.loginManager.getAllDisabledHosts())
if (!host || util.isSubdomain(domain, host))
- services.loginmanager.setLoginSavingEnabled(host, true);
+ services.loginManager.setLoginSavingEnabled(host, true);
},
override: true
});
append: {
SanitizeDialogPane:
<groupbox orient="horizontal" xmlns={XUL}>
- <caption label={config.appName + " (see :help privacy)"}/>
+ <caption label={config.appName + /*L*/" (see :help privacy)"}/>
<grid flex="1">
<columns><column flex="1"/><column flex="1"/></columns>
<rows>{
function (win) prefOverlay(branch, false, {
append: {
itemList: <>
- <listitem xmlns={XUL} label="See :help privacy for the following:" disabled="true" style="font-style: italic; font-weight: bold;"/>
+ <listitem xmlns={XUL} label={/*L*/"See :help privacy for the following:"} disabled="true" style="font-style: italic; font-weight: bold;"/>
{
template.map(ourItems(), function ([item, desc])
<listitem xmlns={XUL} type="checkbox"
}
},
+ firstRun: 0,
+
addItem: function addItem(name, params) {
let item = this.itemMap[name] || Item(name, params);
this.itemMap[name] = item;
if (!("value" in prop) || !callable(prop.value) && !(k in item))
Object.defineProperty(item, k, prop);
- let names = set([name].concat(params.contains || []).map(function (e) "clear-" + e));
+ let names = Set([name].concat(params.contains || []).map(function (e) "clear-" + e));
if (params.action)
storage.addObserver("sanitizer",
function (key, event, arg) {
deny: 2,
session: 8
},
+
UNPERMS: Class.memoize(function () iter(this.PERMS).map(Array.reverse).toObject()),
+
COMMANDS: {
- unset: "Unset",
- allow: "Allowed",
- deny: "Denied",
- session: "Allowed for the current session",
- list: "List all cookies for domain",
- clear: "Clear all cookies for domain",
- "clear-persistent": "Clear all persistent cookies for domain",
- "clear-session": "Clear all session cookies for domain"
+ unset: /*L*/"Unset",
+ allow: /*L*/"Allowed",
+ deny: /*L*/"Denied",
+ session: /*L*/"Allowed for the current session",
+ list: /*L*/"List all cookies for domain",
+ clear: /*L*/"Clear all cookies for domain",
+ "clear-persistent": /*L*/"Clear all persistent cookies for domain",
+ "clear-session": /*L*/"Clear all session cookies for domain"
},
argPrefMap: {
}
}, {
load: function (dactyl, modules, window) {
- if (sanitizer.runAtShutdown && !sanitizer.ranAtShutdown)
+ if (!sanitizer.firstRun++ && sanitizer.runAtShutdown && !sanitizer.ranAtShutdown)
sanitizer.sanitizeItems(null, Range(), null, "shutdown");
sanitizer.ranAtShutdown = false;
},
commands.add(["sa[nitize]"],
"Clear private data",
function (args) {
- dactyl.assert(!modules.options['private'], "Cannot sanitize items in private mode");
+ dactyl.assert(!modules.options['private'], _("command.sanitize.privateMode"));
let timespan = args["-timespan"] || modules.options["sanitizetimespan"];
args[0] = "all";
if (args.bang) {
- dactyl.assert(args.length == 0, _("error.trailing"));
+ dactyl.assert(args.length == 0, _("error.trailingCharacters"));
items = Object.keys(sanitizer.itemMap).filter(
function (k) modules.options.get("sanitizeitems").has(k));
}
else
- dactyl.assert(modules.options.get("sanitizeitems").validator(items), "Valid items required");
+ dactyl.assert(modules.options.get("sanitizeitems").validator(items), _("error.invalidArgument"));
+
+ function sanitize(items) {
+ sanitizer.range = range.native;
+ sanitizer.ignoreTimespan = range.min == null;
+ sanitizer.sanitizing = true;
+ if (args["-host"]) {
+ args["-host"].forEach(function (host) {
+ sanitizer.sanitizing = true;
+ sanitizer.sanitizeItems(items, range, host);
+ });
+ }
+ else
+ sanitizer.sanitize(items, range);
+ }
if (items.indexOf("all") >= 0)
- items = Object.keys(sanitizer.itemMap).filter(function (k) items.indexOf(k) === -1);
-
- sanitizer.range = range.native;
- sanitizer.ignoreTimespan = range.min == null;
- sanitizer.sanitizing = true;
- if (args["-host"]) {
- args["-host"].forEach(function (host) {
- sanitizer.sanitizing = true;
- sanitizer.sanitizeItems(items, range, host)
- });
- }
+ modules.commandline.input(_("sanitize.prompt.deleteAll") + " ",
+ function (resp) {
+ if (resp.match(/^y(es)?$/i)) {
+ items = Object.keys(sanitizer.itemMap).filter(function (k) items.indexOf(k) === -1);
+ sanitize(items);
+ dactyl.echo(_("command.sanitize.allDeleted"));
+ }
+ else
+ dactyl.echo(_("command.sanitize.noneDeleted"));
+ });
else
- sanitizer.sanitize(items, range);
+ sanitize(items);
+
},
{
argCount: "*", // FIXME: should be + and 0
!args["-host"].some(function (host) util.isSubdomain(item.text, host)));
modules.completion.domain(context);
},
- type: modules.CommandOption.LIST,
+ type: modules.CommandOption.LIST
}, {
names: ["-older", "-o"],
description: "Sanitize items older than timespan",
get values() values(sanitizer.itemMap).toArray(),
has: modules.Option.has.toggleAll,
validator: function (values) values.length &&
- values.every(function (val) val === "all" || set.has(sanitizer.itemMap, val))
+ values.every(function (val) val === "all" || Set.has(sanitizer.itemMap, val))
});
options.add(["sanitizeshutdown", "ss"],
sanitizer.runAtShutdown = false;
else {
sanitizer.runAtShutdown = true;
- let have = set(value);
+ let have = Set(value);
for (let item in values(sanitizer.itemMap))
prefs.set(item.shutdownPref,
- Boolean(set.has(have, item.name) ^ set.has(have, "all")));
+ Boolean(Set.has(have, item.name) ^ Set.has(have, "all")));
}
return value;
}
},
initialValue: true,
persist: false,
- validator: function (val) parseInt(val) == val || modules.Option.validateCompleter.call(this, val)
+ validator: function validator(val) parseInt(val) == val || validator.superapply(this, arguments)
});
}
});