OLD | NEW |
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 = false; | |
13 | |
14 /** | 12 /** |
15 * @constructor | 13 * @constructor |
16 */ | 14 */ |
17 var BackgroundPage = function() { | 15 var BackgroundPage = function() { |
18 /** @private {remoting.AppLauncher} */ | 16 /** @private {remoting.AppLauncher} */ |
19 this.appLauncher_ = null; | 17 this.appLauncher_ = null; |
20 /** @private {remoting.ActivationHandler} */ | 18 /** @private {remoting.ActivationHandler} */ |
21 this.activationHandler_ = null; | 19 this.activationHandler_ = null; |
22 /** @private {remoting.It2MeService} */ | |
23 this.it2meService_ = null; | |
24 /** @private {base.Disposables} */ | |
25 this.disposables_ = null; | |
26 | |
27 this.preInit_(); | 20 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 }; | 21 }; |
33 | 22 |
34 /** | 23 /** |
35 * Initialize members and globals that are valid throughout the entire lifetime | 24 * Initialize members and globals that are valid throughout the entire lifetime |
36 * of the background page. | 25 * of the background page. |
37 * | 26 * |
38 * @private | 27 * @private |
39 */ | 28 */ |
40 BackgroundPage.prototype.preInit_ = function() { | 29 BackgroundPage.prototype.preInit_ = function() { |
41 remoting.settings = new remoting.Settings(); | 30 remoting.settings = new remoting.Settings(); |
42 if (base.isAppsV2()) { | 31 if (base.isAppsV2()) { |
43 remoting.identity = new remoting.Identity(); | 32 remoting.identity = new remoting.Identity(); |
44 } else { | 33 } else { |
45 remoting.oauth2 = new remoting.OAuth2(); | 34 remoting.oauth2 = new remoting.OAuth2(); |
46 var oauth2 = /** @type {*} */ (remoting.oauth2); | 35 var oauth2 = /** @type {*} */ (remoting.oauth2); |
47 remoting.identity = /** @type {remoting.Identity} */ (oauth2); | 36 remoting.identity = /** @type {remoting.Identity} */ (oauth2); |
48 } | 37 } |
49 | 38 |
50 if (base.isAppsV2()) { | 39 if (base.isAppsV2()) { |
51 this.appLauncher_ = new remoting.V2AppLauncher(); | 40 this.appLauncher_ = new remoting.V2AppLauncher(); |
52 this.activationHandler_ = new remoting.ActivationHandler( | 41 this.activationHandler_ = new remoting.ActivationHandler( |
53 base.Ipc.getInstance(), this.appLauncher_); | 42 base.Ipc.getInstance(), this.appLauncher_); |
54 } else { | 43 } else { |
55 this.appLauncher_ = new remoting.V1AppLauncher(); | 44 this.appLauncher_ = new remoting.V1AppLauncher(); |
56 } | 45 } |
57 }; | 46 }; |
58 | 47 |
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 | 48 |
75 window.addEventListener('load', function() { | 49 window.addEventListener('load', function() { |
76 remoting.backgroundPage = new BackgroundPage(); | 50 remoting.backgroundPage = new BackgroundPage(); |
77 }, false); | 51 }, false); |
78 | 52 |
79 }()); | 53 }()); |
OLD | NEW |