Bug 1091260 - Badge the Browser Toolbox dock icon on OS X to differentiate it from the main process. r=jryans,fitzgen
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Wed, 05 Nov 2014 13:56:17 -0800
changeset 214216 ff1606d46388c9cf9b2d3b5a21788e96478fbb58
parent 214215 758d1cb4568b040fef053843c7afc23b418fa215
child 214217 6d819f81dcbd8e4620493e123243d4f38570d708
push id9801
push usermozilla@noorenberghe.ca
push dateThu, 06 Nov 2014 00:51:33 +0000
treeherderfx-team@4d284c7760bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjryans, fitzgen
bugs1091260
milestone36.0a1
Bug 1091260 - Badge the Browser Toolbox dock icon on OS X to differentiate it from the main process. r=jryans,fitzgen
browser/devtools/framework/moz.build
browser/devtools/framework/toolbox-process-window.js
browser/devtools/jar.mn
--- a/browser/devtools/framework/moz.build
+++ b/browser/devtools/framework/moz.build
@@ -13,11 +13,10 @@ EXTRA_JS_MODULES.devtools += [
 
 EXTRA_JS_MODULES.devtools.framework += [
     'selection.js',
     'sidebar.js',
     'target.js',
     'toolbox-highlighter-utils.js',
     'toolbox-hosts.js',
     'toolbox-options.js',
-    'toolbox-process-window.js',
     'toolbox.js',
 ]
--- a/browser/devtools/framework/toolbox-process-window.js
+++ b/browser/devtools/framework/toolbox-process-window.js
@@ -87,16 +87,47 @@ function onNewToolbox(toolbox) {
    gToolbox = toolbox;
    bindToolboxHandlers();
    raise();
 }
 
 function bindToolboxHandlers() {
   gToolbox.once("destroyed", quitApp);
   window.addEventListener("unload", onUnload);
+
+#ifdef XP_MACOSX
+  // Badge the dock icon to differentiate this process from the main application process.
+  updateBadgeText(false);
+
+  // Check if the debugger panel is already loaded otherwise listen for it to be.
+  if (gToolbox.getPanel("jsdebugger")) {
+    setupThreadListeners(gToolbox.getPanel("jsdebugger"));
+  } else {
+    gToolbox.once("jsdebugger-ready", (e, panel) => setupThreadListeners(panel));
+  }
+#endif
+}
+
+function setupThreadListeners(panel) {
+  updateBadgeText(panel._controller.activeThread.state == "paused");
+
+  let onPaused = updateBadgeText.bind(null, true);
+  let onResumed = updateBadgeText.bind(null, false);
+  panel.target.on("thread-paused", onPaused);
+  panel.target.on("thread-resumed", onResumed);
+
+  panel.once("destroyed", () => {
+    panel.off("thread-paused", onPaused);
+    panel.off("thread-resumed", onResumed);
+  });
+}
+
+function updateBadgeText(paused) {
+  let dockSupport = Cc["@mozilla.org/widget/macdocksupport;1"].getService(Ci.nsIMacDockSupport);
+  dockSupport.badgeText = paused ? "▐▐ " : " ▶";
 }
 
 function onUnload() {
   window.removeEventListener("unload", onUnload);
   window.removeEventListener("message", onMessage);
   let cmdClose = document.getElementById("toolbox-cmd-close");
   cmdClose.removeEventListener("command", onCloseCommand);
   gToolbox.destroy();
--- a/browser/devtools/jar.mn
+++ b/browser/devtools/jar.mn
@@ -97,17 +97,17 @@ browser.jar:
     content/browser/devtools/commandlinetooltip.xhtml                  (commandline/commandlinetooltip.xhtml)
     content/browser/devtools/commandline/commands-index.js             (commandline/commands-index.js)
     content/browser/devtools/framework/toolbox-window.xul              (framework/toolbox-window.xul)
     content/browser/devtools/framework/toolbox-options.xul             (framework/toolbox-options.xul)
     content/browser/devtools/framework/toolbox-options.js              (framework/toolbox-options.js)
     content/browser/devtools/framework/toolbox.xul                     (framework/toolbox.xul)
     content/browser/devtools/framework/options-panel.css               (framework/options-panel.css)
     content/browser/devtools/framework/toolbox-process-window.xul      (framework/toolbox-process-window.xul)
-    content/browser/devtools/framework/toolbox-process-window.js       (framework/toolbox-process-window.js)
+*   content/browser/devtools/framework/toolbox-process-window.js       (framework/toolbox-process-window.js)
     content/browser/devtools/framework/dev-edition-promo.xul           (framework/dev-edition-promo/dev-edition-promo.xul)
     content/browser/devtools/framework/dev-edition-promo.css           (framework/dev-edition-promo/dev-edition-promo.css)
     content/browser/devtools/framework/dev-edition-logo.png            (framework/dev-edition-promo/dev-edition-logo.png)
     content/browser/devtools/inspector/inspector.xul                   (inspector/inspector.xul)
     content/browser/devtools/inspector/inspector.css                   (inspector/inspector.css)
     content/browser/devtools/connect.xhtml                             (framework/connect/connect.xhtml)
     content/browser/devtools/connect.css                               (framework/connect/connect.css)
     content/browser/devtools/connect.js                                (framework/connect/connect.js)