OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @fileoverview | 6 * @fileoverview |
7 * Class handling creation and teardown of a remoting client session. | 7 * Class handling creation and teardown of a remoting client session. |
8 * | 8 * |
9 * The ClientSession class controls lifetime of the client plugin | 9 * The ClientSession class controls lifetime of the client plugin |
10 * object and provides the plugin with the functionality it needs to | 10 * object and provides the plugin with the functionality it needs to |
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 this.plugin_ = null; | 583 this.plugin_ = null; |
584 } | 584 } |
585 | 585 |
586 // Leave full-screen mode, and stop listening for related events. | 586 // Leave full-screen mode, and stop listening for related events. |
587 var listener = this.callOnFullScreenChanged_; | 587 var listener = this.callOnFullScreenChanged_; |
588 remoting.fullscreen.activate( | 588 remoting.fullscreen.activate( |
589 false, | 589 false, |
590 function() { | 590 function() { |
591 remoting.fullscreen.removeListener(listener); | 591 remoting.fullscreen.removeListener(listener); |
592 }); | 592 }); |
593 if (remoting.windowFrame) { | 593 this.updateClientSessionUi_(null); |
594 remoting.windowFrame.setClientSession(null); | |
595 } else { | |
596 remoting.toolbar.setClientSession(null); | |
597 } | |
598 remoting.optionsMenu.setClientSession(null); | |
599 document.body.classList.remove('connected'); | |
600 | 594 |
601 // Remove mediasource-rendering class from the container - this will also | 595 // Remove mediasource-rendering class from the container - this will also |
602 // hide the <video> element. | 596 // hide the <video> element. |
603 this.container_.classList.remove('mediasource-rendering'); | 597 this.container_.classList.remove('mediasource-rendering'); |
604 | 598 |
605 this.container_.removeEventListener('mousemove', | 599 this.container_.removeEventListener('mousemove', |
606 this.updateMouseCursorPosition_, | 600 this.updateMouseCursorPosition_, |
607 true); | 601 true); |
608 }; | 602 }; |
609 | 603 |
610 /** | 604 /** |
| 605 * @param {remoting.ClientSession} clientSession The active session, or null if |
| 606 * there is no connection. |
| 607 */ |
| 608 remoting.ClientSession.prototype.updateClientSessionUi_ = function( |
| 609 clientSession) { |
| 610 if (remoting.windowFrame) { |
| 611 remoting.windowFrame.setClientSession(clientSession); |
| 612 } |
| 613 if (remoting.toolbar) { |
| 614 remoting.toolbar.setClientSession(clientSession); |
| 615 } |
| 616 if (remoting.optionsMenu) { |
| 617 remoting.optionsMenu.setClientSession(clientSession); |
| 618 } |
| 619 |
| 620 if (clientSession == null) { |
| 621 document.body.classList.remove('connected'); |
| 622 } else { |
| 623 document.body.classList.add('connected'); |
| 624 } |
| 625 } |
| 626 |
| 627 /** |
611 * Disconnect the current session with a particular |error|. The session will | 628 * Disconnect the current session with a particular |error|. The session will |
612 * raise a |stateChanged| event in response to it. The caller should then call | 629 * raise a |stateChanged| event in response to it. The caller should then call |
613 * |cleanup| to remove and destroy the <embed> element. | 630 * |cleanup| to remove and destroy the <embed> element. |
614 * | 631 * |
615 * @param {remoting.Error} error The reason for the disconnection. Use | 632 * @param {remoting.Error} error The reason for the disconnection. Use |
616 * remoting.Error.NONE if there is no error. | 633 * remoting.Error.NONE if there is no error. |
617 * @return {void} Nothing. | 634 * @return {void} Nothing. |
618 */ | 635 */ |
619 remoting.ClientSession.prototype.disconnect = function(error) { | 636 remoting.ClientSession.prototype.disconnect = function(error) { |
620 var state = (error == remoting.Error.NONE) ? | 637 var state = (error == remoting.Error.NONE) ? |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
948 this.setFocusHandlers_(); | 965 this.setFocusHandlers_(); |
949 this.onDesktopSizeChanged_(); | 966 this.onDesktopSizeChanged_(); |
950 if (this.resizeToClient_) { | 967 if (this.resizeToClient_) { |
951 var clientArea = this.getClientArea_(); | 968 var clientArea = this.getClientArea_(); |
952 this.plugin_.notifyClientResolution(clientArea.width, | 969 this.plugin_.notifyClientResolution(clientArea.width, |
953 clientArea.height, | 970 clientArea.height, |
954 window.devicePixelRatio); | 971 window.devicePixelRatio); |
955 } | 972 } |
956 // Activate full-screen related UX. | 973 // Activate full-screen related UX. |
957 remoting.fullscreen.addListener(this.callOnFullScreenChanged_); | 974 remoting.fullscreen.addListener(this.callOnFullScreenChanged_); |
958 if (remoting.windowFrame) { | 975 this.updateClientSessionUi_(this); |
959 remoting.windowFrame.setClientSession(this); | |
960 } else { | |
961 remoting.toolbar.setClientSession(this); | |
962 } | |
963 remoting.optionsMenu.setClientSession(this); | |
964 document.body.classList.add('connected'); | |
965 | |
966 this.container_.addEventListener('mousemove', | 976 this.container_.addEventListener('mousemove', |
967 this.updateMouseCursorPosition_, | 977 this.updateMouseCursorPosition_, |
968 true); | 978 true); |
969 | 979 |
970 } else if (status == remoting.ClientSession.State.FAILED) { | 980 } else if (status == remoting.ClientSession.State.FAILED) { |
971 switch (error) { | 981 switch (error) { |
972 case remoting.ClientSession.ConnectionError.HOST_IS_OFFLINE: | 982 case remoting.ClientSession.ConnectionError.HOST_IS_OFFLINE: |
973 this.error_ = remoting.Error.HOST_IS_OFFLINE; | 983 this.error_ = remoting.Error.HOST_IS_OFFLINE; |
974 break; | 984 break; |
975 case remoting.ClientSession.ConnectionError.SESSION_REJECTED: | 985 case remoting.ClientSession.ConnectionError.SESSION_REJECTED: |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1634 * @param {string} data Contents of the extension message. | 1644 * @param {string} data Contents of the extension message. |
1635 * @return {boolean} True if the message was recognized, false otherwise. | 1645 * @return {boolean} True if the message was recognized, false otherwise. |
1636 */ | 1646 */ |
1637 remoting.ClientSession.prototype.handleExtensionMessage = | 1647 remoting.ClientSession.prototype.handleExtensionMessage = |
1638 function(type, data) { | 1648 function(type, data) { |
1639 if (this.videoFrameRecorder_) { | 1649 if (this.videoFrameRecorder_) { |
1640 return this.videoFrameRecorder_.handleMessage(type, data); | 1650 return this.videoFrameRecorder_.handleMessage(type, data); |
1641 } | 1651 } |
1642 return false; | 1652 return false; |
1643 } | 1653 } |
OLD | NEW |