OLD | NEW |
1 /* Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 /* Copyright (c) 2011 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 /** | 6 /** |
7 * @fileoverview | 7 * @fileoverview |
8 * A class that loads a WCS IQ client and constructs remoting.wcs as a | 8 * A class that loads a WCS IQ client and constructs remoting.wcs as a |
9 * wrapper for it. | 9 * wrapper for it. |
10 */ | 10 */ |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 69 |
70 /** | 70 /** |
71 * The URL of the GTalk gadget. | 71 * The URL of the GTalk gadget. |
72 * @type {string} | 72 * @type {string} |
73 * @private | 73 * @private |
74 */ | 74 */ |
75 remoting.WcsLoader.prototype.TALK_GADGET_URL_ = | 75 remoting.WcsLoader.prototype.TALK_GADGET_URL_ = |
76 'https://talkgadget.google.com/talkgadget/'; | 76 'https://talkgadget.google.com/talkgadget/'; |
77 | 77 |
78 /** | 78 /** |
| 79 * Starts loading the WCS IQ client aynchronously. If an OAuth2 token is |
| 80 * already available, this is equivalent to the start method; if not, then |
| 81 * the client will be loaded after an OAuth token exchange has occurred. |
| 82 * |
| 83 * @param {function(function(string): void): void} tokenRefresh |
| 84 * Gets a (possibly updated) access token asynchronously. |
| 85 * @param {function(boolean): void} onReady If the WCS connection is not yet |
| 86 * ready, then |onReady| will be called with a true parameter when it is |
| 87 * ready, or with a false parameter on error. |
| 88 * @return {void} Nothing. |
| 89 */ |
| 90 remoting.WcsLoader.prototype.startAsync = function(tokenRefresh, onReady) { |
| 91 /** @type {remoting.WcsLoader} */ |
| 92 var that = this; |
| 93 /** @param {string} token The OAuth2 access token. */ |
| 94 var start = function(token) { |
| 95 that.start(token, tokenRefresh, onReady); |
| 96 }; |
| 97 remoting.oauth2.callWithToken(start); |
| 98 }; |
| 99 |
| 100 /** |
79 * Starts loading the WCS IQ client. | 101 * Starts loading the WCS IQ client. |
80 * | 102 * |
81 * When it's loaded, construct remoting.wcs as a wrapper for it. | 103 * When it's loaded, construct remoting.wcs as a wrapper for it. |
82 * When the WCS connection is ready, call |onReady|. | 104 * When the WCS connection is ready, call |onReady|. |
83 * | 105 * |
84 * No guarantee is made about what will happen if this function is called more | 106 * No guarantee is made about what will happen if this function is called more |
85 * than once. | 107 * than once. |
86 * | 108 * |
87 * @param {string} token An OAuth2 access token. | 109 * @param {string} token An OAuth2 access token. |
88 * @param {function(function(string): void): void} tokenRefresh | 110 * @param {function(function(string): void): void} tokenRefresh |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 * Notifies this object that WCS is ready. | 160 * Notifies this object that WCS is ready. |
139 * | 161 * |
140 * @return {void} Nothing. | 162 * @return {void} Nothing. |
141 * @private | 163 * @private |
142 */ | 164 */ |
143 remoting.WcsLoader.prototype.onWcsReady_ = function() { | 165 remoting.WcsLoader.prototype.onWcsReady_ = function() { |
144 this.loadState_ = this.LoadState_.READY; | 166 this.loadState_ = this.LoadState_.READY; |
145 this.onReady_(true); | 167 this.onReady_(true); |
146 this.onReady_ = function(success) {}; | 168 this.onReady_ = function(success) {}; |
147 }; | 169 }; |
OLD | NEW |