summaryrefslogtreecommitdiffstats
path: root/remoting/webapp/background/background.js
diff options
context:
space:
mode:
Diffstat (limited to 'remoting/webapp/background/background.js')
-rw-r--r--remoting/webapp/background/background.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/remoting/webapp/background/background.js b/remoting/webapp/background/background.js
index 5f26788..28c2010 100644
--- a/remoting/webapp/background/background.js
+++ b/remoting/webapp/background/background.js
@@ -43,6 +43,29 @@ function initializeAppV2(appLauncher) {
);
}
+/**
+ * The background service is responsible for listening to incoming connection
+ * requests from Hangouts and the webapp.
+ *
+ * @param {remoting.AppLauncher} appLauncher
+ */
+function initializeBackgroundService(appLauncher) {
+ function initializeIt2MeService() {
+ /** @type {remoting.It2MeService} */
+ remoting.it2meService = new remoting.It2MeService(appLauncher);
+ remoting.it2meService.init();
+ }
+
+ chrome.runtime.onSuspend.addListener(function() {
+ base.debug.assert(remoting.it2meService != null);
+ remoting.it2meService.dispose();
+ remoting.it2meService = null;
+ });
+
+ chrome.runtime.onSuspendCanceled.addListener(initializeIt2MeService);
+ initializeIt2MeService();
+}
+
function main() {
/** @type {remoting.AppLauncher} */
var appLauncher = new remoting.V1AppLauncher();
@@ -50,6 +73,7 @@ function main() {
appLauncher = new remoting.V2AppLauncher();
initializeAppV2(appLauncher);
}
+ initializeBackgroundService(appLauncher);
}
window.addEventListener('load', main, false);