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 /** | 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 23 matching lines...) Expand all Loading... |
34 * Load WCS if necessary, then invoke the callback with an access token. | 34 * Load WCS if necessary, then invoke the callback with an access token. |
35 * | 35 * |
36 * @param {function(string?): void} onReady The callback function, called with | 36 * @param {function(string?): void} onReady The callback function, called with |
37 * an OAuth2 access token when WCS has been loaded, or with null on error. | 37 * an OAuth2 access token when WCS has been loaded, or with null on error. |
38 * @return {void} Nothing. | 38 * @return {void} Nothing. |
39 */ | 39 */ |
40 remoting.WcsLoader.load = function(onReady) { | 40 remoting.WcsLoader.load = function(onReady) { |
41 if (!remoting.wcsLoader) { | 41 if (!remoting.wcsLoader) { |
42 remoting.wcsLoader = new remoting.WcsLoader(); | 42 remoting.wcsLoader = new remoting.WcsLoader(); |
43 } | 43 } |
44 /** @param {string} token The OAuth2 access token. */ | 44 /** @param {string?} token The OAuth2 access token. */ |
45 var start = function(token) { | 45 var start = function(token) { |
46 remoting.wcsLoader.start_(token, onReady); | 46 if (token) { |
| 47 remoting.wcsLoader.start_(token, onReady); |
| 48 } else { |
| 49 console.error('WcsLoader: Authentication failed.'); |
| 50 onReady(null); |
| 51 } |
47 }; | 52 }; |
48 remoting.oauth2.callWithToken(start); | 53 remoting.oauth2.callWithToken(start); |
49 }; | 54 }; |
50 | 55 |
51 /** | 56 /** |
52 * The URL of the GTalk gadget. | 57 * The URL of the GTalk gadget. |
53 * @type {string} | 58 * @type {string} |
54 * @private | 59 * @private |
55 */ | 60 */ |
56 remoting.WcsLoader.prototype.TALK_GADGET_URL_ = | 61 remoting.WcsLoader.prototype.TALK_GADGET_URL_ = |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 * an OAuth2 access token when WCS has been loaded, or with null on error. | 128 * an OAuth2 access token when WCS has been loaded, or with null on error. |
124 * @return {void} Nothing. | 129 * @return {void} Nothing. |
125 * @private | 130 * @private |
126 */ | 131 */ |
127 remoting.WcsLoader.prototype.constructWcs_ = function(token, onReady) { | 132 remoting.WcsLoader.prototype.constructWcs_ = function(token, onReady) { |
128 remoting.wcs = new remoting.Wcs( | 133 remoting.wcs = new remoting.Wcs( |
129 remoting.wcsLoader.wcsIqClient, | 134 remoting.wcsLoader.wcsIqClient, |
130 token, | 135 token, |
131 function() { onReady(token); }); | 136 function() { onReady(token); }); |
132 }; | 137 }; |
OLD | NEW |