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 /** | 8 /** |
9 * Type definition for the RunApplicationResponse returned by the API. | 9 * Type definition for the RunApplicationResponse returned by the API. |
10 * @typedef {{ | 10 * @typedef {{ |
(...skipping 10 matching lines...) Expand all Loading... |
21 remoting.AppHostResponse; | 21 remoting.AppHostResponse; |
22 | 22 |
23 (function() { | 23 (function() { |
24 | 24 |
25 'use strict'; | 25 'use strict'; |
26 | 26 |
27 /** | 27 /** |
28 * @param {Array<string>} appCapabilities Array of application capabilities. | 28 * @param {Array<string>} appCapabilities Array of application capabilities. |
29 * @param {remoting.Application} app | 29 * @param {remoting.Application} app |
30 * @param {remoting.WindowShape} windowShape | 30 * @param {remoting.WindowShape} windowShape |
| 31 * @param {string} subscriptionToken |
31 * | 32 * |
32 * @constructor | 33 * @constructor |
33 * @implements {remoting.Activity} | 34 * @implements {remoting.Activity} |
34 */ | 35 */ |
35 remoting.AppRemotingActivity = function(appCapabilities, app, windowShape) { | 36 remoting.AppRemotingActivity = function(appCapabilities, app, windowShape, |
| 37 subscriptionToken) { |
36 /** @private */ | 38 /** @private */ |
37 this.sessionFactory_ = new remoting.ClientSessionFactory( | 39 this.sessionFactory_ = new remoting.ClientSessionFactory( |
38 document.querySelector('#client-container .client-plugin-container'), | 40 document.querySelector('#client-container .client-plugin-container'), |
39 appCapabilities); | 41 appCapabilities); |
40 | 42 |
41 /** @private {remoting.ClientSession} */ | 43 /** @private {remoting.ClientSession} */ |
42 this.session_ = null; | 44 this.session_ = null; |
43 | 45 |
44 /** @private {base.Disposables} */ | 46 /** @private {base.Disposables} */ |
45 this.connectedDisposables_ = null; | 47 this.connectedDisposables_ = null; |
46 | 48 |
47 /** @private */ | 49 /** @private */ |
48 this.app_ = app; | 50 this.app_ = app; |
49 | 51 |
50 /** @private */ | 52 /** @private */ |
51 this.windowShape_ = windowShape; | 53 this.windowShape_ = windowShape; |
| 54 |
| 55 /** @private */ |
| 56 this.subscriptionToken_ = subscriptionToken; |
52 }; | 57 }; |
53 | 58 |
54 remoting.AppRemotingActivity.prototype.dispose = function() { | 59 remoting.AppRemotingActivity.prototype.dispose = function() { |
55 this.cleanup_(); | 60 this.cleanup_(); |
56 remoting.LoadingWindow.close(); | 61 remoting.LoadingWindow.close(); |
57 }; | 62 }; |
58 | 63 |
59 remoting.AppRemotingActivity.prototype.start = function() { | 64 remoting.AppRemotingActivity.prototype.start = function() { |
60 remoting.LoadingWindow.show(); | 65 remoting.LoadingWindow.show(); |
61 var that = this; | 66 var that = this; |
(...skipping 21 matching lines...) Expand all Loading... |
83 }; | 88 }; |
84 | 89 |
85 /** | 90 /** |
86 * @param {string} token | 91 * @param {string} token |
87 * @return {Promise<!remoting.Xhr.Response>} | 92 * @return {Promise<!remoting.Xhr.Response>} |
88 * @private | 93 * @private |
89 */ | 94 */ |
90 remoting.AppRemotingActivity.prototype.getAppHostInfo_ = function(token) { | 95 remoting.AppRemotingActivity.prototype.getAppHostInfo_ = function(token) { |
91 var url = remoting.settings.APP_REMOTING_API_BASE_URL + '/applications/' + | 96 var url = remoting.settings.APP_REMOTING_API_BASE_URL + '/applications/' + |
92 remoting.settings.getAppRemotingApplicationId() + '/run'; | 97 remoting.settings.getAppRemotingApplicationId() + '/run'; |
| 98 // TODO(kelvinp): Passes |this.subscriptionToken_| to the XHR. |
93 return new remoting.AutoRetryXhr({ | 99 return new remoting.AutoRetryXhr({ |
94 method: 'POST', | 100 method: 'POST', |
95 url: url, | 101 url: url, |
96 oauthToken: token | 102 oauthToken: token |
97 }).start(); | 103 }).start(); |
98 }; | 104 }; |
99 | 105 |
100 /** | 106 /** |
101 * @param {!remoting.Xhr.Response} xhrResponse | 107 * @param {!remoting.Xhr.Response} xhrResponse |
102 * @private | 108 * @private |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 * @private | 258 * @private |
253 */ | 259 */ |
254 remoting.AppRemotingActivity.prototype.showErrorMessage_ = function(error) { | 260 remoting.AppRemotingActivity.prototype.showErrorMessage_ = function(error) { |
255 console.error('Connection failed: ' + error.toString()); | 261 console.error('Connection failed: ' + error.toString()); |
256 remoting.MessageWindow.showErrorMessage( | 262 remoting.MessageWindow.showErrorMessage( |
257 this.app_.getApplicationName(), | 263 this.app_.getApplicationName(), |
258 chrome.i18n.getMessage(error.getTag())); | 264 chrome.i18n.getMessage(error.getTag())); |
259 }; | 265 }; |
260 | 266 |
261 })(); | 267 })(); |
OLD | NEW |