Bug 1104927 - UITour: Add Loop conversation view target for email/copy link buttons. r=Unfocused,mixedpuppy a=dolske
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Thu, 11 Dec 2014 21:05:54 -0800
changeset 242524 71d6de6e9e16bd474b80f87371a1f8dc91a8a3a3
parent 242523 c220a894c67162b287e4a32ef684b1a9b9fe59ec
child 242525 dfefc5d9930cd71f9b072fa33485b5304bf21285
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersUnfocused, mixedpuppy, dolske
bugs1104927
milestone36.0a2
Bug 1104927 - UITour: Add Loop conversation view target for email/copy link buttons. r=Unfocused,mixedpuppy a=dolske
browser/base/content/socialchat.xml
browser/components/loop/MozLoopService.jsm
browser/modules/UITour.jsm
--- a/browser/base/content/socialchat.xml
+++ b/browser/base/content/socialchat.xml
@@ -664,16 +664,22 @@
 
           let otherWin = window.openDialog("chrome://browser/content/chatWindow.xul",
                                            "_blank", "chrome,all,dialog=no" + options);
 
           otherWin.addEventListener("load", function _chatLoad(event) {
             if (event.target != otherWin.document)
               return;
 
+            let detachEvent = new aChatbox.contentWindow.CustomEvent("socialFrameDetached", {
+              bubbles: true,
+              cancelable: true,
+            });
+            aChatbox.contentDocument.dispatchEvent(detachEvent);
+
             otherWin.removeEventListener("load", _chatLoad, true);
             let otherChatbox = otherWin.document.getElementById("chatter");
             aChatbox.swapDocShells(otherChatbox);
             aChatbox.close();
             chatbar.chatboxForURL.set(aChatbox.src, Cu.getWeakReference(otherChatbox));
 
             deferred.resolve(otherChatbox);
           }, true);
--- a/browser/components/loop/MozLoopService.jsm
+++ b/browser/components/loop/MozLoopService.jsm
@@ -823,19 +823,25 @@ let MozLoopServiceInternal = {
       chatbox.addEventListener("DOMContentLoaded", function loaded(event) {
         if (event.target != chatbox.contentDocument) {
           return;
         }
         chatbox.removeEventListener("DOMContentLoaded", loaded, true);
 
         let window = chatbox.contentWindow;
 
-        window.addEventListener("unload", function onUnloadChat(evt) {
-          UITour.notify("Loop:ChatWindowClosed");
-        });
+        function socialFrameChanged(eventName) {
+          UITour.availableTargetsCache.clear();
+          UITour.notify(eventName);
+        }
+
+        window.addEventListener("socialFrameHide", socialFrameChanged.bind(null, "Loop:ChatWindowHidden"));
+        window.addEventListener("socialFrameShow", socialFrameChanged.bind(null, "Loop:ChatWindowShown"));
+        window.addEventListener("socialFrameDetached", socialFrameChanged.bind(null, "Loop:ChatWindowDetached"));
+        window.addEventListener("unload", socialFrameChanged.bind(null, "Loop:ChatWindowClosed"));
 
         injectLoopAPI(window);
 
         let ourID = window.QueryInterface(Ci.nsIInterfaceRequestor)
             .getInterface(Ci.nsIDOMWindowUtils).currentInnerWindowID;
 
         let onPCLifecycleChange = (pc, winID, type) => {
           if (winID != ourID) {
--- a/browser/modules/UITour.jsm
+++ b/browser/modules/UITour.jsm
@@ -137,16 +137,26 @@ this.UITour = {
       query: (aDocument) => {
         let loopBrowser = aDocument.querySelector("#loop-notification-panel > #loop");
         if (!loopBrowser) {
           return null;
         }
         return loopBrowser.contentDocument.querySelector(".room-list");
       },
     }],
+    ["loop-selectedRoomButtons", {
+      infoPanelPosition: "leftcenter bottomright",
+      query: (aDocument) => {
+        let chatbox = aDocument.querySelector("chatbox[src^='about\:loopconversation'][selected]");
+        if (!chatbox || !chatbox.contentDocument) {
+          return null;
+        }
+        return chatbox.contentDocument.querySelector(".call-action-group");
+      },
+    }],
     ["loop-signInUpLink", {
       query: (aDocument) => {
         let loopBrowser = aDocument.querySelector("#loop-notification-panel > #loop");
         if (!loopBrowser) {
           return null;
         }
         return loopBrowser.contentDocument.querySelector(".signin-link");
       },
@@ -1371,18 +1381,17 @@ this.UITour = {
   },
 
   hideAppMenuAnnotations: function(aEvent) {
     UITour.hideAnnotationsForPanel(aEvent, UITour.targetIsInAppMenu);
   },
 
   hideLoopPanelAnnotations: function(aEvent) {
     UITour.hideAnnotationsForPanel(aEvent, (aTarget) => {
-      // TODO: Bug 1104927 - Handle the conversation targets separately.
-      return aTarget.targetName.startsWith("loop-");
+      return aTarget.targetName.startsWith("loop-") && aTarget.targetName != "loop-selectedRoomButtons";
     });
   },
 
   onPanelHidden: function(aEvent) {
     aEvent.target.removeAttribute("noautohide");
     UITour.recreatePopup(aEvent.target);
   },