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 /** | 10 /** |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 /** | 111 /** |
112 * Sign the user out of Chromoting by clearing (and revoking, if possible) the | 112 * Sign the user out of Chromoting by clearing (and revoking, if possible) the |
113 * OAuth refresh token. | 113 * OAuth refresh token. |
114 * | 114 * |
115 * Also clear all local storage, to avoid leaking information. | 115 * Also clear all local storage, to avoid leaking information. |
116 */ | 116 */ |
117 remoting.signOut = function() { | 117 remoting.signOut = function() { |
118 remoting.oauth2.clear(); | 118 remoting.oauth2.clear(); |
119 chrome.storage.local.clear(); | 119 chrome.storage.local.clear(); |
120 remoting.setMode(remoting.AppMode.HOME); | 120 remoting.setMode(remoting.AppMode.HOME); |
121 document.getElementById('auth-dialog').hidden = false; | 121 remoting.AuthDialog.show().then(function() { |
| 122 remoting.identity.handleAuthFailureAndRelaunch(); |
| 123 }); |
122 }; | 124 }; |
123 | 125 |
124 /** | 126 /** |
125 * Callback function called when the browser window gets a paste operation. | 127 * Callback function called when the browser window gets a paste operation. |
126 * | 128 * |
127 * @param {Event} event | 129 * @param {Event} event |
128 * @return {void} Nothing. | 130 * @return {void} Nothing. |
129 */ | 131 */ |
130 function pluginGotPaste_(event) { | 132 function pluginGotPaste_(event) { |
131 if (event && event.clipboardData) { | 133 if (event && event.clipboardData) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 * Chromoting again. | 194 * Chromoting again. |
193 * | 195 * |
194 * @param {remoting.Error} error | 196 * @param {remoting.Error} error |
195 * @return {void} Nothing. | 197 * @return {void} Nothing. |
196 */ | 198 */ |
197 remoting.showErrorMessage = function(error) { | 199 remoting.showErrorMessage = function(error) { |
198 l10n.localizeElementFromTag( | 200 l10n.localizeElementFromTag( |
199 document.getElementById('token-refresh-error-message'), | 201 document.getElementById('token-refresh-error-message'), |
200 error); | 202 error); |
201 var auth_failed = (error == remoting.Error.AUTHENTICATION_FAILED); | 203 var auth_failed = (error == remoting.Error.AUTHENTICATION_FAILED); |
202 document.getElementById('token-refresh-auth-failed').hidden = !auth_failed; | 204 if (base.isAppsV2()) { |
203 document.getElementById('token-refresh-other-error').hidden = auth_failed; | 205 remoting.identity.handleAuthFailureAndRelaunch(); |
204 remoting.setMode(remoting.AppMode.TOKEN_REFRESH_FAILED); | 206 } else { |
| 207 document.getElementById('token-refresh-auth-failed').hidden = !auth_failed; |
| 208 document.getElementById('token-refresh-other-error').hidden = auth_failed; |
| 209 remoting.setMode(remoting.AppMode.TOKEN_REFRESH_FAILED); |
| 210 } |
205 }; | 211 }; |
206 | 212 |
207 /** | 213 /** |
208 * Determine whether or not the app is running in a window. | 214 * Determine whether or not the app is running in a window. |
209 * @param {function(boolean):void} callback Callback to receive whether or not | 215 * @param {function(boolean):void} callback Callback to receive whether or not |
210 * the current tab is running in windowed mode. | 216 * the current tab is running in windowed mode. |
211 */ | 217 */ |
212 function isWindowed_(callback) { | 218 function isWindowed_(callback) { |
213 /** @param {chrome.Window} win The current window. */ | 219 /** @param {chrome.Window} win The current window. */ |
214 var windowCallback = function(win) { | 220 var windowCallback = function(win) { |
215 callback(win.type == 'popup'); | 221 callback(win.type == 'popup'); |
216 }; | 222 }; |
217 /** @param {chrome.Tab} tab The current tab. */ | 223 /** @param {chrome.Tab} tab The current tab. */ |
218 var tabCallback = function(tab) { | 224 var tabCallback = function(tab) { |
219 if (tab.pinned) { | 225 if (tab.pinned) { |
220 callback(false); | 226 callback(false); |
221 } else { | 227 } else { |
222 chrome.windows.get(tab.windowId, null, windowCallback); | 228 chrome.windows.get(tab.windowId, null, windowCallback); |
223 } | 229 } |
224 }; | 230 }; |
225 if (chrome.tabs) { | 231 if (chrome.tabs) { |
226 chrome.tabs.getCurrent(tabCallback); | 232 chrome.tabs.getCurrent(tabCallback); |
227 } else { | 233 } else { |
228 console.error('chome.tabs is not available.'); | 234 console.error('chome.tabs is not available.'); |
229 } | 235 } |
230 } | 236 } |
231 | 237 |
OLD | NEW |