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