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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 /**
6 * @fileoverview
7 * Class to communicate with the background scripts via chrome runtime
8 * messages to
9 * 1. Forward session state notifications
10 * 2. Closes the window when the session terminates
11 */
12
13 'use strict';
14
15 /** @suppress {duplicate} */
16 var remoting = remoting || {};
17
18 /**
19 * @constructor
20 */
21 remoting.HangoutSession = function() {
22 /**
23 * @private
24 * @type {chrome.extension.Port}
25 */
26 this.port_ = null;
27 };
28
29 remoting.HangoutSession.prototype.init = function() {
30 this.port_ = chrome.runtime.connect({name: 'it2me.helper.webapp'});
31
32 /** @type {base.EventSource} */
33 var HangoutSessionEvents = remoting.HangoutSessionEvents;
Jamie 2014/08/07 23:12:35 No need for this assignment.
kelvinp 2014/08/08 01:14:22 Done.
34 HangoutSessionEvents.addEventListener(
35 remoting.HangoutSessionEvents.sessionStateChanged,
36 this.onSessionStateChanged_.bind(this));
37 };
38
39 /**
40 * @param {remoting.HangoutSessionEvents.SessionStates} state
41 */
42 remoting.HangoutSession.prototype.onSessionStateChanged_ = function(state) {
43 var State = remoting.HangoutSessionEvents.SessionStates;
44 try {
45 this.port_.postMessage({method: 'sessionStateChanged', state: state});
46 } catch (e) {
47 // postMessage will throw an exception if the port is disconnected.
48 // We can safely ignore this exception.
49 } finally {
50 if (state === State.ERROR || state === State.CLOSED) {
51 // close the current window
52 if (remoting.isAppsV2) {
53 chrome.app.window.current().close();
54 } else {
55 window.close();
56 }
57 }
58 }
59 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698