Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / remoting / webapp / crd / js / background.js
blob032593507800459c26ac32ed1304b8f900445eca
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 || {};
8 (function(){
10 'use strict';
12 /**
13 * @constructor
15 var BackgroundPage = function() {
16 /** @private {remoting.AppLauncher} */
17 this.appLauncher_ = null;
18 /** @private {remoting.ActivationHandler} */
19 this.activationHandler_ = null;
20 /** @private {remoting.TelemetryEventWriter.Service} */
21 this.telemetryService_ = null;
22 /** @private */
23 this.disposables_ = new base.Disposables();
24 this.preInit_();
27 /**
28 * Initialize members and globals that are valid throughout the entire lifetime
29 * of the background page.
31 * @private
33 BackgroundPage.prototype.preInit_ = function() {
34 remoting.settings = new remoting.Settings();
35 if (base.isAppsV2()) {
36 remoting.identity = new remoting.Identity();
37 } else {
38 remoting.oauth2 = new remoting.OAuth2();
39 var oauth2 = /** @type {*} */ (remoting.oauth2);
40 remoting.identity = /** @type {remoting.Identity} */ (oauth2);
43 if (base.isAppsV2()) {
44 this.appLauncher_ = new remoting.V2AppLauncher();
45 this.telemetryService_ = remoting.TelemetryEventWriter.Service.create();
46 this.telemetryService_.init();
47 this.activationHandler_ = new remoting.ActivationHandler(
48 base.Ipc.getInstance(), this.appLauncher_, this.telemetryService_);
49 this.disposables_.add(new base.EventHook(
50 this.activationHandler_, remoting.ActivationHandler.Events.windowClosed,
51 this.telemetryService_.unbindSession.bind(this.telemetryService_)));
52 } else {
53 this.appLauncher_ = new remoting.V1AppLauncher();
58 window.addEventListener('load', function() {
59 remoting.backgroundPage = new BackgroundPage();
60 }, false);
62 }());