OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 /** @suppress {duplicate} */ | 5 /** @suppress {duplicate} */ |
6 var remoting = remoting || {}; | 6 var remoting = remoting || {}; |
7 | 7 |
8 (function() { | 8 (function() { |
9 | 9 |
10 'use strict'; | 10 'use strict'; |
11 | 11 |
12 /** | 12 /** |
13 * This class provides common functionality to Me2MeActivity and It2MeActivity, | 13 * This class provides common functionality to Me2MeActivity and It2MeActivity, |
14 * e.g. constructing the relevant UX, and delegate the custom handling of the | 14 * e.g. constructing the relevant UX, and delegate the custom handling of the |
15 * session state changes to the |parentActivity|. | 15 * session state changes to the |parentActivity|. |
16 * | 16 * |
17 * @param {remoting.Activity} parentActivity | 17 * @param {remoting.Activity} parentActivity |
18 * @implements {remoting.ClientSession.EventHandler} | 18 * @implements {remoting.ClientSession.EventHandler} |
19 * @implements {base.Disposable} | 19 * @implements {base.Disposable} |
20 * @constructor | 20 * @constructor |
21 */ | 21 */ |
22 remoting.DesktopRemotingActivity = function(parentActivity) { | 22 remoting.DesktopRemotingActivity = function(parentActivity) { |
23 /** @private */ | 23 /** @private */ |
24 this.parentActivity_ = parentActivity; | 24 this.parentActivity_ = parentActivity; |
25 /** @private {remoting.DesktopConnectedView} */ | 25 /** @private {remoting.DesktopConnectedView} */ |
26 this.connectedView_ = null; | 26 this.connectedView_ = null; |
| 27 /** @private */ |
| 28 this.sessionFactory_ = new remoting.ClientSessionFactory( |
| 29 document.querySelector('#client-container .client-plugin-container'), |
| 30 remoting.app_capabilities()); |
27 /** @private {remoting.ClientSession} */ | 31 /** @private {remoting.ClientSession} */ |
28 this.session_ = null; | 32 this.session_ = null; |
29 }; | 33 }; |
30 | 34 |
| 35 /** |
| 36 * Initiates a connection. |
| 37 * |
| 38 * @param {remoting.Host} host the Host to connect to. |
| 39 * @param {remoting.CredentialsProvider} credentialsProvider |
| 40 * @param {boolean=} opt_suppressOfflineError |
| 41 * @return {void} Nothing. |
| 42 */ |
| 43 remoting.DesktopRemotingActivity.prototype.start = |
| 44 function(host, credentialsProvider, opt_suppressOfflineError) { |
| 45 var that = this; |
| 46 this.sessionFactory_.createSession(this).then( |
| 47 function(/** remoting.ClientSession */ session) { |
| 48 that.session_ = session; |
| 49 session.logHostOfflineErrors(!opt_suppressOfflineError); |
| 50 session.connect(host, credentialsProvider); |
| 51 }); |
| 52 }; |
| 53 |
31 remoting.DesktopRemotingActivity.prototype.stop = function() { | 54 remoting.DesktopRemotingActivity.prototype.stop = function() { |
32 if (this.session_) { | 55 if (this.session_) { |
33 this.session_.disconnect(remoting.Error.none()); | 56 this.session_.disconnect(remoting.Error.none()); |
34 console.log('Disconnected.'); | 57 console.log('Disconnected.'); |
35 } | 58 } |
36 }; | 59 }; |
37 | 60 |
38 /** | 61 /** |
39 * @param {remoting.ConnectionInfo} connectionInfo | 62 * @param {remoting.ConnectionInfo} connectionInfo |
40 */ | 63 */ |
41 remoting.DesktopRemotingActivity.prototype.onConnected = | 64 remoting.DesktopRemotingActivity.prototype.onConnected = |
42 function(connectionInfo) { | 65 function(connectionInfo) { |
43 remoting.setMode(remoting.AppMode.IN_SESSION); | 66 remoting.setMode(remoting.AppMode.IN_SESSION); |
44 if (!base.isAppsV2()) { | 67 if (!base.isAppsV2()) { |
45 remoting.toolbar.center(); | 68 remoting.toolbar.center(); |
46 remoting.toolbar.preview(); | 69 remoting.toolbar.preview(); |
47 } | 70 } |
48 | 71 |
49 this.session_ = connectionInfo.session(); | |
50 | |
51 this.connectedView_ = new remoting.DesktopConnectedView( | 72 this.connectedView_ = new remoting.DesktopConnectedView( |
52 document.getElementById('client-container'), connectionInfo); | 73 document.getElementById('client-container'), connectionInfo); |
53 | 74 |
54 // By default, under ChromeOS, remap the right Control key to the right | 75 // By default, under ChromeOS, remap the right Control key to the right |
55 // Win / Cmd key. | 76 // Win / Cmd key. |
56 if (remoting.platformIsChromeOS()) { | 77 if (remoting.platformIsChromeOS()) { |
57 connectionInfo.plugin().setRemapKeys('0x0700e4>0x0700e7'); | 78 connectionInfo.plugin().setRemapKeys('0x0700e4>0x0700e7'); |
58 } | 79 } |
59 | 80 |
60 if (connectionInfo.plugin().hasCapability( | 81 if (connectionInfo.plugin().hasCapability( |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 } | 114 } |
94 | 115 |
95 this.parentActivity_.onError(error); | 116 this.parentActivity_.onError(error); |
96 | 117 |
97 this.dispose(); | 118 this.dispose(); |
98 }; | 119 }; |
99 | 120 |
100 remoting.DesktopRemotingActivity.prototype.dispose = function() { | 121 remoting.DesktopRemotingActivity.prototype.dispose = function() { |
101 base.dispose(this.connectedView_); | 122 base.dispose(this.connectedView_); |
102 this.connectedView_ = null; | 123 this.connectedView_ = null; |
| 124 base.dispose(this.session_); |
103 this.session_ = null; | 125 this.session_ = null; |
104 }; | 126 }; |
105 | 127 |
106 /** @return {remoting.DesktopConnectedView} */ | 128 /** @return {remoting.DesktopConnectedView} */ |
107 remoting.DesktopRemotingActivity.prototype.getConnectedView = function() { | 129 remoting.DesktopRemotingActivity.prototype.getConnectedView = function() { |
108 return this.connectedView_; | 130 return this.connectedView_; |
109 }; | 131 }; |
110 | 132 |
111 })(); | 133 })(); |
OLD | NEW |