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 'use strict'; | 5 'use strict'; |
6 | 6 |
7 /** @suppress {duplicate} */ | 7 /** @suppress {duplicate} */ |
8 var remoting = remoting || {}; | 8 var remoting = remoting || {}; |
9 | 9 |
10 /** @type {remoting.HostSession} */ remoting.hostSession = null; | 10 /** @type {remoting.HostSession} */ remoting.hostSession = null; |
(...skipping 21 matching lines...) Expand all Loading... | |
32 * Entry point for app initialization. | 32 * Entry point for app initialization. |
33 */ | 33 */ |
34 remoting.init = function() { | 34 remoting.init = function() { |
35 // TODO(jamiewalch): Remove this when we migrate to apps v2. | 35 // TODO(jamiewalch): Remove this when we migrate to apps v2. |
36 remoting.initMockStorage(); | 36 remoting.initMockStorage(); |
37 | 37 |
38 remoting.logExtensionInfoAsync_(); | 38 remoting.logExtensionInfoAsync_(); |
39 l10n.localize(); | 39 l10n.localize(); |
40 // Create global objects. | 40 // Create global objects. |
41 remoting.oauth2 = new remoting.OAuth2(); | 41 remoting.oauth2 = new remoting.OAuth2(); |
42 // TODO(jamiewalch): Reinstate this when we migrate to apps v2. | |
43 // remoting.identity = new remoting.Identity( | |
44 // document.getElementById('auth-dialog'), | |
45 // document.getElementById('auth-button')); | |
46 remoting.identity = remoting.oauth2; | |
42 remoting.stats = new remoting.ConnectionStats( | 47 remoting.stats = new remoting.ConnectionStats( |
43 document.getElementById('statistics')); | 48 document.getElementById('statistics')); |
44 remoting.formatIq = new remoting.FormatIq(); | 49 remoting.formatIq = new remoting.FormatIq(); |
45 remoting.hostList = new remoting.HostList( | 50 remoting.hostList = new remoting.HostList( |
46 document.getElementById('host-list'), | 51 document.getElementById('host-list'), |
47 document.getElementById('host-list-empty'), | 52 document.getElementById('host-list-empty'), |
48 document.getElementById('host-list-error-message'), | 53 document.getElementById('host-list-error-message'), |
49 document.getElementById('host-list-refresh-failed-button')); | 54 document.getElementById('host-list-refresh-failed-button')); |
50 remoting.toolbar = new remoting.Toolbar( | 55 remoting.toolbar = new remoting.Toolbar( |
51 document.getElementById('session-toolbar')); | 56 document.getElementById('session-toolbar')); |
52 remoting.clipboard = new remoting.Clipboard(); | 57 remoting.clipboard = new remoting.Clipboard(); |
53 remoting.suspendMonitor = new remoting.SuspendMonitor( | 58 remoting.suspendMonitor = new remoting.SuspendMonitor( |
54 function() { | 59 function() { |
55 if (remoting.clientSession) { | 60 if (remoting.clientSession) { |
56 remoting.clientSession.logErrors(false); | 61 remoting.clientSession.logErrors(false); |
57 } | 62 } |
58 } | 63 } |
59 ); | 64 ); |
60 | 65 |
61 remoting.oauth2.getEmail(remoting.onEmail, remoting.showErrorMessage); | 66 remoting.identity.getEmail(remoting.onEmail, remoting.showErrorMessage); |
62 | 67 |
63 remoting.showOrHideIt2MeUi(); | 68 remoting.showOrHideIt2MeUi(); |
64 remoting.showOrHideMe2MeUi(); | 69 remoting.showOrHideMe2MeUi(); |
65 | 70 |
66 // The plugin's onFocus handler sends a paste command to |window|, because | 71 // The plugin's onFocus handler sends a paste command to |window|, because |
67 // it can't send one to the plugin element itself. | 72 // it can't send one to the plugin element itself. |
68 window.addEventListener('paste', pluginGotPaste_, false); | 73 window.addEventListener('paste', pluginGotPaste_, false); |
69 window.addEventListener('copy', pluginGotCopy_, false); | 74 window.addEventListener('copy', pluginGotCopy_, false); |
70 | 75 |
71 remoting.initModalDialogs(); | 76 remoting.initModalDialogs(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 document.getElementById('get-started-it2me').disabled = false; | 111 document.getElementById('get-started-it2me').disabled = false; |
107 document.getElementById('get-started-me2me').disabled = false; | 112 document.getElementById('get-started-me2me').disabled = false; |
108 }; | 113 }; |
109 | 114 |
110 // initDaemonUi is called if the app is not starting up in session mode, and | 115 // initDaemonUi is called if the app is not starting up in session mode, and |
111 // also if the user cancels pin entry or the connection in session mode. | 116 // also if the user cancels pin entry or the connection in session mode. |
112 remoting.initDaemonUi = function () { | 117 remoting.initDaemonUi = function () { |
113 remoting.hostController = new remoting.HostController(); | 118 remoting.hostController = new remoting.HostController(); |
114 document.getElementById('share-button').disabled = | 119 document.getElementById('share-button').disabled = |
115 !remoting.hostController.isPluginSupported(); | 120 !remoting.hostController.isPluginSupported(); |
116 remoting.setMode(getAppStartupMode_()); | 121 remoting.setMode(remoting.AppMode.HOME); |
122 if (!remoting.oauth2.isAuthenticated()) { | |
Wez
2013/01/05 00:04:24
Is there an equivalent to isAuthenticated() for th
Jamie
2013/01/05 01:32:54
I don't think so.
rmsousa
2013/01/05 05:21:11
I'm not sure we need to do this here at all. For a
Jamie
2013/01/07 23:52:20
The problem with that approach is that the apps v2
Wez
2013/01/07 23:52:44
The one distinction between the identity and OAuth
| |
123 document.getElementById('auth-dialog').hidden = false; | |
124 } | |
117 remoting.hostSetupDialog = | 125 remoting.hostSetupDialog = |
118 new remoting.HostSetupDialog(remoting.hostController); | 126 new remoting.HostSetupDialog(remoting.hostController); |
119 // Display the cached host list, then asynchronously update and re-display it. | 127 // Display the cached host list, then asynchronously update and re-display it. |
120 remoting.updateLocalHostState(); | 128 remoting.updateLocalHostState(); |
121 remoting.hostList.refresh(remoting.updateLocalHostState); | 129 remoting.hostList.refresh(remoting.updateLocalHostState); |
122 }; | 130 }; |
123 | 131 |
124 /** | 132 /** |
125 * Fetches local host state and updates host list accordingly. | 133 * Fetches local host state and updates host list accordingly. |
126 */ | 134 */ |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
183 | 191 |
184 /** | 192 /** |
185 * Sign the user out of Chromoting by clearing (and revoking, if possible) the | 193 * Sign the user out of Chromoting by clearing (and revoking, if possible) the |
186 * OAuth refresh token. | 194 * OAuth refresh token. |
187 * | 195 * |
188 * Also clear all local storage, to avoid leaking information. | 196 * Also clear all local storage, to avoid leaking information. |
189 */ | 197 */ |
190 remoting.signOut = function() { | 198 remoting.signOut = function() { |
191 remoting.oauth2.clear(); | 199 remoting.oauth2.clear(); |
192 chrome.storage.local.clear(); | 200 chrome.storage.local.clear(); |
193 remoting.setMode(remoting.AppMode.UNAUTHENTICATED); | 201 remoting.setMode(remoting.AppMode.HOME); |
202 document.getElementById('auth-dialog').hidden = false; | |
194 }; | 203 }; |
195 | 204 |
196 /** | 205 /** |
197 * Returns whether the app is running on ChromeOS. | 206 * Returns whether the app is running on ChromeOS. |
198 * | 207 * |
199 * @return {boolean} True if the app is running on ChromeOS. | 208 * @return {boolean} True if the app is running on ChromeOS. |
200 */ | 209 */ |
201 remoting.runningOnChromeOS = function() { | 210 remoting.runningOnChromeOS = function() { |
202 return !!navigator.userAgent.match(/\bCrOS\b/); | 211 return !!navigator.userAgent.match(/\bCrOS\b/); |
203 } | 212 } |
(...skipping 21 matching lines...) Expand all Loading... | |
225 var event = /** @type {remoting.ClipboardEvent} */ eventUncast; | 234 var event = /** @type {remoting.ClipboardEvent} */ eventUncast; |
226 if (event && event.clipboardData) { | 235 if (event && event.clipboardData) { |
227 if (remoting.clipboard.toOs(event.clipboardData)) { | 236 if (remoting.clipboard.toOs(event.clipboardData)) { |
228 // The default action may overwrite items that we added to clipboardData. | 237 // The default action may overwrite items that we added to clipboardData. |
229 event.preventDefault(); | 238 event.preventDefault(); |
230 } | 239 } |
231 } | 240 } |
232 } | 241 } |
233 | 242 |
234 /** | 243 /** |
235 * Gets the major-mode that this application should start up in. | |
236 * | |
237 * @return {remoting.AppMode} The mode to start in. | |
238 */ | |
239 function getAppStartupMode_() { | |
240 if (!remoting.oauth2.isAuthenticated()) { | |
241 return remoting.AppMode.UNAUTHENTICATED; | |
242 } | |
243 return remoting.AppMode.HOME; | |
244 } | |
245 | |
246 /** | |
247 * Returns whether Host mode is supported on this platform. | 244 * Returns whether Host mode is supported on this platform. |
248 * | 245 * |
249 * @return {boolean} True if Host mode is supported. | 246 * @return {boolean} True if Host mode is supported. |
250 */ | 247 */ |
251 function isHostModeSupported_() { | 248 function isHostModeSupported_() { |
252 // Currently, sharing on Chromebooks is not supported. | 249 // Currently, sharing on Chromebooks is not supported. |
253 return !remoting.runningOnChromeOS(); | 250 return !remoting.runningOnChromeOS(); |
254 } | 251 } |
255 | 252 |
256 /** | 253 /** |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
313 */ | 310 */ |
314 remoting.showErrorMessage = function(error) { | 311 remoting.showErrorMessage = function(error) { |
315 l10n.localizeElementFromTag( | 312 l10n.localizeElementFromTag( |
316 document.getElementById('token-refresh-error-message'), | 313 document.getElementById('token-refresh-error-message'), |
317 error); | 314 error); |
318 var auth_failed = (error == remoting.Error.AUTHENTICATION_FAILED); | 315 var auth_failed = (error == remoting.Error.AUTHENTICATION_FAILED); |
319 document.getElementById('token-refresh-auth-failed').hidden = !auth_failed; | 316 document.getElementById('token-refresh-auth-failed').hidden = !auth_failed; |
320 document.getElementById('token-refresh-other-error').hidden = auth_failed; | 317 document.getElementById('token-refresh-other-error').hidden = auth_failed; |
321 remoting.setMode(remoting.AppMode.TOKEN_REFRESH_FAILED); | 318 remoting.setMode(remoting.AppMode.TOKEN_REFRESH_FAILED); |
322 }; | 319 }; |
OLD | NEW |