Bug 1472491: Part 5ε - Add PurgeSessionHistoryChild actor. r=mconley
MozReview-Commit-ID: 7oOXuPNsPPG
new file mode 100644
--- /dev/null
+++ b/toolkit/actors/PurgeSessionHistoryChild.jsm
@@ -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);
+ }
+ }
+}
--- a/toolkit/actors/moz.build
+++ b/toolkit/actors/moz.build
@@ -6,15 +6,16 @@
FINAL_TARGET_FILES.actors += [
'AudioPlaybackChild.jsm',
'DateTimePickerChild.jsm',
'ExtFindChild.jsm',
'FindBarChild.jsm',
'PopupBlockingChild.jsm',
'PrintingChild.jsm',
+ 'PurgeSessionHistoryChild.jsm',
'SelectChild.jsm',
'SelectionSourceChild.jsm',
'ThumbnailsChild.jsm',
'UnselectedTabHoverChild.jsm',
'WebChannelChild.jsm',
'ZoomChild.jsm',
]
--- a/toolkit/content/browser-content.js
+++ b/toolkit/content/browser-content.js
@@ -39,40 +39,16 @@ var AutoScrollListener = {
this._controller = new AutoScrollController(global);
}
this._controller.handleEvent(event);
}
}
};
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,
init() {
addEventListener("unload", this, {once: true});
addEventListener("DOMContentLoaded", this, {once: true});
// WebExtension browserAction is preloaded and does not receive DCL, wait
--- a/toolkit/modules/ActorManagerParent.jsm
+++ b/toolkit/modules/ActorManagerParent.jsm
@@ -161,16 +161,25 @@ let ACTORS = {
"Printing:Preview:Exit",
"Printing:Preview:Navigate",
"Printing:Preview:ParseDocument",
"Printing:Print",
],
},
},
+ PurgeSessionHistory: {
+ child: {
+ module: "resource://gre/actors/PurgeSessionHistoryChild.jsm",
+ messages: [
+ "Browser:PurgeSessionHistory",
+ ],
+ },
+ },
+
Select: {
child: {
module: "resource://gre/actors/SelectChild.jsm",
events: {
"mozshowdropdown": {},
"mozshowdropdown-sourcetouch": {},
},
},