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

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: 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 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(
garykac 2015/03/07 02:16:01 This indentation looks wrong.
Jamie 2015/03/09 17:41:15 Done.
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 * Quit the application.
120 */
121 remoting.Application.prototype.exit = function() {
122 this.delegate_.stop();
123 chrome.app.window.current().close();
107 }; 124 };
108 125
109 /** Disconnect the remoting client. */ 126 /** Disconnect the remoting client. */
110 remoting.Application.prototype.disconnect = function() { 127 remoting.Application.prototype.disconnect = function() {
111 if (remoting.clientSession) { 128 if (remoting.clientSession) {
112 remoting.clientSession.disconnect(remoting.Error.NONE); 129 remoting.clientSession.disconnect(remoting.Error.NONE);
113 console.log('Disconnected.'); 130 console.log('Disconnected.');
114 } 131 }
115 }; 132 };
116 133
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 * the user has consented to all permissions specified in the manifest. 291 * the user has consented to all permissions specified in the manifest.
275 * 292 *
276 * @param {remoting.SessionConnector} connector 293 * @param {remoting.SessionConnector} connector
277 * @param {string} token An OAuth access token. The delegate should not cache 294 * @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 295 * this token, but can assume that it will remain valid during application
279 * start-up. 296 * start-up.
280 */ 297 */
281 remoting.Application.Delegate.prototype.start = function(connector, token) {}; 298 remoting.Application.Delegate.prototype.start = function(connector, token) {};
282 299
283 /** 300 /**
301 * Perform any application-specific cleanup before exiting. This is called in
302 * lieu of start() if the user declines the app permissions, and will usually
303 * be called immediately prior to exiting, although delegates should not rely
304 * on this.
305 */
306 remoting.Application.Delegate.prototype.stop = function() {};
307
308 /**
284 * Report an authentication error to the user. This is called in lieu of start() 309 * 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. 310 * if the user cannot be authenticated.
286 * 311 *
287 * @param {remoting.Error} error The failure reason. 312 * @param {remoting.Error} error The failure reason.
288 */ 313 */
289 remoting.Application.Delegate.prototype.signInFailed = function(error) {}; 314 remoting.Application.Delegate.prototype.signInFailed = function(error) {};
290 315
291 /** 316 /**
292 * @return {string} Application product name to be used in UI. 317 * @return {string} Application product name to be used in UI.
293 */ 318 */
294 remoting.Application.Delegate.prototype.getApplicationName = function() {}; 319 remoting.Application.Delegate.prototype.getApplicationName = function() {};
295 320
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 * Called when an error needs to be displayed to the user. 372 * Called when an error needs to be displayed to the user.
348 * 373 *
349 * @param {remoting.Error} errorTag The error to be localized and displayed. 374 * @param {remoting.Error} errorTag The error to be localized and displayed.
350 * @return {void} Nothing. 375 * @return {void} Nothing.
351 */ 376 */
352 remoting.Application.Delegate.prototype.handleError = function(errorTag) {}; 377 remoting.Application.Delegate.prototype.handleError = function(errorTag) {};
353 378
354 379
355 /** @type {remoting.Application} */ 380 /** @type {remoting.Application} */
356 remoting.app = null; 381 remoting.app = null;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698