OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 * Interface abstracting the Application functionality. | 7 * Interface abstracting the Application functionality. |
8 */ | 8 */ |
9 | 9 |
10 'use strict'; | 10 'use strict'; |
11 | 11 |
12 /** @suppress {duplicate} */ | 12 /** @suppress {duplicate} */ |
13 var remoting = remoting || {}; | 13 var remoting = remoting || {}; |
14 | 14 |
15 /** | 15 /** |
16 * @param {Array.<string>} app_features Array of application features. | |
Jamie
2015/02/02 22:57:47
There's confusion in this file as to "features" vs
garykac
2015/02/03 01:50:21
Done.
| |
16 * @constructor | 17 * @constructor |
17 */ | 18 */ |
18 remoting.Application = function() { | 19 remoting.Application = function(app_features) { |
19 /** | 20 /** |
20 * @type {remoting.Application.Delegate} | 21 * @type {remoting.Application.Delegate} |
21 * @private | 22 * @private |
22 */ | 23 */ |
23 this.delegate_ = null; | 24 this.delegate_ = null; |
24 | 25 |
25 /** | 26 /** |
27 * @type {Array.<string>} | |
28 * @private | |
29 */ | |
30 this.app_features_ = app_features; | |
31 | |
32 /** | |
26 * @type {remoting.SessionConnector} | 33 * @type {remoting.SessionConnector} |
27 * @private | 34 * @private |
28 */ | 35 */ |
29 this.session_connector_ = null; | 36 this.session_connector_ = null; |
30 }; | 37 }; |
31 | 38 |
32 /** | 39 /** |
33 * @param {remoting.Application.Delegate} appDelegate The delegate that | 40 * @param {remoting.Application.Delegate} appDelegate The delegate that |
34 * contains the app-specific functionality. | 41 * contains the app-specific functionality. |
35 */ | 42 */ |
36 remoting.Application.prototype.setDelegate = function(appDelegate) { | 43 remoting.Application.prototype.setDelegate = function(appDelegate) { |
37 this.delegate_ = appDelegate; | 44 this.delegate_ = appDelegate; |
38 }; | 45 }; |
39 | 46 |
40 /** | 47 /** |
48 * @return {Array.<string>} A list of |ClientSession.Capability|s required | |
49 * by this application. | |
50 */ | |
51 remoting.Application.prototype.getRequiredCapabilities = function() { | |
52 var capabilities = [ | |
53 remoting.ClientSession.Capability.SEND_INITIAL_RESOLUTION, | |
54 remoting.ClientSession.Capability.RATE_LIMIT_RESIZE_REQUESTS, | |
55 remoting.ClientSession.Capability.VIDEO_RECORDER | |
56 ]; | |
57 if (this.app_features_.indexOf('cast') != -1) { | |
58 capabilities.push(remoting.ClientSession.Capability.CAST); | |
59 } | |
60 if (this.app_features_.indexOf('gdrive') != -1) { | |
61 capabilities.push(remoting.ClientSession.Capability.GOOGLE_DRIVE); | |
62 } | |
63 return capabilities; | |
64 }; | |
65 | |
66 /** | |
41 * Initialize the application and register all event handlers. After this | 67 * Initialize the application and register all event handlers. After this |
42 * is called, the app is running and waiting for user events. | 68 * is called, the app is running and waiting for user events. |
43 * | 69 * |
44 * @return {void} Nothing. | 70 * @return {void} Nothing. |
45 */ | 71 */ |
46 remoting.Application.prototype.start = function() { | 72 remoting.Application.prototype.start = function() { |
47 // Create global objects. | 73 // Create global objects. |
48 remoting.ClientPlugin.factory = new remoting.DefaultClientPluginFactory(); | 74 remoting.ClientPlugin.factory = new remoting.DefaultClientPluginFactory(); |
49 remoting.SessionConnector.factory = | 75 remoting.SessionConnector.factory = |
50 new remoting.DefaultSessionConnectorFactory(); | 76 new remoting.DefaultSessionConnectorFactory(); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 */ | 172 */ |
147 remoting.Application.prototype.getSessionConnector = function() { | 173 remoting.Application.prototype.getSessionConnector = function() { |
148 // TODO(garykac): Check if this can be initialized in the ctor. | 174 // TODO(garykac): Check if this can be initialized in the ctor. |
149 if (!this.session_connector_) { | 175 if (!this.session_connector_) { |
150 this.session_connector_ = remoting.SessionConnector.factory.createConnector( | 176 this.session_connector_ = remoting.SessionConnector.factory.createConnector( |
151 document.getElementById('client-container'), | 177 document.getElementById('client-container'), |
152 this.onConnected.bind(this), | 178 this.onConnected.bind(this), |
153 this.onError.bind(this), | 179 this.onError.bind(this), |
154 this.onExtensionMessage.bind(this), | 180 this.onExtensionMessage.bind(this), |
155 this.onConnectionFailed.bind(this), | 181 this.onConnectionFailed.bind(this), |
156 this.delegate_.getRequiredCapabilities(), | 182 this.getRequiredCapabilities(), |
157 this.delegate_.getDefaultRemapKeys()); | 183 this.delegate_.getDefaultRemapKeys()); |
158 } | 184 } |
159 return this.session_connector_; | 185 return this.session_connector_; |
160 }; | 186 }; |
161 | 187 |
162 | 188 |
163 /** | 189 /** |
164 * @interface | 190 * @interface |
165 */ | 191 */ |
166 remoting.Application.Delegate = function() {}; | 192 remoting.Application.Delegate = function() {}; |
167 | 193 |
168 /** | 194 /** |
169 * Initialize the application and register all event handlers. After this | 195 * Initialize the application and register all event handlers. After this |
170 * is called, the app is running and waiting for user events. | 196 * is called, the app is running and waiting for user events. |
171 * | 197 * |
172 * @param {remoting.SessionConnector} connector | 198 * @param {remoting.SessionConnector} connector |
173 * @return {void} Nothing. | 199 * @return {void} Nothing. |
174 */ | 200 */ |
175 remoting.Application.Delegate.prototype.init = function(connector) {}; | 201 remoting.Application.Delegate.prototype.init = function(connector) {}; |
176 | 202 |
177 /** | 203 /** |
178 * @return {string} The default remap keys for the current platform. | 204 * @return {string} The default remap keys for the current platform. |
179 */ | 205 */ |
180 remoting.Application.Delegate.prototype.getDefaultRemapKeys = function() {}; | 206 remoting.Application.Delegate.prototype.getDefaultRemapKeys = function() {}; |
181 | 207 |
182 /** | 208 /** |
183 * @return {Array.<string>} A list of |ClientSession.Capability|s required | |
184 * by this application. | |
185 */ | |
186 remoting.Application.Delegate.prototype.getRequiredCapabilities = function() {}; | |
187 | |
188 /** | |
189 * Called when a new session has been connected. | 209 * Called when a new session has been connected. |
190 * | 210 * |
191 * @param {remoting.ClientSession} clientSession | 211 * @param {remoting.ClientSession} clientSession |
192 * @return {void} Nothing. | 212 * @return {void} Nothing. |
193 */ | 213 */ |
194 remoting.Application.Delegate.prototype.handleConnected = function( | 214 remoting.Application.Delegate.prototype.handleConnected = function( |
195 clientSession) {}; | 215 clientSession) {}; |
196 | 216 |
197 /** | 217 /** |
198 * Called when the current session has been disconnected. | 218 * Called when the current session has been disconnected. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
234 * Called when an error needs to be displayed to the user. | 254 * Called when an error needs to be displayed to the user. |
235 * | 255 * |
236 * @param {remoting.Error} errorTag The error to be localized and displayed. | 256 * @param {remoting.Error} errorTag The error to be localized and displayed. |
237 * @return {void} Nothing. | 257 * @return {void} Nothing. |
238 */ | 258 */ |
239 remoting.Application.Delegate.prototype.handleError = function(errorTag) {}; | 259 remoting.Application.Delegate.prototype.handleError = function(errorTag) {}; |
240 | 260 |
241 | 261 |
242 /** @type {remoting.Application} */ | 262 /** @type {remoting.Application} */ |
243 remoting.app = null; | 263 remoting.app = null; |
OLD | NEW |