Bug 1214215: Part 1 - start sharing browser tabs when owner joins the room. r=Standard8
authorMike de Boer <mdeboer@mozilla.com>
Thu, 03 Dec 2015 11:12:52 +0100
changeset 309618 d54d4573815dd3fe10f95684faf352d8ec911ce2
parent 309617 92499b34eeffbfdaf5df19f63c464988435356db
child 309619 3278e225eb212dd79ec6bcbf5bf2fcdedee89975
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersStandard8
bugs1214215
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1214215: Part 1 - start sharing browser tabs when owner joins the room. r=Standard8
browser/extensions/loop/content/panels/js/roomViews.js
browser/extensions/loop/content/panels/js/roomViews.jsx
browser/extensions/loop/content/shared/js/actions.js
browser/extensions/loop/content/shared/js/activeRoomStore.js
browser/extensions/loop/test/desktop-local/roomViews_test.js
--- a/browser/extensions/loop/content/panels/js/roomViews.js
+++ b/browser/extensions/loop/content/panels/js/roomViews.js
@@ -617,16 +617,22 @@ loop.roomViews = (function(mozL10n) {
       if (this.state.roomState !== ROOM_STATES.MEDIA_WAIT &&
           nextState.roomState === ROOM_STATES.MEDIA_WAIT) {
         this.props.dispatcher.dispatch(new sharedActions.SetupStreamElements({
           publisherConfig: this.getDefaultPublisherConfig({
             publishVideo: !this.state.videoMuted
           })
         }));
       }
+
+      // Automatically start sharing a tab now we're ready to share.
+      if (this.state.roomState !== ROOM_STATES.SESSION_CONNECTED &&
+          nextState.roomState === ROOM_STATES.SESSION_CONNECTED) {
+        this.props.dispatcher.dispatch(new sharedActions.StartBrowserShare());
+      }
     },
 
     /**
      * User clicked on the "Leave" button.
      */
     leaveRoom: function() {
       if (this.state.used) {
         this.props.dispatcher.dispatch(new sharedActions.LeaveRoom());
--- a/browser/extensions/loop/content/panels/js/roomViews.jsx
+++ b/browser/extensions/loop/content/panels/js/roomViews.jsx
@@ -617,16 +617,22 @@ loop.roomViews = (function(mozL10n) {
       if (this.state.roomState !== ROOM_STATES.MEDIA_WAIT &&
           nextState.roomState === ROOM_STATES.MEDIA_WAIT) {
         this.props.dispatcher.dispatch(new sharedActions.SetupStreamElements({
           publisherConfig: this.getDefaultPublisherConfig({
             publishVideo: !this.state.videoMuted
           })
         }));
       }
+
+      // Automatically start sharing a tab now we're ready to share.
+      if (this.state.roomState !== ROOM_STATES.SESSION_CONNECTED &&
+          nextState.roomState === ROOM_STATES.SESSION_CONNECTED) {
+        this.props.dispatcher.dispatch(new sharedActions.StartBrowserShare());
+      }
     },
 
     /**
      * User clicked on the "Leave" button.
      */
     leaveRoom: function() {
       if (this.state.used) {
         this.props.dispatcher.dispatch(new sharedActions.LeaveRoom());
--- a/browser/extensions/loop/content/shared/js/actions.js
+++ b/browser/extensions/loop/content/shared/js/actions.js
@@ -208,16 +208,22 @@ loop.shared.actions = (function() {
      * Used to start a screen share.
      */
     StartScreenShare: Action.define("startScreenShare", {
       // The part of the screen to share, e.g. "window" or "browser".
       type: String
     }),
 
     /**
+     * Used to start a browser tab share.
+     */
+    StartBrowserShare: Action.define("startBrowserShare", {
+    }),
+
+    /**
      * Used to end a screen share.
      */
     EndScreenShare: Action.define("endScreenShare", {
     }),
 
     /**
      * Used to notify that screen sharing is active or not.
      */
--- a/browser/extensions/loop/content/shared/js/activeRoomStore.js
+++ b/browser/extensions/loop/content/shared/js/activeRoomStore.js
@@ -253,16 +253,17 @@ loop.store.ActiveRoomStore = (function()
         "windowUnload",
         "leaveRoom",
         "feedbackComplete",
         "mediaStreamCreated",
         "mediaStreamDestroyed",
         "remoteVideoStatus",
         "videoDimensionsChanged",
         "startScreenShare",
+        "startBrowserShare",
         "endScreenShare",
         "updateSocialShareInfo",
         "connectionStatus",
         "mediaConnected"
       ];
       // Register actions that are only used on Desktop.
       if (this._isDesktop) {
         // 'receivedTextChatMessage' and  'sendTextChatMessage' actions are only
@@ -945,16 +946,25 @@ loop.store.ActiveRoomStore = (function()
         loop.request("AddBrowserSharingListener").then(this._browserSharingListener);
         loop.subscribe("BrowserSwitch", this._browserSharingListener);
       } else {
         this._sdkDriver.startScreenShare(options);
       }
     },
 
     /**
+     * Initiates a browser tab sharing publisher.
+     *
+     * @param {sharedActions.StartBrowserShare} actionData
+     */
+    startBrowserShare: function(actionData) {
+      this.startScreenShare({ type: "browser" });
+    },
+
+    /**
      * Ends an active screenshare session.
      */
     endScreenShare: function() {
       if (this._browserSharingListener) {
         // Remove the browser sharing listener as we don't need it now.
         loop.request("RemoveBrowserSharingListener");
         loop.unsubscribe("BrowserSwitch", this._browserSharingListener);
         this._browserSharingListener = null;
--- a/browser/extensions/loop/test/desktop-local/roomViews_test.js
+++ b/browser/extensions/loop/test/desktop-local/roomViews_test.js
@@ -432,16 +432,25 @@ describe("loop.roomViews", function() {
       it("should dispatch a `SetupStreamElements` action on MEDIA_WAIT state is re-entered", function() {
           activeRoomStore.setStoreState({ roomState: ROOM_STATES.ENDED });
           var component = mountTestComponent();
 
           activeRoomStore.setStoreState({ roomState: ROOM_STATES.MEDIA_WAIT });
 
           expectActionDispatched(component);
         });
+
+      it("should dispatch a `StartBrowserShare` action when the SESSION_CONNECTED state is entered", function() {
+        activeRoomStore.setStoreState({ roomState: ROOM_STATES.READY });
+        var component = mountTestComponent();
+
+        activeRoomStore.setStoreState({ roomState: ROOM_STATES.SESSION_CONNECTED });
+
+        expectActionDispatched("startBrowserShare");
+      });
     });
 
     describe("#render", function() {
       it("should set document.title to store.serverData.roomName", function() {
         mountTestComponent();
 
         activeRoomStore.setStoreState({ roomName: "fakeName" });