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

Side by Side Diff: extensions/renderer/resources/guest_view/guest_view.js

Issue 857093003: Implemented explicit resizing from guestview. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 // This module implements a wrapper for a guestview that manages its 5 // This module implements a wrapper for a guestview that manages its
6 // creation, attaching, and destruction. 6 // creation, attaching, and destruction.
7 7
8 var EventBindings = require('event_bindings'); 8 var EventBindings = require('event_bindings');
9 var GuestViewInternal = 9 var GuestViewInternal =
10 require('binding').Binding.create('guestViewInternal').generate(); 10 require('binding').Binding.create('guestViewInternal').generate();
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 } 106 }
107 107
108 // Map of possible errors for each action. For each action, the errors are 108 // Map of possible errors for each action. For each action, the errors are
109 // listed for states in the order: GUEST_STATE_START, GUEST_STATE_CREATED, 109 // listed for states in the order: GUEST_STATE_START, GUEST_STATE_CREATED,
110 // GUEST_STATE_ATTACHED. 110 // GUEST_STATE_ATTACHED.
111 var errors = { 111 var errors = {
112 'attach': [ERROR_MSG_NOT_CREATED, null, ERROR_MSG_ALREADY_ATTACHED], 112 'attach': [ERROR_MSG_NOT_CREATED, null, ERROR_MSG_ALREADY_ATTACHED],
113 'create': [null, ERROR_MSG_ALREADY_CREATED, ERROR_MSG_ALREADY_CREATED], 113 'create': [null, ERROR_MSG_ALREADY_CREATED, ERROR_MSG_ALREADY_CREATED],
114 'destroy': [null, null, null], 114 'destroy': [null, null, null],
115 'detach': [ERROR_MSG_NOT_ATTACHED, ERROR_MSG_NOT_ATTACHED, null], 115 'detach': [ERROR_MSG_NOT_ATTACHED, ERROR_MSG_NOT_ATTACHED, null],
116 'setAutoSize': [ERROR_MSG_NOT_CREATED, null, null] 116 'setSize': [ERROR_MSG_NOT_CREATED, null, null]
117 }; 117 };
118 118
119 // Check that the proposed action is a real action. 119 // Check that the proposed action is a real action.
120 if (errors[action] == undefined) { 120 if (errors[action] == undefined) {
121 window.console.error(errorPrefix + ERROR_MSG_INVALID_ACTION); 121 window.console.error(errorPrefix + ERROR_MSG_INVALID_ACTION);
122 return false; 122 return false;
123 } 123 }
124 124
125 // Report the error if the proposed action is found to be invalid for the 125 // Report the error if the proposed action is found to be invalid for the
126 // current state. 126 // current state.
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 243
244 GuestViewInternalNatives.DetachGuest( 244 GuestViewInternalNatives.DetachGuest(
245 this.internalInstanceId, 245 this.internalInstanceId,
246 this.handleCallback.bind(this, callback)); 246 this.handleCallback.bind(this, callback));
247 247
248 this.contentWindow = null; 248 this.contentWindow = null;
249 this.internalInstanceId = 0; 249 this.internalInstanceId = 0;
250 this.state = GUEST_STATE_CREATED; 250 this.state = GUEST_STATE_CREATED;
251 }; 251 };
252 252
253 // Internal implementation of setAutoSize(). 253 // Internal implementation of setSize().
254 GuestViewImpl.prototype.setAutoSizeImpl = function(autoSizeParams, callback) { 254 GuestViewImpl.prototype.setSizeImpl = function(sizeParams, callback) {
255 // Check the current state. 255 // Check the current state.
256 if (!this.checkState('setAutoSize')) { 256 if (!this.checkState('setSize')) {
257 this.handleCallback(callback); 257 this.handleCallback(callback);
258 return; 258 return;
259 } 259 }
260 260
261 GuestViewInternal.setAutoSize(this.id, autoSizeParams, 261 GuestViewInternal.setSize(this.id, sizeParams,
262 this.handleCallback.bind(this, callback)); 262 this.handleCallback.bind(this, callback));
263 }; 263 };
264 264
265 // The exposed interface to a guestview. Exposes in its API the functions 265 // The exposed interface to a guestview. Exposes in its API the functions
266 // attach(), create(), destroy(), and getId(). All other implementation details 266 // attach(), create(), destroy(), and getId(). All other implementation details
267 // are hidden. 267 // are hidden.
268 function GuestView(viewType, guestInstanceId) { 268 function GuestView(viewType, guestInstanceId) {
269 privates(this).internal = new GuestViewImpl(this, viewType, guestInstanceId); 269 privates(this).internal = new GuestViewImpl(this, viewType, guestInstanceId);
270 } 270 }
271 271
272 // Attaches the guestview to the container with ID |internalInstanceId|. 272 // Attaches the guestview to the container with ID |internalInstanceId|.
(...skipping 23 matching lines...) Expand all
296 296
297 // Detaches the guestview from its container. 297 // Detaches the guestview from its container.
298 // Note: This is not currently used. 298 // Note: This is not currently used.
299 GuestView.prototype.detach = function(callback) { 299 GuestView.prototype.detach = function(callback) {
300 var internal = privates(this).internal; 300 var internal = privates(this).internal;
301 internal.actionQueue.push(internal.detachImpl.bind(internal, callback)); 301 internal.actionQueue.push(internal.detachImpl.bind(internal, callback));
302 internal.performNextAction(); 302 internal.performNextAction();
303 }; 303 };
304 304
305 // Adjusts the guestview's sizing parameters. 305 // Adjusts the guestview's sizing parameters.
306 GuestView.prototype.setAutoSize = function(autoSizeParams, callback) { 306 GuestView.prototype.setSize = function(sizeParams, callback) {
307 var internal = privates(this).internal; 307 var internal = privates(this).internal;
308 internal.actionQueue.push(internal.setAutoSizeImpl.bind( 308 internal.actionQueue.push(internal.setSizeImpl.bind(
309 internal, autoSizeParams, callback)); 309 internal, sizeParams, callback));
310 internal.performNextAction(); 310 internal.performNextAction();
311 }; 311 };
312 312
313 // Returns the contentWindow for this guestview. 313 // Returns the contentWindow for this guestview.
314 GuestView.prototype.getContentWindow = function() { 314 GuestView.prototype.getContentWindow = function() {
315 var internal = privates(this).internal; 315 var internal = privates(this).internal;
316 return internal.contentWindow; 316 return internal.contentWindow;
317 }; 317 };
318 318
319 // Returns the ID for this guestview. 319 // Returns the ID for this guestview.
320 GuestView.prototype.getId = function() { 320 GuestView.prototype.getId = function() {
321 var internal = privates(this).internal; 321 var internal = privates(this).internal;
322 return internal.id; 322 return internal.id;
323 }; 323 };
324 324
325 // Exports 325 // Exports
326 exports.GuestView = GuestView; 326 exports.GuestView = GuestView;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698