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

Side by Side Diff: remoting/webapp/base/js/application.js

Issue 779613003: [Chromoting] Create core Application interface for CRD. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move setupConnection into Application Created 6 years 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
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 * Interface abstracting the Application functionality.
8 */
9
10 'use strict';
11
12 /** @suppress {duplicate} */
13 var remoting = remoting || {};
14
15 /**
16 * @constructor
17 *
18 * This class implements ApplicationDelegate so that the interface is
19 * consistent with the ApplicationDelegate's.
20 * @implements {remoting.ApplicationDelegate}
Jamie 2014/12/06 00:09:23 Unless you're ever going to want to pass an instan
garykac 2014/12/06 01:39:33 Done.
21 */
22 remoting.Application = function() {
23 /**
24 * @type {remoting.ApplicationDelegate}
25 * @private
26 */
27 this.delegate_ = null;
28
29 /**
30 * @type {remoting.SessionConnector}
31 * @private
32 */
33 this.session_connector_ = null;
34 };
35
36 /**
37 * @param {remoting.ApplicationDelegate} appDelegate The delegate that
38 * contains the app-specific functionality.
39 */
40 remoting.Application.prototype.setDelegate = function(appDelegate) {
41 this.delegate_ = appDelegate;
42 };
43
44 /**
45 * Initialize the application and register all event handlers. After this
46 * is called, the app is running and waiting for user events.
47 *
48 * @return {void} Nothing.
49 */
50 remoting.Application.prototype.init = function() {
51 this.delegate_.init();
52 };
53
54 /**
55 * Called when a new session has been connected.
56 *
57 * @param {remoting.ClientSession} clientSession
58 * @return {void} Nothing.
59 */
60 remoting.Application.prototype.onConnected = function(clientSession) {
61 remoting.clientSession = clientSession;
Jamie 2014/12/06 00:09:23 Long term, this should also be a member variable,
garykac 2014/12/06 01:39:33 Added TODO.
62 remoting.clientSession.addEventListener('stateChanged', onClientStateChange_);
63
64 remoting.clipboard.startSession();
65 updateStatistics_();
66 remoting.hangoutSessionEvents.raiseEvent(
67 remoting.hangoutSessionEvents.sessionStateChanged,
68 remoting.ClientSession.State.CONNECTED
69 );
70
71 this.delegate_.onConnected(clientSession);
72 };
73
74 /**
75 * Called when the current session has been disconnected.
76 *
77 * @return {void} Nothing.
78 */
79 remoting.Application.prototype.onDisconnected = function() {
80 this.delegate_.onDisconnected();
81 };
82
83 /**
84 * Called when the current session has reached the point where the host has
85 * started streaming video frames to the client.
86 *
87 * @return {void} Nothing.
88 */
89 remoting.Application.prototype.onVideoStreamingStarted = function() {
90 this.delegate_.onVideoStreamingStarted();
91 };
92
93 /**
94 * Called when an extension message needs to be handled.
95 *
96 * @param {string} type The type of the extension message.
97 * @param {string} data The payload of the extension message.
98 * @return {boolean} Return true if the extension message was recognized.
99 */
100 remoting.Application.prototype.onExtensionMessage = function(type, data) {
101 return this.delegate_.onExtensionMessage(type, data);
102 };
103
104 /**
105 * Called when an error needs to be displayed to the user.
106 *
107 * @param {remoting.Error} errorTag The error to be localized and displayed.
108 * @return {void} Nothing.
109 */
110 remoting.Application.prototype.onError = function(errorTag) {
111 this.delegate_.onError(errorTag);
112 };
113
114 /**
115 * @return {remoting.SessionConnector} A session connector, creating a new one
116 * if necessary.
117 */
118 remoting.Application.prototype.getSessionConnector = function() {
119 if (!this.session_connector_) {
120 this.session_connector_ = remoting.SessionConnector.factory.createConnector(
121 document.getElementById('video-container'), this);
122 }
123 return this.session_connector_;
124 };
125
126 /** @type {remoting.Application} */
127 remoting.app = null;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698