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 /** @return {boolean} */ | 10 /** @return {boolean} */ |
(...skipping 25 matching lines...) Expand all Loading... |
36 }); | 36 }); |
37 chrome.contextMenus.onClicked.addListener(onContextMenu); | 37 chrome.contextMenus.onClicked.addListener(onContextMenu); |
38 } | 38 } |
39 | 39 |
40 initializeContextMenu(); | 40 initializeContextMenu(); |
41 chrome.app.runtime.onLaunched.addListener( | 41 chrome.app.runtime.onLaunched.addListener( |
42 appLauncher.launch.bind(appLauncher) | 42 appLauncher.launch.bind(appLauncher) |
43 ); | 43 ); |
44 } | 44 } |
45 | 45 |
| 46 /** |
| 47 * The background service is responsible for listening to incoming connection |
| 48 * requests from Hangouts and the webapp. |
| 49 * |
| 50 * @param {remoting.AppLauncher} appLauncher |
| 51 */ |
| 52 function initializeBackgroundService(appLauncher) { |
| 53 function initializeIt2MeService() { |
| 54 /** @type {remoting.It2MeService} */ |
| 55 remoting.it2meService = new remoting.It2MeService(appLauncher); |
| 56 remoting.it2meService.init(); |
| 57 } |
| 58 |
| 59 chrome.runtime.onSuspend.addListener(function() { |
| 60 base.debug.assert(remoting.it2meService != null); |
| 61 remoting.it2meService.dispose(); |
| 62 remoting.it2meService = null; |
| 63 }); |
| 64 |
| 65 chrome.runtime.onSuspendCanceled.addListener(initializeIt2MeService); |
| 66 initializeIt2MeService(); |
| 67 } |
| 68 |
46 function main() { | 69 function main() { |
47 /** @type {remoting.AppLauncher} */ | 70 /** @type {remoting.AppLauncher} */ |
48 var appLauncher = new remoting.V1AppLauncher(); | 71 var appLauncher = new remoting.V1AppLauncher(); |
49 if (isAppsV2()) { | 72 if (isAppsV2()) { |
50 appLauncher = new remoting.V2AppLauncher(); | 73 appLauncher = new remoting.V2AppLauncher(); |
51 initializeAppV2(appLauncher); | 74 initializeAppV2(appLauncher); |
52 } | 75 } |
| 76 initializeBackgroundService(appLauncher); |
53 } | 77 } |
54 | 78 |
55 window.addEventListener('load', main, false); | 79 window.addEventListener('load', main, false); |
56 | 80 |
57 }()); | 81 }()); |
OLD | NEW |