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 || {};
10 /** @return {boolean} */
12 var manifest = chrome.runtime.getManifest();
13 if (manifest && manifest.app && manifest.app.background) {
19 /** @param {remoting.AppLauncher} appLauncher */
20 function initializeAppV2(appLauncher) {
22 var kNewWindowId = 'new-window';
24 /** @param {OnClickData} info */
25 function onContextMenu(info) {
26 if (info.menuItemId == kNewWindowId) {
31 function initializeContextMenu() {
32 chrome.contextMenus.create({
34 contexts: ['launcher'],
35 title: chrome.i18n.getMessage(/*i18n-content*/'NEW_WINDOW')
37 chrome.contextMenus.onClicked.addListener(onContextMenu);
40 initializeContextMenu();
41 chrome.app.runtime.onLaunched.addListener(
42 appLauncher.launch.bind(appLauncher)
47 * The background service is responsible for listening to incoming connection
48 * requests from Hangouts and the webapp.
50 * @param {remoting.AppLauncher} appLauncher
52 function initializeBackgroundService(appLauncher) {
53 function initializeIt2MeService() {
54 /** @type {remoting.It2MeService} */
55 remoting.it2meService = new remoting.It2MeService(appLauncher);
56 remoting.it2meService.init();
59 chrome.runtime.onSuspend.addListener(function() {
60 base.debug.assert(remoting.it2meService != null);
61 remoting.it2meService.dispose();
62 remoting.it2meService = null;
65 chrome.runtime.onSuspendCanceled.addListener(initializeIt2MeService);
66 initializeIt2MeService();
70 /** @type {remoting.AppLauncher} */
71 var appLauncher = new remoting.V1AppLauncher();
73 appLauncher = new remoting.V2AppLauncher();
74 initializeAppV2(appLauncher);
76 initializeBackgroundService(appLauncher);
79 window.addEventListener('load', main, false);