Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(268)

Unified Diff: remoting/webapp/hangout_session.js

Issue 439923002: Hangout remote desktop part I - It2Me mode (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address CR Feedback Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: remoting/webapp/hangout_session.js
diff --git a/remoting/webapp/hangout_session.js b/remoting/webapp/hangout_session.js
new file mode 100644
index 0000000000000000000000000000000000000000..ce04da30fa7afef6cc8f67aabff185c408d817ec
--- /dev/null
+++ b/remoting/webapp/hangout_session.js
@@ -0,0 +1,59 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * @fileoverview
+ * Class to communicate with the background scripts via chrome runtime
+ * messages to
+ * 1. Forward session state notifications
+ * 2. Closes the window when the session terminates
+ */
+
+'use strict';
+
+/** @suppress {duplicate} */
+var remoting = remoting || {};
+
+/**
+ * @constructor
+ */
+remoting.HangoutSession = function() {
+ /**
+ * @private
+ * @type {chrome.extension.Port}
+ */
+ this.port_ = null;
+};
+
+remoting.HangoutSession.prototype.init = function() {
+ this.port_ = chrome.runtime.connect({name: 'it2me.helper.webapp'});
+
+ /** @type {base.EventSource} */
+ var HangoutSessionEvents = remoting.HangoutSessionEvents;
Jamie 2014/08/07 23:12:35 No need for this assignment.
kelvinp 2014/08/08 01:14:22 Done.
+ HangoutSessionEvents.addEventListener(
+ remoting.HangoutSessionEvents.sessionStateChanged,
+ this.onSessionStateChanged_.bind(this));
+};
+
+/**
+ * @param {remoting.HangoutSessionEvents.SessionStates} state
+ */
+remoting.HangoutSession.prototype.onSessionStateChanged_ = function(state) {
+ var State = remoting.HangoutSessionEvents.SessionStates;
+ try {
+ this.port_.postMessage({method: 'sessionStateChanged', state: state});
+ } catch (e) {
+ // postMessage will throw an exception if the port is disconnected.
+ // We can safely ignore this exception.
+ } finally {
+ if (state === State.ERROR || state === State.CLOSED) {
+ // close the current window
+ if (remoting.isAppsV2) {
+ chrome.app.window.current().close();
+ } else {
+ window.close();
+ }
+ }
+ }
+};

Powered by Google App Engine
This is Rietveld 408576698