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

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

Issue 981723003: Add application pre-authorization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 * @fileoverview 6 * @fileoverview
7 * This class implements the functionality that is specific to desktop 7 * This class implements the functionality that is specific to desktop
8 * remoting ("Chromoting" or CRD). 8 * remoting ("Chromoting" or CRD).
9 */ 9 */
10 10
(...skipping 23 matching lines...) Expand all
34 * Whether to refresh the JID and retry the connection if the current JID 34 * Whether to refresh the JID and retry the connection if the current JID
35 * is offline. 35 * is offline.
36 * 36 *
37 * @type {boolean} 37 * @type {boolean}
38 * @private 38 * @private
39 */ 39 */
40 this.refreshHostJidIfOffline_ = true; 40 this.refreshHostJidIfOffline_ = true;
41 }; 41 };
42 42
43 /** 43 /**
44 * Display the user's email address and allow access to the rest of the app,
45 * including parsing URL parameters.
46 *
47 * @param {string} email The user's email address.
48 * @param {string} fullName The user's full name. This is always null since
49 * CRD doesn't request userinfo.profile permission.
50 * @return {void} Nothing.
51 */
52 remoting.onUserInfoAvailable = function(email, fullName) {
53 document.getElementById('current-email').innerText = email;
54 document.getElementById('get-started-it2me').disabled = false;
55 document.getElementById('get-started-me2me').disabled = false;
56 };
57
58 /**
59 * Initialize the application and register all event handlers. After this 44 * Initialize the application and register all event handlers. After this
60 * is called, the app is running and waiting for user events. 45 * is called, the app is running and waiting for user events.
61 * 46 *
62 * @return {void} Nothing. 47 * @return {void} Nothing.
63 */ 48 */
64 remoting.DesktopRemoting.prototype.init = function() { 49 remoting.DesktopRemoting.prototype.init = function() {
65 remoting.initGlobalObjects();
66 remoting.initIdentity(remoting.onUserInfoAvailable);
67
68 remoting.initElementEventHandlers(); 50 remoting.initElementEventHandlers();
69 51
70 if (base.isAppsV2()) { 52 if (base.isAppsV2()) {
71 remoting.windowFrame = new remoting.WindowFrame( 53 remoting.windowFrame = new remoting.WindowFrame(
72 document.getElementById('title-bar')); 54 document.getElementById('title-bar'));
73 remoting.optionsMenu = remoting.windowFrame.createOptionsMenu(); 55 remoting.optionsMenu = remoting.windowFrame.createOptionsMenu();
74 56
75 var START_FULLSCREEN = 'start-fullscreen'; 57 var START_FULLSCREEN = 'start-fullscreen';
76 remoting.fullscreen = new remoting.FullscreenAppsV2(); 58 remoting.fullscreen = new remoting.FullscreenAppsV2();
77 remoting.fullscreen.addListener(function(isFullscreen) { 59 remoting.fullscreen.addListener(function(isFullscreen) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 document.getElementById('startup-mode-box-it2me').hidden = false; 118 document.getElementById('startup-mode-box-it2me').hidden = false;
137 } 119 }
138 }; 120 };
139 isWindowed_(onIsWindowed); 121 isWindowed_(onIsWindowed);
140 } 122 }
141 123
142 remoting.ClientPlugin.factory.preloadPlugin(); 124 remoting.ClientPlugin.factory.preloadPlugin();
143 } 125 }
144 126
145 /** 127 /**
128 * Start the application. Once start() is called, the delegate can assume that
129 * the user has consented to all permissions specified in the manifest.
130 *
131 * @param {remoting.SessionConnector} connector
132 * @param {string} token An OAuth access token. The delegate should not cache
133 * this token, but can assume that it will remain valid during application
134 * start-up.
135 */
136 remoting.DesktopRemoting.prototype.start = function(connector, token) {
137 remoting.identity.getEmail().then(
138 function(/** string */ email) {
139 document.getElementById('current-email').innerText = email;
140 document.getElementById('get-started-it2me').disabled = false;
141 document.getElementById('get-started-me2me').disabled = false;
142 });
143 };
144
145 /**
146 * Report an authentication error to the user. This is called in lieu of start()
147 * if the user cannot be authenticated or if they decline the app permissions.
148 *
149 * @param {remoting.Error} error The failure reason.
150 */
151 remoting.DesktopRemoting.prototype.signInFailed = function(error) {
152 if (error == remoting.Error.CANCELLED) {
153 chrome.app.window.current().close();
garykac 2015/03/05 02:38:25 if AppsV2?
Jamie 2015/03/05 19:01:36 I'm assuming that there is only apps v2 for this c
garykac 2015/03/06 21:16:25 Acknowledged.
154 } else {
155 remoting.showErrorMessage(error);
156 }
157 };
158
159 /**
146 * @return {string} Application product name to be used in UI. 160 * @return {string} Application product name to be used in UI.
147 */ 161 */
148 remoting.DesktopRemoting.prototype.getApplicationName = function() { 162 remoting.DesktopRemoting.prototype.getApplicationName = function() {
149 return chrome.i18n.getMessage(/*i18n-content*/'PRODUCT_NAME'); 163 return chrome.i18n.getMessage(/*i18n-content*/'PRODUCT_NAME');
150 }; 164 };
151 165
152 /** 166 /**
153 * @return {string} The default remap keys for the current platform. 167 * @return {string} The default remap keys for the current platform.
154 */ 168 */
155 remoting.DesktopRemoting.prototype.getDefaultRemapKeys = function() { 169 remoting.DesktopRemoting.prototype.getDefaultRemapKeys = function() {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 clientSession.requestPairing(clientName, onPairingComplete); 240 clientSession.requestPairing(clientName, onPairingComplete);
227 } 241 }
228 }; 242 };
229 243
230 /** 244 /**
231 * Called when the current session has been disconnected. 245 * Called when the current session has been disconnected.
232 * 246 *
233 * @return {void} Nothing. 247 * @return {void} Nothing.
234 */ 248 */
235 remoting.DesktopRemoting.prototype.handleDisconnected = function() { 249 remoting.DesktopRemoting.prototype.handleDisconnected = function() {
236 }; 250 };
garykac 2015/03/05 02:38:26 if AppsV2, then chrome.app.window.current().close?
Jamie 2015/03/05 19:01:36 No, we don't want to close the widow on disconnect
garykac 2015/03/06 21:16:25 Acknowledged.
237 251
238 /** 252 /**
239 * Called when the current session's connection has failed. 253 * Called when the current session's connection has failed.
240 * 254 *
241 * @param {remoting.SessionConnector} connector 255 * @param {remoting.SessionConnector} connector
242 * @param {remoting.Error} error 256 * @param {remoting.Error} error
243 * @return {void} Nothing. 257 * @return {void} Nothing.
244 */ 258 */
245 remoting.DesktopRemoting.prototype.handleConnectionFailed = function( 259 remoting.DesktopRemoting.prototype.handleConnectionFailed = function(
246 connector, error) { 260 connector, error) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 l10n.localizeElementFromTag(errorDiv, /** @type {string} */ (errorTag)); 325 l10n.localizeElementFromTag(errorDiv, /** @type {string} */ (errorTag));
312 326
313 var mode = remoting.clientSession ? remoting.desktopConnectedView.getMode() 327 var mode = remoting.clientSession ? remoting.desktopConnectedView.getMode()
314 : this.app_.getSessionConnector().getConnectionMode(); 328 : this.app_.getSessionConnector().getConnectionMode();
315 if (mode == remoting.DesktopConnectedView.Mode.IT2ME) { 329 if (mode == remoting.DesktopConnectedView.Mode.IT2ME) {
316 remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_IT2ME); 330 remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_IT2ME);
317 } else { 331 } else {
318 remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_ME2ME); 332 remoting.setMode(remoting.AppMode.CLIENT_CONNECT_FAILED_ME2ME);
319 } 333 }
320 }; 334 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698