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

Side by Side Diff: remoting/webapp/base/js/application.js

Issue 1020743002: [Chromoting] Move app-specific code out of remoting.js (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 * Interface abstracting the Application functionality. 7 * Interface abstracting the Application functionality.
8 */ 8 */
9 9
10 'use strict'; 10 'use strict';
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 this.delegate_.init(); 82 this.delegate_.init();
83 83
84 var that = this; 84 var that = this;
85 remoting.identity.getToken().then( 85 remoting.identity.getToken().then(
86 this.delegate_.start.bind(this.delegate_, this.getSessionConnector()) 86 this.delegate_.start.bind(this.delegate_, this.getSessionConnector())
87 ).catch(remoting.Error.handler( 87 ).catch(remoting.Error.handler(
88 function(/** !remoting.Error */ error) { 88 function(/** !remoting.Error */ error) {
89 if (error.hasTag(remoting.Error.Tag.CANCELLED)) { 89 if (error.hasTag(remoting.Error.Tag.CANCELLED)) {
90 that.exit(); 90 that.exit();
91 } else { 91 } else {
92 that.delegate_.signInFailed(error); 92 that.delegate_.handleAuthError(error);
93 } 93 }
94 } 94 }
95 ) 95 )
96 ); 96 );
97 }; 97 };
98 98
99 /** 99 /**
100 * Quit the application. 100 * Quit the application.
101 */ 101 */
102 remoting.Application.prototype.exit = function() { 102 remoting.Application.prototype.exit = function() {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 * Called when an error needs to be displayed to the user. 162 * Called when an error needs to be displayed to the user.
163 * 163 *
164 * @param {!remoting.Error} errorTag The error to be localized and displayed. 164 * @param {!remoting.Error} errorTag The error to be localized and displayed.
165 * @return {void} Nothing. 165 * @return {void} Nothing.
166 */ 166 */
167 remoting.Application.prototype.onError = function(errorTag) { 167 remoting.Application.prototype.onError = function(errorTag) {
168 this.delegate_.handleError(errorTag); 168 this.delegate_.handleError(errorTag);
169 }; 169 };
170 170
171 /** 171 /**
172 * Called when an auth error needs to be displayed to the user.
173 *
174 * @param {!remoting.Error} errorTag The error to be localized and displayed.
175 * @return {void} Nothing.
176 */
177 remoting.Application.prototype.onAuthError = function(errorTag) {
178 this.delegate_.handleAuthError(errorTag);
179 };
180
181 /**
172 * @return {remoting.SessionConnector} A session connector, creating a new one 182 * @return {remoting.SessionConnector} A session connector, creating a new one
173 * if necessary. 183 * if necessary.
174 */ 184 */
175 remoting.Application.prototype.getSessionConnector = function() { 185 remoting.Application.prototype.getSessionConnector = function() {
176 // TODO(garykac): Check if this can be initialized in the ctor. 186 // TODO(garykac): Check if this can be initialized in the ctor.
177 if (!this.sessionConnector_) { 187 if (!this.sessionConnector_) {
178 this.sessionConnector_ = remoting.SessionConnector.factory.createConnector( 188 this.sessionConnector_ = remoting.SessionConnector.factory.createConnector(
179 document.getElementById('client-container'), 189 document.getElementById('client-container'),
180 this.onConnected.bind(this), 190 this.onConnected.bind(this),
181 this.onError.bind(this), 191 this.onError.bind(this),
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 * the user has consented to all permissions specified in the manifest. 258 * the user has consented to all permissions specified in the manifest.
249 * 259 *
250 * @param {remoting.SessionConnector} connector 260 * @param {remoting.SessionConnector} connector
251 * @param {string} token An OAuth access token. The delegate should not cache 261 * @param {string} token An OAuth access token. The delegate should not cache
252 * this token, but can assume that it will remain valid during application 262 * this token, but can assume that it will remain valid during application
253 * start-up. 263 * start-up.
254 */ 264 */
255 remoting.Application.Delegate.prototype.start = function(connector, token) {}; 265 remoting.Application.Delegate.prototype.start = function(connector, token) {};
256 266
257 /** 267 /**
258 * Report an authentication error to the user. This is called in lieu of start()
259 * if the user cannot be authenticated.
260 *
261 * @param {!remoting.Error} error The failure reason.
262 */
263 remoting.Application.Delegate.prototype.signInFailed = function(error) {};
264
265 /**
266 * @return {string} Application product name to be used in UI. 268 * @return {string} Application product name to be used in UI.
267 */ 269 */
268 remoting.Application.Delegate.prototype.getApplicationName = function() {}; 270 remoting.Application.Delegate.prototype.getApplicationName = function() {};
269 271
270 /** 272 /**
271 * @return {string} The default remap keys for the current platform. 273 * @return {string} The default remap keys for the current platform.
272 */ 274 */
273 remoting.Application.Delegate.prototype.getDefaultRemapKeys = function() {}; 275 remoting.Application.Delegate.prototype.getDefaultRemapKeys = function() {};
274 276
275 /** 277 /**
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 311
310 /** 312 /**
311 * Called when an error needs to be displayed to the user. 313 * Called when an error needs to be displayed to the user.
312 * 314 *
313 * @param {!remoting.Error} errorTag The error to be localized and displayed. 315 * @param {!remoting.Error} errorTag The error to be localized and displayed.
314 * @return {void} Nothing. 316 * @return {void} Nothing.
315 */ 317 */
316 remoting.Application.Delegate.prototype.handleError = function(errorTag) {}; 318 remoting.Application.Delegate.prototype.handleError = function(errorTag) {};
317 319
318 /** 320 /**
321 * Report an authentication error to the user. This is called in lieu of start()
322 * if the user cannot be authenticated.
323 *
324 * @param {!remoting.Error} error The failure reason.
325 */
326 remoting.Application.Delegate.prototype.handleAuthError = function(error) {};
327
328 /**
319 * Perform any application-specific cleanup before exiting. This is called in 329 * Perform any application-specific cleanup before exiting. This is called in
320 * lieu of start() if the user declines the app permissions, and will usually 330 * lieu of start() if the user declines the app permissions, and will usually
321 * be called immediately prior to exiting, although delegates should not rely 331 * be called immediately prior to exiting, although delegates should not rely
322 * on this. 332 * on this.
323 */ 333 */
324 remoting.Application.Delegate.prototype.handleExit = function() {}; 334 remoting.Application.Delegate.prototype.handleExit = function() {};
325 335
326 336
327 /** @type {remoting.Application} */ 337 /** @type {remoting.Application} */
328 remoting.app = null; 338 remoting.app = null;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698