Bug 436942 - URL Bar history should have a separate sanitize option
r/sr=neil a-SM2.0=KaiRo
This commit is contained in:
Родитель
fd57ed5bde
Коммит
ea7b5630e3
|
@ -525,6 +525,7 @@ pref("privacy.popups.showBrowserMessage", true);
|
|||
|
||||
// sanitize (clear private data) options
|
||||
pref("privacy.item.history", true);
|
||||
pref("privacy.item.urlbar", true);
|
||||
pref("privacy.item.formdata", true);
|
||||
pref("privacy.item.passwords", false);
|
||||
pref("privacy.item.downloads", true);
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
-
|
||||
- Contributor(s):
|
||||
- Terry Hayes <thayes@netscape.com>
|
||||
- Ian Neal <iann_bugzilla@blueyonder.co.uk>
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
|
@ -62,6 +63,9 @@
|
|||
<preference id="privacy.item.history"
|
||||
name="privacy.item.history"
|
||||
type="bool"/>
|
||||
<preference id="privacy.item.urlbar"
|
||||
name="privacy.item.urlbar"
|
||||
type="bool"/>
|
||||
<preference id="privacy.item.formdata"
|
||||
name="privacy.item.formdata"
|
||||
type="bool"/>
|
||||
|
@ -114,6 +118,9 @@
|
|||
<checkbox label="&itemHistory.label;"
|
||||
accesskey="&itemHistory.accesskey;"
|
||||
preference="privacy.item.history"/>
|
||||
<checkbox label="&itemUrlBar.label;"
|
||||
accesskey="&itemUrlBar.accesskey;"
|
||||
preference="privacy.item.urlbar"/>
|
||||
<checkbox label="&itemDownloads.label;"
|
||||
accesskey="&itemDownloads.accesskey;"
|
||||
preference="privacy.item.downloads"/>
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
- Ben Goodger <ben@mozilla.org>
|
||||
- Giorgio Maone <g.maone@informaction.com>
|
||||
- Robert Kaiser <kairo@kairo.at>
|
||||
- Ian Neal <iann_bugzilla@blueyonder.co.uk>
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
|
@ -107,6 +108,8 @@
|
|||
<preferences id="sanitizePreferences">
|
||||
<preference id="privacy.item.history" name="privacy.item.history"
|
||||
type="bool" readonly="true" onchange="onReadGeneric();"/>
|
||||
<preference id="privacy.item.urlbar" name="privacy.item.urlbar"
|
||||
type="bool" readonly="true" onchange="onReadGeneric();"/>
|
||||
<preference id="privacy.item.formdata" name="privacy.item.formdata"
|
||||
type="bool" readonly="true" onchange="onReadGeneric();"/>
|
||||
<preference id="privacy.item.passwords" name="privacy.item.passwords"
|
||||
|
@ -128,6 +131,9 @@
|
|||
<checkbox label="&itemHistory.label;"
|
||||
accesskey="&itemHistory.accesskey;"
|
||||
preference="privacy.item.history"/>
|
||||
<checkbox label="&itemUrlBar.label;"
|
||||
accesskey="&itemUrlBar.accesskey;"
|
||||
preference="privacy.item.urlbar"/>
|
||||
<checkbox label="&itemDownloads.label;"
|
||||
accesskey="&itemDownloads.accesskey;"
|
||||
preference="privacy.item.downloads"/>
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
<!ENTITY itemHistory.label "Browsing History">
|
||||
<!ENTITY itemHistory.accesskey "B">
|
||||
<!ENTITY itemUrlBar.label "Location Bar History">
|
||||
<!ENTITY itemUrlBar.accesskey "L">
|
||||
<!ENTITY itemDownloads.label "Download History">
|
||||
<!ENTITY itemDownloads.accesskey "D">
|
||||
<!ENTITY itemFormSearchHistory.label "Saved Form and Search History">
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
* Giorgio Maone <g.maone@informaction.com>
|
||||
* Ryan Flint <rflint@dslr.net>
|
||||
* Robert Kaiser <kairo@kairo.at>
|
||||
* Ian Neal <iann_bugzilla@blueyonder.co.uk>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
|
@ -177,7 +178,15 @@ var Sanitizer = {
|
|||
.getService(Components.interfaces.nsIObserverService);
|
||||
os.notifyObservers(null, "browser:purge-session-history", "");
|
||||
} catch(ex) {}
|
||||
},
|
||||
|
||||
// bug 347231: Always allow clearing history due to dependencies on
|
||||
// the browser:purge-session-history notification. (like error console)
|
||||
canClear: true
|
||||
},
|
||||
|
||||
urlbar: {
|
||||
clear: function() {
|
||||
// Clear last URL of the Open Web Location dialog
|
||||
var prefs = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch2);
|
||||
|
@ -194,9 +203,19 @@ var Sanitizer = {
|
|||
file.remove(false);
|
||||
},
|
||||
|
||||
// bug 347231: Always allow clearing history due to dependencies on
|
||||
// the browser:purge-session-history notification. (like error console)
|
||||
canClear: true
|
||||
get canClear() {
|
||||
var prefs = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch2);
|
||||
if (!prefs.prefIsLocked("general.open_location.last_url") &&
|
||||
prefs.prefHasUserValue("general.open_location.last_url"))
|
||||
return true;
|
||||
|
||||
var file = Components.classes["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Components.interfaces.nsIProperties)
|
||||
.get("ProfD", Components.interfaces.nsIFile);
|
||||
file.append("urlbarhistory.sqlite");
|
||||
return file.exists();
|
||||
}
|
||||
},
|
||||
|
||||
formdata: {
|
||||
|
|
|
@ -105,18 +105,46 @@ var sanTests = {
|
|||
|
||||
var history = Components.classes["@mozilla.org/browser/global-history;2"]
|
||||
.getService(Components.interfaces.nsIBrowserHistory);
|
||||
if (history.addPageWithDetails) {
|
||||
// toolkit history interfaces can be used
|
||||
history.addPageWithDetails(uri, "Sanitizer!", (new Date()).getTime());
|
||||
history.addPageWithDetails(uri, "Sanitizer!", Date.now());
|
||||
|
||||
return this.check();
|
||||
},
|
||||
|
||||
check: function() {
|
||||
var history = Components.classes["@mozilla.org/browser/nav-history-service;1"]
|
||||
.getService(Components.interfaces.nsINavHistoryService);
|
||||
var options = history.getNewQueryOptions();
|
||||
var query = history.getNewQuery();
|
||||
query.searchTerms = "Sanitizer!";
|
||||
var results = history.executeQuery(query, options).root;
|
||||
results.containerOpen = true;
|
||||
for (var i = 0; i < results.childCount; i++) {
|
||||
if (results.getChild(i).uri == "http://sanitizer.test/")
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
// old xpfe history implementation!
|
||||
history.removeAllPages();
|
||||
history.addURI(uri, false, true, null);
|
||||
history.setPageTitle(uri, "Sanitizer!");
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
urlbar: {
|
||||
desc: "Location bar history",
|
||||
setup: function() {
|
||||
// Create urlbarhistory file first otherwise tests will fail.
|
||||
var file = Components.classes["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Components.interfaces.nsIProperties)
|
||||
.get("ProfD", Components.interfaces.nsIFile);
|
||||
file.append("urlbarhistory.sqlite");
|
||||
if (!file.exists()) {
|
||||
var connection = Components.classes["@mozilla.org/storage/service;1"]
|
||||
.getService(Components.interfaces.mozIStorageService)
|
||||
.openDatabase(file);
|
||||
connection.createTable("urlbarhistory", "url TEXT");
|
||||
connection.executeSimpleSQL(
|
||||
"INSERT INTO urlbarhistory (url) VALUES ('Sanitizer')");
|
||||
connection.close();
|
||||
}
|
||||
|
||||
// Open location dialog
|
||||
// Open location dialog.
|
||||
var supStr = Components.classes["@mozilla.org/supports-string;1"]
|
||||
.createInstance(Components.interfaces.nsISupportsString);
|
||||
supStr.data = "Sanitizer!";
|
||||
|
@ -125,38 +153,44 @@ var sanTests = {
|
|||
this.prefs.setComplexValue("general.open_location.last_url",
|
||||
Components.interfaces.nsISupportsString, supStr);
|
||||
|
||||
return this.check();
|
||||
return this.check(true);
|
||||
},
|
||||
|
||||
check: function() {
|
||||
check: function(aCheckAll) {
|
||||
var locDialog = false;
|
||||
try {
|
||||
locDialog = (this.prefs.getComplexValue("general.open_location.last_url",
|
||||
Components.interfaces.nsISupportsString).data == "Sanitizer!");
|
||||
} catch(ex) {}
|
||||
|
||||
if (Components.classes["@mozilla.org/browser/nav-history-service;1"]) {
|
||||
// toolkit history interfaces can be used
|
||||
var history = Components.classes["@mozilla.org/browser/nav-history-service;1"]
|
||||
.getService(Components.interfaces.nsINavHistoryService);
|
||||
var options = history.getNewQueryOptions();
|
||||
var query = history.getNewQuery();
|
||||
query.searchTerms = "Sanitizer!";
|
||||
var results = history.executeQuery(query, options).root;
|
||||
results.containerOpen = true;
|
||||
for (var i = 0; i < results.childCount; i++) {
|
||||
if (results.getChild(i).uri == "http://sanitizer.test/" && locDialog)
|
||||
return true;
|
||||
}
|
||||
if (locDialog == !aCheckAll)
|
||||
return locDialog;
|
||||
|
||||
var file = Components.classes["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Components.interfaces.nsIProperties)
|
||||
.get("ProfD", Components.interfaces.nsIFile);
|
||||
file.append("urlbarhistory.sqlite");
|
||||
if (!file.exists())
|
||||
return false;
|
||||
|
||||
if (!aCheckAll)
|
||||
return true;
|
||||
|
||||
var connection = Components.classes["@mozilla.org/storage/service;1"]
|
||||
.getService(Components.interfaces.mozIStorageService)
|
||||
.openDatabase(file);
|
||||
var urlbar = connection.tableExists("urlbarhistory");
|
||||
if (urlbar) {
|
||||
var handle = connection.createStatement(
|
||||
"SELECT url FROM urlbarhistory");
|
||||
if (handle.executeStep())
|
||||
urlbar = (handle.getString(0) == "Sanitizer");
|
||||
handle.reset();
|
||||
handle.finalize();
|
||||
}
|
||||
else {
|
||||
// old xpfe history implementation, having any entry set is counted as true
|
||||
var history = Components.classes["@mozilla.org/browser/global-history;2"]
|
||||
.getService(Components.interfaces.nsIBrowserHistory);
|
||||
if (history.count)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
connection.close();
|
||||
|
||||
return urlbar;
|
||||
}
|
||||
},
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче