Bug 1091260 - Badge the Browser Toolbox dock icon on OS X to differentiate it from the main process. r=jryans,fitzgen
☠☠ backed out by 8047f8b92715 ☠ ☠
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Tue, 04 Nov 2014 16:44:41 -0800
changeset 213852 ec34b5a1552ca9ce5a81e096ecc4846d20b34f2c
parent 213851 6affd0c19f6bf0acc240e3fae38a44cd47caae8e
child 213853 fb9269729f51f7c4ce7ff495c91bb18513a6bf8b
push id9768
push usermozilla@noorenberghe.ca
push dateWed, 05 Nov 2014 02:02:42 +0000
treeherderfx-team@fb9269729f51 [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/toolbox-process-window.js
browser/devtools/jar.mn
--- 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/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)
     content/browser/devtools/app-manager/template.js                   (app-manager/content/template.js)
     content/browser/devtools/app-manager/utils.js                      (app-manager/content/utils.js)
     content/browser/devtools/app-manager/connection-footer.js          (app-manager/content/connection-footer.js)