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