OLD | NEW |
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 CreateEvent = require('guestViewEvents').CreateEvent; | 8 var CreateEvent = require('guestViewEvents').CreateEvent; |
9 var EventBindings = require('event_bindings'); | 9 var EventBindings = require('event_bindings'); |
10 var GuestViewInternal = | 10 var GuestViewInternal = |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 // current state. | 123 // current state. |
124 var error; | 124 var error; |
125 if (error = errors[action][this.state]) { | 125 if (error = errors[action][this.state]) { |
126 window.console.error(errorPrefix + error); | 126 window.console.error(errorPrefix + error); |
127 return false; | 127 return false; |
128 } | 128 } |
129 | 129 |
130 return true; | 130 return true; |
131 }; | 131 }; |
132 | 132 |
| 133 GuestViewImpl.prototype.setContentWindow = function(contentWindow) { |
| 134 this.contentWindow = contentWindow; |
| 135 }; |
| 136 |
133 // Internal implementation of attach(). | 137 // Internal implementation of attach(). |
134 GuestViewImpl.prototype.attachImpl = function( | 138 GuestViewImpl.prototype.attachImpl = function( |
135 internalInstanceId, viewInstanceId, attachParams, callback) { | 139 internalInstanceId, viewInstanceId, attachParams, callback) { |
136 // Check the current state. | 140 // Check the current state. |
137 if (!this.checkState('attach')) { | 141 if (!this.checkState('attach')) { |
138 this.handleCallback(callback); | 142 this.handleCallback(callback); |
139 return; | 143 return; |
140 } | 144 } |
141 | 145 |
142 // Callback wrapper function to store the contentWindow from the attachGuest() | 146 // Callback wrapper function to store the contentWindow from the attachGuest() |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 internal, sizeParams, callback)); | 321 internal, sizeParams, callback)); |
318 internal.performNextAction(); | 322 internal.performNextAction(); |
319 }; | 323 }; |
320 | 324 |
321 // Returns the contentWindow for this guestview. | 325 // Returns the contentWindow for this guestview. |
322 GuestView.prototype.getContentWindow = function() { | 326 GuestView.prototype.getContentWindow = function() { |
323 var internal = privates(this).internal; | 327 var internal = privates(this).internal; |
324 return internal.contentWindow; | 328 return internal.contentWindow; |
325 }; | 329 }; |
326 | 330 |
| 331 GuestView.prototype.setContentWindow = function(contentWindow) { |
| 332 var internal = privates(this).internal; |
| 333 return internal.setContentWindow(contentWindow); |
| 334 }; |
| 335 |
327 // Returns the ID for this guestview. | 336 // Returns the ID for this guestview. |
328 GuestView.prototype.getId = function() { | 337 GuestView.prototype.getId = function() { |
329 var internal = privates(this).internal; | 338 var internal = privates(this).internal; |
330 return internal.id; | 339 return internal.id; |
331 }; | 340 }; |
332 | 341 |
333 // Exports | 342 // Exports |
334 exports.GuestView = GuestView; | 343 exports.GuestView = GuestView; |
OLD | NEW |