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

Unified Diff: remoting/webapp/hrd_helper_session.js

Issue 439923002: Hangout remote desktop part I - It2Me mode (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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/hrd_helper_session.js
diff --git a/remoting/webapp/hrd_helper_session.js b/remoting/webapp/hrd_helper_session.js
new file mode 100644
index 0000000000000000000000000000000000000000..1e1f0e847354d5ed36c98ef4c13d084e2fba3c98
--- /dev/null
+++ b/remoting/webapp/hrd_helper_session.js
@@ -0,0 +1,52 @@
+// 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 it2me background service via chrome runtime
+ * messages.
Jamie 2014/08/05 21:15:14 To do what? AFAICT, this class does two things: 1
kelvinp 2014/08/07 18:03:25 Done.
+ */
+
+'use strict';
+
+/** @suppress {duplicate} */
+var remoting = remoting || {};
+
+/**
+ * @constructor
+ */
+remoting.HRDHelperSession = function() {
Jamie 2014/08/05 21:15:14 Can you come up with something more descriptive th
kelvinp 2014/08/07 18:03:25 Done.
+ /** @type {chrome.extension.Port} */
Jamie 2014/08/05 21:15:14 Add @private?
kelvinp 2014/08/07 18:03:25 Done.
+ this.port_ = null;
+ this.onSessionStateChangedHandler_ = this.onSessionStateChanged_.bind(this);
Jamie 2014/08/05 21:15:13 You only use this in one place, so there's no need
kelvinp 2014/08/07 18:03:25 Done.
+};
+
+remoting.HRDHelperSession.prototype.init = function() {
+ this.port_ = chrome.runtime.connect({name: 'it2me.helper.webapp'});
Jamie 2014/08/05 21:15:13 Are you missing an extension id here? Without one,
kelvinp 2014/08/07 18:03:25 This is intended. According to the documentation,
+
+ /** @type {base.EventSource} */
+ var hrdSessionEvents = remoting.hrdSessionEvents;
+ hrdSessionEvents.addEventListener('sessionStateChanged',
+ this.onSessionStateChangedHandler_);
+};
+
+/**
+ * @param {remoting.hrdSessionEvents.SessionStates} state
+ */
+remoting.HRDHelperSession.prototype.onSessionStateChanged_ = function(state) {
+ var State = remoting.hrdSessionEvents.SessionStates;
+ try {
+ this.port_.postMessage({method: 'sessionStateChanged', state: state});
+ } catch (e) {
Jamie 2014/08/05 21:15:13 This ignores any errors. Is that what you want? If
kelvinp 2014/08/07 18:03:25 Done.
+ } 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