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 /** @param {remoting.AppLauncher} appLauncher */
11 function initializeAppV2(appLauncher) {
13 var kNewWindowId = 'new-window';
15 /** @param {OnClickData} info */
16 function onContextMenu(info) {
17 if (info.menuItemId == kNewWindowId) {
22 function initializeContextMenu() {
23 chrome.contextMenus.create({
25 contexts: ['launcher'],
26 title: chrome.i18n.getMessage(/*i18n-content*/'NEW_WINDOW')
28 chrome.contextMenus.onClicked.addListener(onContextMenu);
31 initializeContextMenu();
32 chrome.app.runtime.onLaunched.addListener(
33 appLauncher.launch.bind(appLauncher)
38 * The background service is responsible for listening to incoming connection
39 * requests from Hangouts and the webapp.
41 * @param {remoting.AppLauncher} appLauncher
43 function initializeBackgroundService(appLauncher) {
44 function initializeIt2MeService() {
45 /** @type {remoting.It2MeService} */
46 remoting.it2meService = new remoting.It2MeService(appLauncher);
47 remoting.it2meService.init();
50 chrome.runtime.onSuspend.addListener(function() {
51 base.debug.assert(remoting.it2meService != null);
52 remoting.it2meService.dispose();
53 remoting.it2meService = null;
56 remoting.settings = new remoting.Settings();
58 chrome.runtime.onSuspendCanceled.addListener(initializeIt2MeService);
59 initializeIt2MeService();
63 /** @type {remoting.AppLauncher} */
64 var appLauncher = new remoting.V1AppLauncher();
65 if (base.isAppsV2()) {
66 appLauncher = new remoting.V2AppLauncher();
67 initializeAppV2(appLauncher);
69 initializeBackgroundService(appLauncher);
72 window.addEventListener('load', main, false);