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

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: Fix unit test failure and rebase 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
« no previous file with comments | « remoting/webapp/base/js/base.js ('k') | remoting/webapp/crd/js/identity.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 /** @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 /** @private {remoting.AppLauncher} */
19 this.appLauncher_ = null;
20 /** @private {remoting.ActivationHandler} */
21 this.activationHandler_ = null;
22 /** @private {remoting.It2MeService} */
23 this.it2meService_ = null;
24 /** @private {base.Disposables} */
25 this.disposables_ = null;
26
27 this.preInit_();
28 this.onResumed_();
29
30 chrome.runtime.onSuspendCanceled.addListener(this.onResumed_.bind(this));
31 chrome.runtime.onSuspend.addListener(this.onSuspended_.bind(this));
32 };
33
34 /**
35 * Initialize members and globals that are valid throughout the entire lifetime
36 * of the background page.
15 * 37 *
16 * @param {remoting.AppLauncher} appLauncher 38 * @private
17 */ 39 */
18 function initializeBackgroundService(appLauncher) { 40 BackgroundPage.prototype.preInit_ = function() {
19 function initializeIt2MeService() { 41 remoting.settings = new remoting.Settings();
20 /** @type {remoting.It2MeService} */ 42 if (base.isAppsV2()) {
21 remoting.it2meService = new remoting.It2MeService(appLauncher); 43 remoting.identity = new remoting.Identity();
22 remoting.it2meService.init(); 44 } else {
45 remoting.oauth2 = new remoting.OAuth2();
46 var oauth2 = /** @type {*} */ (remoting.oauth2);
47 remoting.identity = /** @type {remoting.Identity} */ (oauth2);
23 } 48 }
24 49
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()) { 50 if (base.isAppsV2()) {
39 new remoting.ActivationHandler(base.Ipc.getInstance(), 51 this.appLauncher_ = new remoting.V2AppLauncher();
40 new remoting.V2AppLauncher()); 52 this.activationHandler_ = new remoting.ActivationHandler(
53 base.Ipc.getInstance(), this.appLauncher_);
54 } else {
55 this.appLauncher_ = new remoting.V1AppLauncher();
41 } 56 }
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 }; 57 };
50 58
51 window.addEventListener('load', main, false); 59 /** @private */
60 BackgroundPage.prototype.onResumed_ = function() {
61 if (ENABLE_HANGOUT_REMOTE_ASSISTANCE) {
62 this.it2meService_ = new remoting.It2MeService(this.appLauncher_);
63 this.it2meService_.init();
64 this.disposables_ = new base.Disposables(this.it2meService_);
65 }
66 };
67
68 /** @private */
69 BackgroundPage.prototype.onSuspended_ = function() {
70 this.it2meService_ = null;
71 base.dispose(this.disposables_);
72 this.disposables_ = null;
73 };
74
75 window.addEventListener('load', function() {
76 remoting.backgroundPage = new BackgroundPage();
77 }, false);
52 78
53 }()); 79 }());
OLDNEW
« no previous file with comments | « remoting/webapp/base/js/base.js ('k') | remoting/webapp/crd/js/identity.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698