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
3 // found in the LICENSE file.
5 /** @suppress {duplicate} */
6 var remoting = remoting || {};
12 var ENABLE_HANGOUT_REMOTE_ASSISTANCE = true;
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;
30 chrome.runtime.onSuspendCanceled.addListener(this.onResumed_.bind(this));
31 chrome.runtime.onSuspend.addListener(this.onSuspended_.bind(this));
35 * Initialize members and globals that are valid throughout the entire lifetime
36 * of the background page.
40 BackgroundPage.prototype.preInit_ = function() {
41 remoting.settings = new remoting.Settings();
42 if (base.isAppsV2()) {
43 remoting.identity = new remoting.Identity();
45 remoting.oauth2 = new remoting.OAuth2();
46 var oauth2 = /** @type {*} */ (remoting.oauth2);
47 remoting.identity = /** @type {remoting.Identity} */ (oauth2);
50 if (base.isAppsV2()) {
51 this.appLauncher_ = new remoting.V2AppLauncher();
52 this.activationHandler_ = new remoting.ActivationHandler(
53 base.Ipc.getInstance(), this.appLauncher_);
55 this.appLauncher_ = new remoting.V1AppLauncher();
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_);
69 BackgroundPage.prototype.onSuspended_ = function() {
70 this.it2meService_ = null;
71 base.dispose(this.disposables_);
72 this.disposables_ = null;
75 window.addEventListener('load', function() {
76 remoting.backgroundPage = new BackgroundPage();