Bug 520165 - Part7: Provide a new preference to toggle history, r=mano ui-r=faaborg
This commit is contained in:
Родитель
06677ac8a7
Коммит
e56e0d2c8f
|
@ -784,6 +784,9 @@ pref("browser.sessionstore.max_resumed_crashes", 1);
|
|||
// allow META refresh by default
|
||||
pref("accessibility.blockautorefresh", false);
|
||||
|
||||
// Whether history is enabled or not.
|
||||
pref("places.history.enabled", true);
|
||||
|
||||
// The percentage of system memory that the Places database can use. Out of the
|
||||
// allowed cache size it will at most use the size of the database file.
|
||||
// Changes to this value are effective after an application restart.
|
||||
|
|
|
@ -56,7 +56,6 @@ var gPrivacyPane = {
|
|||
*/
|
||||
init: function ()
|
||||
{
|
||||
this._updateHistoryDaysUI();
|
||||
this._updateSanitizeSettingsButton();
|
||||
this.initializeHistoryMode();
|
||||
this.updateHistoryModePane();
|
||||
|
@ -78,8 +77,7 @@ var gPrivacyPane = {
|
|||
* Extensions adding their own preferences can append their IDs to this array if needed.
|
||||
*/
|
||||
prefsForDefault: [
|
||||
"browser.history_expire_days",
|
||||
"browser.history_expire_days_min",
|
||||
"places.history.enabled",
|
||||
"browser.download.manager.retention",
|
||||
"browser.formfill.enable",
|
||||
"network.cookie.cookieBehavior",
|
||||
|
@ -95,8 +93,7 @@ var gPrivacyPane = {
|
|||
* Extensions adding their own controls can append their IDs to this array if needed.
|
||||
*/
|
||||
dependentControls: [
|
||||
"rememberHistoryDays",
|
||||
"rememberAfter",
|
||||
"rememberHistory",
|
||||
"rememberDownloads",
|
||||
"rememberForms",
|
||||
"keepUntil",
|
||||
|
@ -174,11 +171,9 @@ var gPrivacyPane = {
|
|||
pref.value = false;
|
||||
|
||||
// select the remember history option if needed
|
||||
let rememberHistoryCheckbox = document.getElementById("rememberHistoryDays");
|
||||
if (!rememberHistoryCheckbox.checked) {
|
||||
let rememberHistoryCheckbox = document.getElementById("rememberHistory");
|
||||
if (!rememberHistoryCheckbox.checked)
|
||||
rememberHistoryCheckbox.checked = true;
|
||||
this.onchangeHistoryDaysCheck();
|
||||
}
|
||||
|
||||
// select the remember downloads option if needed
|
||||
if (!document.getElementById("rememberDownloads").checked)
|
||||
|
@ -224,9 +219,8 @@ var gPrivacyPane = {
|
|||
document.getElementById("privacy.sanitize.sanitizeOnShutdown").value;
|
||||
|
||||
// adjust the checked state of the remember history checkboxes
|
||||
document.getElementById("rememberHistoryDays").checked = disabled ? false :
|
||||
document.getElementById("browser.history_expire_days").value > 0;
|
||||
this.onchangeHistoryDaysCheck();
|
||||
document.getElementById("rememberHistory").checked = disabled ? false :
|
||||
document.getElementById("places.history.enabled").value;
|
||||
document.getElementById("rememberDownloads").checked = disabled ? false :
|
||||
this.readDownloadRetention();
|
||||
document.getElementById("rememberForms").checked = disabled ? false :
|
||||
|
@ -319,20 +313,8 @@ var gPrivacyPane = {
|
|||
/*
|
||||
* Preferences:
|
||||
*
|
||||
* NOTE: These first two are no longer shown in the UI. They're controlled
|
||||
* via the checkbox, which uses the zero state of the pref to turn
|
||||
* history off.
|
||||
* browser.history_expire_days
|
||||
* - the number of days of history to remember
|
||||
* browser.history_expire_days.mirror
|
||||
* - a preference whose value mirrors that of browser.history_expire_days, to
|
||||
* make the "days of history" checkbox easier to code
|
||||
*
|
||||
* browser.history_expire_days_min
|
||||
* - the mininum number of days of history to remember
|
||||
* browser.history_expire_days_min.mirror
|
||||
* - a preference whose value mirrors that of browser.history_expire_days_min
|
||||
* to make the "days of history" checkbox easier to code
|
||||
* places.history.enabled
|
||||
* - whether history is enabled or not
|
||||
* browser.formfill.enable
|
||||
* - true if entries in forms and the search bar should be saved, false
|
||||
* otherwise
|
||||
|
@ -345,58 +327,6 @@ var gPrivacyPane = {
|
|||
* 2 means never remove downloads
|
||||
*/
|
||||
|
||||
/**
|
||||
* Initializes the days-of-history mirror preference and connects it to the
|
||||
* days-of-history checkbox so that updates to the textbox are transmitted to
|
||||
* the real days-of-history preference.
|
||||
*/
|
||||
_updateHistoryDaysUI: function ()
|
||||
{
|
||||
var pref = document.getElementById("browser.history_expire_days");
|
||||
var mirror = document.getElementById("browser.history_expire_days.mirror");
|
||||
var pref_min = document.getElementById("browser.history_expire_days_min");
|
||||
var textbox = document.getElementById("historyDays");
|
||||
var checkbox = document.getElementById("rememberHistoryDays");
|
||||
|
||||
// handle mirror non-existence or mirror/pref unsync
|
||||
if (mirror.value === null || mirror.value != pref.value ||
|
||||
(mirror.value == pref.value && mirror.value == 0) )
|
||||
mirror.value = pref.value ? pref.value : pref.defaultValue;
|
||||
|
||||
checkbox.checked = (pref.value > 0);
|
||||
textbox.disabled = !checkbox.checked;
|
||||
},
|
||||
|
||||
/**
|
||||
* Responds to the checking or unchecking of the days-of-history UI, storing
|
||||
* the appropriate value to the days-of-history preference and enabling or
|
||||
* disabling the number textbox as appropriate.
|
||||
*/
|
||||
onchangeHistoryDaysCheck: function ()
|
||||
{
|
||||
var pref = document.getElementById("browser.history_expire_days");
|
||||
var mirror = document.getElementById("browser.history_expire_days.mirror");
|
||||
var textbox = document.getElementById("historyDays");
|
||||
var checkbox = document.getElementById("rememberHistoryDays");
|
||||
|
||||
if (!this._autoStartPrivateBrowsing)
|
||||
pref.value = checkbox.checked ? mirror.value : 0;
|
||||
textbox.disabled = !checkbox.checked;
|
||||
},
|
||||
|
||||
/**
|
||||
* Responds to changes in the days-of-history textbox,
|
||||
* unchecking the history-enabled checkbox if the days
|
||||
* value is zero.
|
||||
*/
|
||||
onkeyupHistoryDaysText: function ()
|
||||
{
|
||||
var textbox = document.getElementById("historyDays");
|
||||
var checkbox = document.getElementById("rememberHistoryDays");
|
||||
|
||||
checkbox.checked = textbox.value != 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* Converts the value of the browser.download.manager.retention preference
|
||||
* into a Boolean value. "remove on close" and "don't remember" both map
|
||||
|
|
|
@ -76,15 +76,9 @@
|
|||
onchange="document.getElementById('browser.urlbar.autocomplete.enabled').updateElements();"/>
|
||||
|
||||
<!-- History -->
|
||||
<preference id="browser.history_expire_days"
|
||||
name="browser.history_expire_days"
|
||||
type="int"/>
|
||||
<preference id="browser.history_expire_days.mirror"
|
||||
name="browser.history_expire_days.mirror"
|
||||
type="int"/>
|
||||
<preference id="browser.history_expire_days_min"
|
||||
name="browser.history_expire_days_min"
|
||||
type="int"/>
|
||||
<preference id="places.history.enabled"
|
||||
name="places.history.enabled"
|
||||
type="bool"/>
|
||||
<preference id="browser.formfill.enable"
|
||||
name="browser.formfill.enable"
|
||||
type="bool"/>
|
||||
|
@ -184,18 +178,10 @@
|
|||
|
||||
<vbox class="indent">
|
||||
<vbox class="indent">
|
||||
<hbox align="center">
|
||||
<checkbox id="rememberHistoryDays"
|
||||
label="&rememberHistory.pre.label;"
|
||||
accesskey="&rememberHistory.pre.accesskey;"
|
||||
oncommand="gPrivacyPane.onchangeHistoryDaysCheck();"
|
||||
aria-labelledby="rememberHistoryDays historyDays rememberAfter"/>
|
||||
<textbox id="historyDays" type="number" size="3"
|
||||
aria-labelledby="rememberHistoryDays historyDays rememberAfter"
|
||||
onkeyup="gPrivacyPane.onkeyupHistoryDaysText();"
|
||||
preference="browser.history_expire_days_min"/>
|
||||
<label id="rememberAfter"> &rememberHistory.post.label;</label>
|
||||
</hbox>
|
||||
<checkbox id="rememberHistory"
|
||||
label="&rememberHistory.label;"
|
||||
accesskey="&rememberHistory.accesskey;"
|
||||
preference="places.history.enabled"/>
|
||||
<checkbox id="rememberDownloads"
|
||||
label="&rememberDownload.label;"
|
||||
accesskey="&rememberDownload.accesskey;"
|
||||
|
|
|
@ -41,10 +41,8 @@ function test() {
|
|||
loader.loadSubScript("chrome://mochikit/content/browser/browser/components/preferences/tests/privacypane_tests.js", this);
|
||||
|
||||
run_test_subset([
|
||||
test_custom_retention("rememberHistoryDays", "remember"),
|
||||
test_custom_retention("rememberHistoryDays", "custom"),
|
||||
test_custom_retention("historyDays", "remember", 1),
|
||||
test_custom_retention("historyDays", "custom", -1),
|
||||
test_custom_retention("rememberHistory", "remember"),
|
||||
test_custom_retention("rememberHistory", "custom"),
|
||||
test_custom_retention("rememberDownloads", "remember"),
|
||||
test_custom_retention("rememberDownloads", "custom"),
|
||||
test_custom_retention("rememberForms", "remember"),
|
||||
|
|
|
@ -107,9 +107,7 @@ function test_dependent_elements(win) {
|
|||
let pbautostart = win.document.getElementById("privateBrowsingAutoStart");
|
||||
ok(pbautostart, "the private browsing auto-start checkbox should exist");
|
||||
let controls = [
|
||||
win.document.getElementById("rememberHistoryDays"),
|
||||
win.document.getElementById("historyDays"),
|
||||
win.document.getElementById("rememberAfter"),
|
||||
win.document.getElementById("rememberHistory"),
|
||||
win.document.getElementById("rememberDownloads"),
|
||||
win.document.getElementById("rememberForms"),
|
||||
win.document.getElementById("keepUntil"),
|
||||
|
@ -132,7 +130,7 @@ function test_dependent_elements(win) {
|
|||
ok(keepuntil, "the keep cookies until menulist should exist");
|
||||
let alwaysclear = win.document.getElementById("alwaysClear");
|
||||
ok(alwaysclear, "the clear data on close checkbox should exist");
|
||||
let rememberhistory = win.document.getElementById("rememberHistoryDays");
|
||||
let rememberhistory = win.document.getElementById("rememberHistory");
|
||||
ok(rememberhistory, "the remember history checkbox should exist");
|
||||
let rememberdownloads = win.document.getElementById("rememberDownloads");
|
||||
ok(rememberdownloads, "the remember downloads checkbox should exist");
|
||||
|
@ -319,7 +317,7 @@ function test_dependent_prefs(win) {
|
|||
let historymode = win.document.getElementById("historyMode");
|
||||
ok(historymode, "history mode menulist should exist");
|
||||
let controls = [
|
||||
win.document.getElementById("rememberHistoryDays"),
|
||||
win.document.getElementById("rememberHistory"),
|
||||
win.document.getElementById("rememberDownloads"),
|
||||
win.document.getElementById("rememberForms"),
|
||||
win.document.getElementById("acceptCookies"),
|
||||
|
|
|
@ -60,15 +60,8 @@
|
|||
<!ENTITY privateBrowsingPermanent.label "Permanent Private Browsing mode">
|
||||
<!ENTITY privateBrowsingPermanent.accesskey "P">
|
||||
|
||||
<!-- LOCALIZATION NOTE:
|
||||
The entities rememberHistory.pre.label and rememberHistory.post.label appear on a single
|
||||
line in preferences as follows:
|
||||
|
||||
&rememberHistory.pre.label [ textbox for number of days ] &rememberHistory.post.label;
|
||||
-->
|
||||
<!ENTITY rememberHistory.pre.label "Remember my browsing history for at least">
|
||||
<!ENTITY rememberHistory.pre.accesskey "b">
|
||||
<!ENTITY rememberHistory.post.label "days">
|
||||
<!ENTITY rememberHistory.label "Remember my browsing history">
|
||||
<!ENTITY rememberHistory.accesskey "b">
|
||||
|
||||
<!ENTITY rememberDownload.label "Remember download history">
|
||||
<!ENTITY rememberDownload.accesskey "d">
|
||||
|
|
|
@ -1459,7 +1459,7 @@ interface nsINavHistoryService : nsISupports
|
|||
|
||||
/**
|
||||
* True if history is disabled. currently,
|
||||
* history is disabled if the browser.history_expire_days pref is 0
|
||||
* history is disabled if the places.history.enabled pref is false.
|
||||
*/
|
||||
readonly attribute boolean historyDisabled;
|
||||
|
||||
|
|
|
@ -104,6 +104,8 @@ using namespace mozilla::places;
|
|||
// preference ID strings
|
||||
#define PREF_BRANCH_BASE "browser."
|
||||
|
||||
#define PREF_HISTORY_ENABLED "places.history.enabled"
|
||||
|
||||
#define PREF_BROWSER_HISTORY_EXPIRE_DAYS_MIN "history_expire_days_min"
|
||||
#define PREF_BROWSER_HISTORY_EXPIRE_DAYS_MAX "history_expire_days"
|
||||
#define PREF_BROWSER_HISTORY_EXPIRE_SITES "history_expire_sites"
|
||||
|
@ -399,6 +401,7 @@ nsNavHistory::nsNavHistory()
|
|||
, mExpireDaysMin(0)
|
||||
, mExpireDaysMax(0)
|
||||
, mExpireSites(0)
|
||||
, mHistoryEnabled(PR_TRUE)
|
||||
, mNumVisitsForFrecency(10)
|
||||
, mTagsFolder(-1)
|
||||
, mInPrivateBrowsing(PRIVATEBROWSING_NOTINITED)
|
||||
|
@ -499,6 +502,11 @@ nsNavHistory::Init()
|
|||
pbi->AddObserver(PREF_BROWSER_HISTORY_EXPIRE_SITES, this, PR_FALSE);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrefBranch2> prefs =
|
||||
do_GetService("@mozilla.org/preferences-service;1");
|
||||
if (prefs)
|
||||
prefs->AddObserver(PREF_HISTORY_ENABLED, this, PR_FALSE);
|
||||
|
||||
nsCOMPtr<nsIObserverService> obsSvc =
|
||||
do_GetService(NS_OBSERVERSERVICE_CONTRACTID);
|
||||
if (obsSvc) {
|
||||
|
@ -2049,6 +2057,8 @@ nsNavHistory::LoadPrefs(PRBool aInitializing)
|
|||
// get the frecency prefs
|
||||
nsCOMPtr<nsIPrefBranch> prefs(do_GetService("@mozilla.org/preferences-service;1"));
|
||||
if (prefs) {
|
||||
prefs->GetBoolPref(PREF_HISTORY_ENABLED, &mHistoryEnabled);
|
||||
|
||||
prefs->GetIntPref(PREF_FRECENCY_NUM_VISITS,
|
||||
&mNumVisitsForFrecency);
|
||||
prefs->GetIntPref(PREF_FRECENCY_FIRST_BUCKET_CUTOFF,
|
||||
|
@ -5534,8 +5544,18 @@ nsNavHistory::Observe(nsISupports *aSubject, const char *aTopic,
|
|||
|
||||
nsCOMPtr<nsIPrefService> prefService =
|
||||
do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||
if (prefService)
|
||||
if (prefService) {
|
||||
prefService->SavePrefFile(nsnull);
|
||||
nsCOMPtr<nsIPrefBranch2> prefs = do_QueryInterface(prefService);
|
||||
prefs->RemoveObserver(PREF_HISTORY_ENABLED, this);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrefBranch2> pbi = do_QueryInterface(mPrefBranch);
|
||||
if (pbi) {
|
||||
pbi->RemoveObserver(PREF_BROWSER_HISTORY_EXPIRE_DAYS_MAX, this);
|
||||
pbi->RemoveObserver(PREF_BROWSER_HISTORY_EXPIRE_DAYS_MIN, this);
|
||||
pbi->RemoveObserver(PREF_BROWSER_HISTORY_EXPIRE_SITES, this);
|
||||
}
|
||||
|
||||
// Start shutdown expiration.
|
||||
mExpire->OnQuit();
|
||||
|
|
|
@ -213,8 +213,10 @@ public:
|
|||
nsACString& aResult);
|
||||
void GetMonthName(PRInt32 aIndex, nsACString& aResult);
|
||||
|
||||
// returns true if history has been disabled
|
||||
PRBool IsHistoryDisabled() { return mExpireDaysMax == 0 || InPrivateBrowsingMode(); }
|
||||
// Returns whether history is enabled or not.
|
||||
PRBool IsHistoryDisabled() {
|
||||
return mExpireDaysMax == 0 || !mHistoryEnabled || InPrivateBrowsingMode();
|
||||
}
|
||||
|
||||
// Constants for the columns returned by the above statement.
|
||||
static const PRInt32 kGetInfoIndex_PageID;
|
||||
|
@ -660,6 +662,10 @@ protected:
|
|||
PRInt32 mExpireDaysMax;
|
||||
PRInt32 mExpireSites;
|
||||
|
||||
// Whether history is enabled or not.
|
||||
// Will mimic value of the places.history.enabled preference.
|
||||
PRBool mHistoryEnabled;
|
||||
|
||||
// Frecency preferences.
|
||||
PRInt32 mNumVisitsForFrecency;
|
||||
PRInt32 mFirstBucketCutoffInDays;
|
||||
|
|
|
@ -91,12 +91,12 @@ var tests = [
|
|||
// go: function go4() {
|
||||
// // disable history
|
||||
// var prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
|
||||
// prefs.setIntPref("browser.history_expire_days", 0);
|
||||
// prefs.setBoolPref("places.history.enabled", false);
|
||||
//
|
||||
// iconsvc.setAndLoadFaviconForPage(this.pageURI, favicons[0].uri, true);
|
||||
//
|
||||
// try {
|
||||
// prefs.clearUserPref("browser.history_expire_days");
|
||||
// prefs.clearUserPref("places.history.enabled");
|
||||
// } catch (ex) {}
|
||||
// },
|
||||
// check: function check4() {
|
||||
|
@ -111,7 +111,7 @@ var tests = [
|
|||
go: function go5() {
|
||||
// disable history
|
||||
var prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
|
||||
prefs.setIntPref("browser.history_expire_days", 0);
|
||||
prefs.setBoolPref("places.history.enabled", false);
|
||||
|
||||
// Add as bookmark
|
||||
addBookmark(this.pageURI);
|
||||
|
@ -119,7 +119,7 @@ var tests = [
|
|||
iconsvc.setAndLoadFaviconForPage(this.pageURI, this.favicon.uri, true);
|
||||
|
||||
try {
|
||||
prefs.clearUserPref("browser.history_expire_days");
|
||||
prefs.clearUserPref("places.history.enabled");
|
||||
} catch (ex) {}
|
||||
},
|
||||
check: function check5() {
|
||||
|
|
|
@ -52,7 +52,7 @@ var dh = Cc["@mozilla.org/browser/download-history;1"].
|
|||
do_check_true(dh instanceof Ci.nsINavHistoryService);
|
||||
|
||||
const NS_LINK_VISITED_EVENT_TOPIC = "link-visited";
|
||||
const DISABLE_HISTORY_PREF = "browser.history_expire_days";
|
||||
const ENABLE_HISTORY_PREF = "places.history.enabled";
|
||||
const PB_KEEP_SESSION_PREF = "browser.privatebrowsing.keep_current_session";
|
||||
|
||||
var testURI = uri("http://google.com/");
|
||||
|
@ -115,7 +115,7 @@ function test_dh_privateBrowsing() {
|
|||
|
||||
function test_dh_disabledHistory() {
|
||||
// Disable history
|
||||
prefs.setIntPref(DISABLE_HISTORY_PREF, 0);
|
||||
prefs.setBoolPref(ENABLE_HISTORY_PREF, false);
|
||||
|
||||
dh.addDownload(testURI, referrerURI, Date.now() * 1000);
|
||||
|
||||
|
@ -124,7 +124,7 @@ function test_dh_disabledHistory() {
|
|||
uri_in_db(referrerURI, false);
|
||||
|
||||
// Cleanup
|
||||
prefs.setIntPref(DISABLE_HISTORY_PREF, 180);
|
||||
prefs.setBoolPref(ENABLE_HISTORY_PREF, true);
|
||||
}
|
||||
|
||||
var tests = [
|
||||
|
|
|
@ -183,7 +183,7 @@ function run_test() {
|
|||
do_check_eq(result.root.childCount, 1);
|
||||
do_check_eq(result.root.getChild(0).uri, "http://google.com/");
|
||||
|
||||
// by default, browser.history_expire_days is 9
|
||||
// By default history is enabled.
|
||||
do_check_true(!histsvc.historyDisabled);
|
||||
|
||||
// test getPageTitle
|
||||
|
|
Загрузка…
Ссылка в новой задаче