Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: remoting/webapp/crd/js/remoting.js

Issue 868203002: Handle authentication failures in the v2 app by restarting the app (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address CL feedback Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 } 108 }
109 }; 109 };
110 110
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.removeCachedAuthToken(function(){
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 window.location.reload();
122 });
122 }; 123 };
123 124
124 /** 125 /**
125 * Callback function called when the browser window gets a paste operation. 126 * Callback function called when the browser window gets a paste operation.
126 * 127 *
127 * @param {Event} event 128 * @param {Event} event
128 * @return {void} Nothing. 129 * @return {void} Nothing.
129 */ 130 */
130 function pluginGotPaste_(event) { 131 function pluginGotPaste_(event) {
131 if (event && event.clipboardData) { 132 if (event && event.clipboardData) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 * Chromoting again. 193 * Chromoting again.
193 * 194 *
194 * @param {remoting.Error} error 195 * @param {remoting.Error} error
195 * @return {void} Nothing. 196 * @return {void} Nothing.
196 */ 197 */
197 remoting.showErrorMessage = function(error) { 198 remoting.showErrorMessage = function(error) {
198 l10n.localizeElementFromTag( 199 l10n.localizeElementFromTag(
199 document.getElementById('token-refresh-error-message'), 200 document.getElementById('token-refresh-error-message'),
200 error); 201 error);
201 var auth_failed = (error == remoting.Error.AUTHENTICATION_FAILED); 202 var auth_failed = (error == remoting.Error.AUTHENTICATION_FAILED);
202 document.getElementById('token-refresh-auth-failed').hidden = !auth_failed; 203 if (base.isAppsV2()) {
203 document.getElementById('token-refresh-other-error').hidden = auth_failed; 204 remoting.handleAuthFailureAndRelaunch();
204 remoting.setMode(remoting.AppMode.TOKEN_REFRESH_FAILED); 205 } else {
206 document.getElementById('token-refresh-auth-failed').hidden = !auth_failed;
207 document.getElementById('token-refresh-other-error').hidden = auth_failed;
208 remoting.setMode(remoting.AppMode.TOKEN_REFRESH_FAILED);
209 }
205 }; 210 };
206 211
207 /** 212 /**
208 * Determine whether or not the app is running in a window. 213 * Determine whether or not the app is running in a window.
209 * @param {function(boolean):void} callback Callback to receive whether or not 214 * @param {function(boolean):void} callback Callback to receive whether or not
210 * the current tab is running in windowed mode. 215 * the current tab is running in windowed mode.
211 */ 216 */
212 function isWindowed_(callback) { 217 function isWindowed_(callback) {
213 /** @param {chrome.Window} win The current window. */ 218 /** @param {chrome.Window} win The current window. */
214 var windowCallback = function(win) { 219 var windowCallback = function(win) {
215 callback(win.type == 'popup'); 220 callback(win.type == 'popup');
216 }; 221 };
217 /** @param {chrome.Tab} tab The current tab. */ 222 /** @param {chrome.Tab} tab The current tab. */
218 var tabCallback = function(tab) { 223 var tabCallback = function(tab) {
219 if (tab.pinned) { 224 if (tab.pinned) {
220 callback(false); 225 callback(false);
221 } else { 226 } else {
222 chrome.windows.get(tab.windowId, null, windowCallback); 227 chrome.windows.get(tab.windowId, null, windowCallback);
223 } 228 }
224 }; 229 };
225 if (chrome.tabs) { 230 if (chrome.tabs) {
226 chrome.tabs.getCurrent(tabCallback); 231 chrome.tabs.getCurrent(tabCallback);
227 } else { 232 } else {
228 console.error('chome.tabs is not available.'); 233 console.error('chome.tabs is not available.');
229 } 234 }
230 } 235 }
231 236
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698