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 | 9 |
10 function AppViewInternal(appviewNode) { | 10 function AppViewInternal(appviewNode) { |
(...skipping 21 matching lines...) Expand all Loading... |
32 }; | 32 }; |
33 | 33 |
34 AppViewInternal.prototype.createBrowserPluginNode = function() { | 34 AppViewInternal.prototype.createBrowserPluginNode = function() { |
35 // We create BrowserPlugin as a custom element in order to observe changes | 35 // We create BrowserPlugin as a custom element in order to observe changes |
36 // to attributes synchronously. | 36 // to attributes synchronously. |
37 var browserPluginNode = new AppViewInternal.BrowserPlugin(); | 37 var browserPluginNode = new AppViewInternal.BrowserPlugin(); |
38 privates(browserPluginNode).internal = this; | 38 privates(browserPluginNode).internal = this; |
39 return browserPluginNode; | 39 return browserPluginNode; |
40 }; | 40 }; |
41 | 41 |
42 AppViewInternal.prototype.connect = function(app, callback) { | 42 AppViewInternal.prototype.connect = function(app, params, callback) { |
43 var params = { | 43 var createParams = { |
44 'appId': app | 44 'appId': app, |
| 45 'params': params |
45 }; | 46 }; |
46 var self = this; | 47 var self = this; |
47 GuestViewInternal.createGuest( | 48 GuestViewInternal.createGuest( |
48 'appview', | 49 'appview', |
49 params, | 50 createParams, |
50 function(instanceId) { | 51 function(instanceId) { |
51 if (!instanceId) { | 52 if (!instanceId) { |
52 self.browserPluginNode.style.visibility = 'hidden'; | 53 self.browserPluginNode.style.visibility = 'hidden'; |
53 var errorMsg = 'Unable to connect to app "' + app + '".'; | 54 var errorMsg = 'Unable to connect to app "' + app + '".'; |
54 window.console.warn(errorMsg); | 55 window.console.warn(errorMsg); |
55 self.getErrorNode().innerText = errorMsg; | 56 self.getErrorNode().innerText = errorMsg; |
56 if (callback) { | 57 if (callback) { |
57 callback(false); | 58 callback(false); |
58 } | 59 } |
59 return; | 60 return; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 124 |
124 var useCapture = true; | 125 var useCapture = true; |
125 window.addEventListener('readystatechange', function listener(event) { | 126 window.addEventListener('readystatechange', function listener(event) { |
126 if (document.readyState == 'loading') | 127 if (document.readyState == 'loading') |
127 return; | 128 return; |
128 | 129 |
129 registerBrowserPluginElement(); | 130 registerBrowserPluginElement(); |
130 registerAppViewElement(); | 131 registerAppViewElement(); |
131 window.removeEventListener(event.type, listener, useCapture); | 132 window.removeEventListener(event.type, listener, useCapture); |
132 }, useCapture); | 133 }, useCapture); |
OLD | NEW |