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

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

Issue 896003002: Use the local user's email when connecting to It2MeHelpeeChannel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@HRD_V2Auth
Patch Set: 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 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 /** @suppress {duplicate} */ 5 /** @suppress {duplicate} */
6 var remoting = remoting || {}; 6 var remoting = remoting || {};
7 7
8 (function(){ 8 (function(){
9 9
10 'use strict'; 10 'use strict';
11 11
12 var ENABLE_HANGOUT_REMOTE_ASSISTANCE = true;
13
12 /** 14 /**
13 * The background service is responsible for listening to incoming connection 15 * @constructor
14 * requests from Hangouts and the webapp. 16 */
17 var BackgroundPage = function() {
18 /**
19 * @type {remoting.AppLauncher}
dcaiafa 2015/02/04 00:12:35 nit: do you guys know about the short form of this
kelvinp 2015/02/04 00:38:13 Glad to know. I love it. Done.
20 * @private
21 */
22 this.appLauncher_ = null;
23 /**
24 * @type {remoting.ActivationHandler}
25 * @private
26 */
27 this.activationHandler_ = null;
28 /**
29 * @type {remoting.It2MeService}
30 * @private
31 */
32 this.it2meService_ = null;
33 /**
34 * @type {base.Disposables}
35 * @private
36 */
37 this.disposables_ = null;
38
39 this.preInit_();
40 this.onResumed_();
41
42 chrome.runtime.onSuspendCanceled.addListener(this.onResumed_.bind(this));
43 chrome.runtime.onSuspend.addListener(this.onSuspended_.bind(this));
44 };
45
46 /**
47 * Initialize members and globals that are valid throughout the entire lifetime
48 * of the background page.
15 * 49 *
16 * @param {remoting.AppLauncher} appLauncher 50 * @private
17 */ 51 */
18 function initializeBackgroundService(appLauncher) { 52 BackgroundPage.prototype.preInit_ = function() {
19 function initializeIt2MeService() { 53 remoting.settings = new remoting.Settings();
20 /** @type {remoting.It2MeService} */ 54 if (base.isAppsV2()) {
21 remoting.it2meService = new remoting.It2MeService(appLauncher); 55 remoting.identity = new remoting.Identity();
22 remoting.it2meService.init(); 56 } else {
57 remoting.oauth2 = new remoting.OAuth2();
58 var oauth2 = /** @type {*} */ (remoting.oauth2);
59 remoting.identity = /** @type {remoting.Identity} */ (oauth2);
23 } 60 }
24 61
25 chrome.runtime.onSuspend.addListener(function() {
26 base.debug.assert(remoting.it2meService != null);
27 remoting.it2meService.dispose();
28 remoting.it2meService = null;
29 });
30
31 remoting.settings = new remoting.Settings();
32
33 chrome.runtime.onSuspendCanceled.addListener(initializeIt2MeService);
34 initializeIt2MeService();
35 }
36
37 function main() {
38 if (base.isAppsV2()) { 62 if (base.isAppsV2()) {
39 new remoting.ActivationHandler(base.Ipc.getInstance(), 63 this.appLauncher_ = new remoting.V2AppLauncher();
40 new remoting.V2AppLauncher()); 64 this.activationHandler_ = new remoting.ActivationHandler(
65 base.Ipc.getInstance(), this.appLauncher_);
66 } else {
67 this.appLauncher_ = new remoting.V1AppLauncher();
68 this.activationHandler_ = new base.Disposables();
dcaiafa 2015/02/04 00:12:35 Why can't this be just null? It's never disposed o
kelvinp 2015/02/04 00:38:13 It is artifacts from a previous experiment. Remov
41 } 69 }
42 }
43
44 remoting.enableHangoutsRemoteAssistance = function() {
45 /** @type {remoting.AppLauncher} */
46 var appLauncher = base.isAppsV2() ? new remoting.V1AppLauncher():
47 new remoting.V2AppLauncher();
48 initializeBackgroundService(appLauncher);
49 }; 70 };
50 71
51 window.addEventListener('load', main, false); 72 /** @private */
73 BackgroundPage.prototype.onResumed_ = function() {
74 if (ENABLE_HANGOUT_REMOTE_ASSISTANCE) {
75 this.it2meService_ = new remoting.It2MeService(this.appLauncher_);
76 this.it2meService_.init();
77 this.disposables_ = new base.Disposables(this.it2meService_);
78 }
79 };
80
81 /** @private */
82 BackgroundPage.prototype.onSuspended_ = function() {
83 this.it2meService_ = null;
84 base.dispose(this.disposables_);
85 this.disposables_ = null;
86 };
87
88 window.addEventListener('load', function() {
89 remoting.backgroundPage = new BackgroundPage();
90 }, false);
52 91
53 }()); 92 }());
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698