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

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

Issue 1016623002: [Webapp Refactor] Reparent the ConnectedView into the delegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Please diff this patch against patch set 1 Created 5 years, 9 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * Interface abstracting the Application functionality. 7 * Interface abstracting the Application functionality.
8 */ 8 */
9 9
10 'use strict'; 10 'use strict';
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 * Called when the current session has reached the point where the host has 152 * Called when the current session has reached the point where the host has
153 * started streaming video frames to the client. 153 * started streaming video frames to the client.
154 * 154 *
155 * @return {void} Nothing. 155 * @return {void} Nothing.
156 */ 156 */
157 remoting.Application.prototype.onVideoStreamingStarted = function() { 157 remoting.Application.prototype.onVideoStreamingStarted = function() {
158 this.delegate_.handleVideoStreamingStarted(); 158 this.delegate_.handleVideoStreamingStarted();
159 }; 159 };
160 160
161 /** 161 /**
162 * Called when an extension message needs to be handled.
163 *
164 * @param {string} type The type of the extension message.
165 * @param {string} data The payload of the extension message.
166 * @return {boolean} Return true if the extension message was recognized.
167 */
168 remoting.Application.prototype.onExtensionMessage = function(type, data) {
169 var message = /** @type {Object} */ (base.jsonParseSafe(data));
170 if (typeof message != 'object') {
171 return false;
172 }
173
174 // Give the delegate a chance to handle this extension message first.
175 if (this.delegate_.handleExtensionMessage(type, message)) {
176 return true;
177 }
178
179 if (remoting.desktopConnectedView) {
180 return remoting.desktopConnectedView.handleExtensionMessage(type, message);
181 }
182
183 return false;
184 };
185
186 /**
187 * Called when an error needs to be displayed to the user. 162 * Called when an error needs to be displayed to the user.
188 * 163 *
189 * @param {!remoting.Error} errorTag The error to be localized and displayed. 164 * @param {!remoting.Error} errorTag The error to be localized and displayed.
190 * @return {void} Nothing. 165 * @return {void} Nothing.
191 */ 166 */
192 remoting.Application.prototype.onError = function(errorTag) { 167 remoting.Application.prototype.onError = function(errorTag) {
193 this.delegate_.handleError(errorTag); 168 this.delegate_.handleError(errorTag);
194 }; 169 };
195 170
196 /** 171 /**
197 * @return {remoting.SessionConnector} A session connector, creating a new one 172 * @return {remoting.SessionConnector} A session connector, creating a new one
198 * if necessary. 173 * if necessary.
199 */ 174 */
200 remoting.Application.prototype.getSessionConnector = function() { 175 remoting.Application.prototype.getSessionConnector = function() {
201 // TODO(garykac): Check if this can be initialized in the ctor. 176 // TODO(garykac): Check if this can be initialized in the ctor.
202 if (!this.sessionConnector_) { 177 if (!this.sessionConnector_) {
203 this.sessionConnector_ = remoting.SessionConnector.factory.createConnector( 178 this.sessionConnector_ = remoting.SessionConnector.factory.createConnector(
204 document.getElementById('client-container'), 179 document.getElementById('client-container'),
205 this.onConnected.bind(this), 180 this.onConnected.bind(this),
206 this.onError.bind(this), 181 this.onError.bind(this),
207 this.onExtensionMessage.bind(this),
208 this.onConnectionFailed.bind(this), 182 this.onConnectionFailed.bind(this),
209 this.appCapabilities_, 183 this.appCapabilities_,
210 this.delegate_.getDefaultRemapKeys()); 184 this.delegate_.getDefaultRemapKeys());
211 } 185 }
212 return this.sessionConnector_; 186 return this.sessionConnector_;
213 }; 187 };
214 188
215 /** 189 /**
216 * Callback function called when the state of the client plugin changes. The 190 * Callback function called when the state of the client plugin changes. The
217 * current and previous states are available via the |state| member variable. 191 * current and previous states are available via the |state| member variable.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 /** 301 /**
328 * Called when the current session has reached the point where the host has 302 * Called when the current session has reached the point where the host has
329 * started streaming video frames to the client. 303 * started streaming video frames to the client.
330 * 304 *
331 * @return {void} Nothing. 305 * @return {void} Nothing.
332 */ 306 */
333 remoting.Application.Delegate.prototype.handleVideoStreamingStarted = 307 remoting.Application.Delegate.prototype.handleVideoStreamingStarted =
334 function() {}; 308 function() {};
335 309
336 /** 310 /**
337 * Called when an extension message needs to be handled.
338 *
339 * @param {string} type The type of the extension message.
340 * @param {Object} message The parsed extension message data.
341 * @return {boolean} Return true if the extension message was recognized.
342 */
343 remoting.Application.Delegate.prototype.handleExtensionMessage =
344 function(type, message) {};
345
346 /**
347 * Called when an error needs to be displayed to the user. 311 * Called when an error needs to be displayed to the user.
348 * 312 *
349 * @param {!remoting.Error} errorTag The error to be localized and displayed. 313 * @param {!remoting.Error} errorTag The error to be localized and displayed.
350 * @return {void} Nothing. 314 * @return {void} Nothing.
351 */ 315 */
352 remoting.Application.Delegate.prototype.handleError = function(errorTag) {}; 316 remoting.Application.Delegate.prototype.handleError = function(errorTag) {};
353 317
354 /** 318 /**
355 * Perform any application-specific cleanup before exiting. This is called in 319 * Perform any application-specific cleanup before exiting. This is called in
356 * lieu of start() if the user declines the app permissions, and will usually 320 * lieu of start() if the user declines the app permissions, and will usually
357 * be called immediately prior to exiting, although delegates should not rely 321 * be called immediately prior to exiting, although delegates should not rely
358 * on this. 322 * on this.
359 */ 323 */
360 remoting.Application.Delegate.prototype.handleExit = function() {}; 324 remoting.Application.Delegate.prototype.handleExit = function() {};
361 325
362 326
363 /** @type {remoting.Application} */ 327 /** @type {remoting.Application} */
364 remoting.app = null; 328 remoting.app = null;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698