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 var DocumentNatives = requireNative('document_natives'); | 5 var DocumentNatives = requireNative('document_natives'); |
6 var GuestViewInternal = | 6 var GuestViewInternal = |
7 require('binding').Binding.create('guestViewInternal').generate(); | 7 require('binding').Binding.create('guestViewInternal').generate(); |
8 var IdGenerator = requireNative('id_generator'); | 8 var IdGenerator = requireNative('id_generator'); |
9 var guestViewInternalNatives = requireNative('guest_view_internal'); | 9 var guestViewInternalNatives = requireNative('guest_view_internal'); |
10 | 10 |
(...skipping 25 matching lines...) Expand all Loading... |
36 // We create BrowserPlugin as a custom element in order to observe changes | 36 // We create BrowserPlugin as a custom element in order to observe changes |
37 // to attributes synchronously. | 37 // to attributes synchronously. |
38 var browserPluginNode = new AppViewInternal.BrowserPlugin(); | 38 var browserPluginNode = new AppViewInternal.BrowserPlugin(); |
39 privates(browserPluginNode).internal = this; | 39 privates(browserPluginNode).internal = this; |
40 return browserPluginNode; | 40 return browserPluginNode; |
41 }; | 41 }; |
42 | 42 |
43 AppViewInternal.prototype.connect = function(app, data, callback) { | 43 AppViewInternal.prototype.connect = function(app, data, callback) { |
44 var createParams = { | 44 var createParams = { |
45 'appId': app, | 45 'appId': app, |
46 'data': data | 46 'data': data || {} |
47 }; | 47 }; |
48 var self = this; | 48 var self = this; |
49 GuestViewInternal.createGuest( | 49 GuestViewInternal.createGuest( |
50 'appview', | 50 'appview', |
51 createParams, | 51 createParams, |
52 function(guestInstanceId) { | 52 function(guestInstanceId) { |
53 if (!guestInstanceId) { | 53 if (!guestInstanceId) { |
54 this.browserPluginNode.style.visibility = 'hidden'; | 54 this.browserPluginNode.style.visibility = 'hidden'; |
55 var errorMsg = 'Unable to connect to app "' + app + '".'; | 55 var errorMsg = 'Unable to connect to app "' + app + '".'; |
56 window.console.warn(errorMsg); | 56 window.console.warn(errorMsg); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 | 128 |
129 var useCapture = true; | 129 var useCapture = true; |
130 window.addEventListener('readystatechange', function listener(event) { | 130 window.addEventListener('readystatechange', function listener(event) { |
131 if (document.readyState == 'loading') | 131 if (document.readyState == 'loading') |
132 return; | 132 return; |
133 | 133 |
134 registerBrowserPluginElement(); | 134 registerBrowserPluginElement(); |
135 registerAppViewElement(); | 135 registerAppViewElement(); |
136 window.removeEventListener(event.type, listener, useCapture); | 136 window.removeEventListener(event.type, listener, useCapture); |
137 }, useCapture); | 137 }, useCapture); |
OLD | NEW |