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

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

Issue 988963003: Add Application.Delegate.stop. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reviewer feedback. 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
« no previous file with comments | « remoting/webapp/app_remoting/js/app_remoting.js ('k') | remoting/webapp/crd/js/app_launcher.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 new remoting.DefaultSessionConnectorFactory(); 94 new remoting.DefaultSessionConnectorFactory();
95 95
96 // TODO(garykac): This should be owned properly rather than living in the 96 // TODO(garykac): This should be owned properly rather than living in the
97 // global 'remoting' namespace. 97 // global 'remoting' namespace.
98 remoting.settings = new remoting.Settings(); 98 remoting.settings = new remoting.Settings();
99 99
100 remoting.initGlobalObjects(); 100 remoting.initGlobalObjects();
101 remoting.initIdentity(); 101 remoting.initIdentity();
102 102
103 this.delegate_.init(); 103 this.delegate_.init();
104
105 var that = this;
104 remoting.identity.getToken().then( 106 remoting.identity.getToken().then(
105 this.delegate_.start.bind(this.delegate_, this.getSessionConnector()), 107 this.delegate_.start.bind(this.delegate_, this.getSessionConnector())
106 remoting.Error.handler(this.delegate_.signInFailed.bind(this.delegate_))); 108 ).catch(remoting.Error.handler(
109 function(/** remoting.Error */ error) {
110 if (error == remoting.Error.CANCELLED) {
111 that.exit();
112 } else {
113 that.delegate_.signInFailed(error);
114 }
115 }
116 )
117 );
118 };
119
120 /**
121 * Quit the application.
122 */
123 remoting.Application.prototype.exit = function() {
124 this.delegate_.handleExit();
125 chrome.app.window.current().close();
107 }; 126 };
108 127
109 /** Disconnect the remoting client. */ 128 /** Disconnect the remoting client. */
110 remoting.Application.prototype.disconnect = function() { 129 remoting.Application.prototype.disconnect = function() {
111 if (remoting.clientSession) { 130 if (remoting.clientSession) {
112 remoting.clientSession.disconnect(remoting.Error.NONE); 131 remoting.clientSession.disconnect(remoting.Error.NONE);
113 console.log('Disconnected.'); 132 console.log('Disconnected.');
114 } 133 }
115 }; 134 };
116 135
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 * 294 *
276 * @param {remoting.SessionConnector} connector 295 * @param {remoting.SessionConnector} connector
277 * @param {string} token An OAuth access token. The delegate should not cache 296 * @param {string} token An OAuth access token. The delegate should not cache
278 * this token, but can assume that it will remain valid during application 297 * this token, but can assume that it will remain valid during application
279 * start-up. 298 * start-up.
280 */ 299 */
281 remoting.Application.Delegate.prototype.start = function(connector, token) {}; 300 remoting.Application.Delegate.prototype.start = function(connector, token) {};
282 301
283 /** 302 /**
284 * Report an authentication error to the user. This is called in lieu of start() 303 * Report an authentication error to the user. This is called in lieu of start()
285 * if the user cannot be authenticated or if they decline the app permissions. 304 * if the user cannot be authenticated.
286 * 305 *
287 * @param {remoting.Error} error The failure reason. 306 * @param {remoting.Error} error The failure reason.
288 */ 307 */
289 remoting.Application.Delegate.prototype.signInFailed = function(error) {}; 308 remoting.Application.Delegate.prototype.signInFailed = function(error) {};
290 309
291 /** 310 /**
292 * @return {string} Application product name to be used in UI. 311 * @return {string} Application product name to be used in UI.
293 */ 312 */
294 remoting.Application.Delegate.prototype.getApplicationName = function() {}; 313 remoting.Application.Delegate.prototype.getApplicationName = function() {};
295 314
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 function(type, message) {}; 363 function(type, message) {};
345 364
346 /** 365 /**
347 * Called when an error needs to be displayed to the user. 366 * Called when an error needs to be displayed to the user.
348 * 367 *
349 * @param {remoting.Error} errorTag The error to be localized and displayed. 368 * @param {remoting.Error} errorTag The error to be localized and displayed.
350 * @return {void} Nothing. 369 * @return {void} Nothing.
351 */ 370 */
352 remoting.Application.Delegate.prototype.handleError = function(errorTag) {}; 371 remoting.Application.Delegate.prototype.handleError = function(errorTag) {};
353 372
373 /**
374 * Perform any application-specific cleanup before exiting. This is called in
375 * lieu of start() if the user declines the app permissions, and will usually
376 * be called immediately prior to exiting, although delegates should not rely
377 * on this.
378 */
379 remoting.Application.Delegate.prototype.handleExit = function() {};
380
354 381
355 /** @type {remoting.Application} */ 382 /** @type {remoting.Application} */
356 remoting.app = null; 383 remoting.app = null;
OLDNEW
« no previous file with comments | « remoting/webapp/app_remoting/js/app_remoting.js ('k') | remoting/webapp/crd/js/app_launcher.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698