Bug 1472491: Part 5ε - Add PurgeSessionHistoryChild actor. r=mconley

MozReview-Commit-ID: 7oOXuPNsPPG

--HG--
extra : rebase_source : 696b840ba75fc23ec76b6c9e217a1d3b84107871
This commit is contained in:
Kris Maglione 2018-07-30 10:14:12 -07:00
Родитель f66f1e4480
Коммит aba57b7011
4 изменённых файлов: 49 добавлений и 24 удалений

Просмотреть файл

@ -0,0 +1,39 @@
/* vim: set ts=2 sw=2 sts=2 et tw=80: */
/* 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/. */
"use strict";
var EXPORTED_SYMBOLS = ["PurgeSessionHistoryChild"];
ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
class PurgeSessionHistoryChild extends ActorChild {
receiveMessage(message) {
if (message.name != "Browser:PurgeSessionHistory") {
return;
}
let sessionHistory = this.docShell.QueryInterface(Ci.nsIWebNavigation).sessionHistory;
if (!sessionHistory) {
return;
}
// place the entry at current index at the end of the history list, so it won't get removed
if (sessionHistory.index < sessionHistory.count - 1) {
let legacy = sessionHistory.legacySHistory;
legacy.QueryInterface(Ci.nsISHistoryInternal);
let indexEntry = legacy.getEntryAtIndex(sessionHistory.index, false);
indexEntry.QueryInterface(Ci.nsISHEntry);
legacy.addEntry(indexEntry, true);
}
let purge = sessionHistory.count;
if (this.content.location.href != "about:blank") {
--purge; // Don't remove the page the user's staring at from shistory
}
if (purge > 0) {
sessionHistory.legacySHistory.PurgeHistory(purge);
}
}
}

Просмотреть файл

@ -10,6 +10,7 @@ FINAL_TARGET_FILES.actors += [
'FindBarChild.jsm',
'PopupBlockingChild.jsm',
'PrintingChild.jsm',
'PurgeSessionHistoryChild.jsm',
'SelectChild.jsm',
'SelectionSourceChild.jsm',
'ThumbnailsChild.jsm',

Просмотреть файл

@ -46,30 +46,6 @@ var AutoScrollListener = {
};
Services.els.addSystemEventListener(global, "mousedown", AutoScrollListener, true);
addMessageListener("Browser:PurgeSessionHistory", function BrowserPurgeHistory() {
let sessionHistory = docShell.QueryInterface(Ci.nsIWebNavigation).sessionHistory;
if (!sessionHistory) {
return;
}
// place the entry at current index at the end of the history list, so it won't get removed
if (sessionHistory.index < sessionHistory.count - 1) {
let legacy = sessionHistory.legacySHistory;
legacy.QueryInterface(Ci.nsISHistoryInternal);
let indexEntry = legacy.getEntryAtIndex(sessionHistory.index, false);
indexEntry.QueryInterface(Ci.nsISHEntry);
legacy.addEntry(indexEntry, true);
}
let purge = sessionHistory.count;
if (global.content.location.href != "about:blank") {
--purge; // Don't remove the page the user's staring at from shistory
}
if (purge > 0) {
sessionHistory.legacySHistory.PurgeHistory(purge);
}
});
let AutoComplete = {
_connected: false,

Просмотреть файл

@ -156,6 +156,15 @@ let ACTORS = {
},
},
PurgeSessionHistory: {
child: {
module: "resource://gre/actors/PurgeSessionHistoryChild.jsm",
messages: [
"Browser:PurgeSessionHistory",
],
},
},
Select: {
child: {
module: "resource://gre/actors/SelectChild.jsm",