summaryrefslogtreecommitdiffstats
path: root/devtools/client/webconsole/hudservice.js
diff options
context:
space:
mode:
authorMoonchild <mcwerewolf@gmail.com>2018-03-02 10:32:45 +0100
committerGitHub <noreply@github.com>2018-03-02 10:32:45 +0100
commite272829137195b46612b7664c9416364089f7baa (patch)
tree20b543048260952a2c4ac8bb4cb22aaaa684bd84 /devtools/client/webconsole/hudservice.js
parentba2c2e5301bb2d993984c62cdf2fd07b361e6bca (diff)
parentc8355b22c047c9737e32f096b816edbb8b0fa181 (diff)
downloadUXP-e272829137195b46612b7664c9416364089f7baa.tar
UXP-e272829137195b46612b7664c9416364089f7baa.tar.gz
UXP-e272829137195b46612b7664c9416364089f7baa.tar.lz
UXP-e272829137195b46612b7664c9416364089f7baa.tar.xz
UXP-e272829137195b46612b7664c9416364089f7baa.zip
Merge pull request #34 from janekptacijarabaci/devtools_import-from-moebius_1
Port across devtools enhancements
Diffstat (limited to 'devtools/client/webconsole/hudservice.js')
-rw-r--r--devtools/client/webconsole/hudservice.js58
1 files changed, 47 insertions, 11 deletions
diff --git a/devtools/client/webconsole/hudservice.js b/devtools/client/webconsole/hudservice.js
index 46b4f2a13..3023b7bb3 100644
--- a/devtools/client/webconsole/hudservice.js
+++ b/devtools/client/webconsole/hudservice.js
@@ -51,6 +51,23 @@ HUD_SERVICE.prototype =
*/
consoles: null,
+ _browerConsoleSessionState: false,
+ storeBrowserConsoleSessionState() {
+ this._browerConsoleSessionState = !!this.getBrowserConsole();
+ },
+ getBrowserConsoleSessionState() {
+ return this._browerConsoleSessionState;
+ },
+
+ /**
+ * Restore the Browser Console as provided by SessionStore.
+ */
+ restoreBrowserConsoleSession: function HS_restoreBrowserConsoleSession() {
+ if (!HUDService.getBrowserConsole()) {
+ HUDService.toggleBrowserConsole();
+ }
+ },
+
/**
* Assign a function to this property to listen for every request that
* completes. Used by unit tests. The callback takes one argument: the HTTP
@@ -647,6 +664,9 @@ BrowserConsole.prototype = extend(WebConsole.prototype, {
return this._bc_init;
}
+ // Only add the shutdown observer if we've opened a Browser Console window.
+ ShutdownObserver.init();
+
this.ui._filterPrefsPrefix = BROWSER_CONSOLE_FILTER_PREFS_PREFIX;
let window = this.iframeWindow;
@@ -703,16 +723,32 @@ BrowserConsole.prototype = extend(WebConsole.prototype, {
});
const HUDService = new HUD_SERVICE();
+exports.HUDService = HUDService;
-(() => {
- let methods = ["openWebConsole", "openBrowserConsole",
- "toggleBrowserConsole", "getOpenWebConsole",
- "getBrowserConsole", "getHudByWindow",
- "openBrowserConsoleOrFocus", "getHudReferenceById"];
- for (let method of methods) {
- exports[method] = HUDService[method].bind(HUDService);
- }
+/**
+ * The ShutdownObserver listens for app shutdown and saves the current state
+ * of the Browser Console for session restore.
+ */
+var ShutdownObserver = {
+ _initialized: false,
+ init() {
+ if (this._initialized) {
+ return;
+ }
+
+ Services.obs.addObserver(this, "quit-application-granted", false);
+
+ this._initialized = true;
+ },
- exports.consoles = HUDService.consoles;
- exports.lastFinishedRequest = HUDService.lastFinishedRequest;
-})();
+ observe(message, topic) {
+ if (topic == "quit-application-granted") {
+ HUDService.storeBrowserConsoleSessionState();
+ this.uninit();
+ }
+ },
+
+ uninit() {
+ Services.obs.removeObserver(this, "quit-application-granted");
+ }
+};