Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <script type="text/javascript"> | 1 <script type="text/javascript"> |
| 2 function SetSrc(src) { | 2 |
| 3 var plugin = document.getElementById('plugin'); | 3 function SetTitle(str) { |
| 4 plugin.src = src; | 4 document.title = str; |
| 5 } | 5 } |
| 6 function SetSize(w, h) { | 6 document.title = 'embedder'; |
| 7 var plugin = document.getElementById('plugin'); | 7 |
| 8 plugin.width = w; | 8 var thePlugin = document.createElement('object'); |
| 9 plugin.height = h; | 9 |
| 10 } | 10 thePlugin.id = "plugin"; |
| 11 thePlugin.tabindex = "0"; | |
| 12 thePlugin.type = "application/browser-plugin"; | |
|
eseidel
2013/11/18 22:11:08
That's quite the generic mimetype ya'll have chose
| |
| 13 thePlugin.width = "640"; | |
| 14 thePlugin.height = "480"; | |
| 15 thePlugin.border = "0px"; | |
| 16 | |
| 17 window.addEventListener('message', receiveMessage, false); | |
| 18 thePlugin.addEventListener('-internal-instanceid-allocated', function(e) { | |
| 19 thePlugin['-internal-attach']({}); | |
| 20 }); | |
| 21 | |
| 11 function PostMessage(data, shouldTargetIframe) { | 22 function PostMessage(data, shouldTargetIframe) { |
| 12 plugin = document.getElementById('plugin'); | 23 plugin = document.getElementById('plugin'); |
| 13 // TODO(fsamuel): contentWindow can be accessed directly once | 24 // TODO(fsamuel): contentWindow can be accessed directly once |
| 14 // http://wkbug.com/85679 lands. | 25 // http://wkbug.com/85679 lands. |
| 15 if (shouldTargetIframe) { | 26 if (shouldTargetIframe) { |
| 16 plugin.contentWindow.frames[0].postMessage('testing123', '*'); | 27 plugin.contentWindow.frames[0].postMessage('testing123', '*'); |
| 17 } else { | 28 } else { |
| 18 plugin.contentWindow.frames.postMessage('testing123', '*'); | 29 plugin.contentWindow.frames.postMessage('testing123', '*'); |
| 19 } | 30 } |
| 20 } | 31 } |
| 21 function SetTitle(str) { | 32 |
| 22 document.title = str; | 33 function SetSrc(src) { |
| 34 thePlugin.src = src; | |
| 23 } | 35 } |
| 24 document.title = 'embedder'; | |
| 25 </script> | |
| 26 | 36 |
| 27 <object id="plugin" | |
| 28 tabindex="0" | |
| 29 type="application/browser-plugin" | |
| 30 width="640" | |
| 31 height="480" | |
| 32 border="0px"></object> | |
| 33 <script type="text/javascript"> | |
| 34 var msg; | 37 var msg; |
| 35 function receiveMessage(event) { | 38 function receiveMessage(event) { |
| 36 msg = event.data; | 39 msg = event.data; |
| 37 if (msg == 'ready') { | 40 if (msg == 'ready') { |
| 38 document.title = 'ready'; | 41 document.title = 'ready'; |
| 39 return; | 42 return; |
| 40 } | 43 } |
| 41 if (msg.indexOf('stop_ack') == -1) { | 44 if (msg.indexOf('stop_ack') == -1) { |
| 42 event.source.postMessage('stop', '*'); | 45 event.source.postMessage('stop', '*'); |
| 43 } else { | 46 } else { |
| 44 var name = msg.replace("stop_ack", "").trim(); | 47 var name = msg.replace("stop_ack", "").trim(); |
| 45 if (name !== '') { | 48 if (name !== '') { |
| 46 window.document.title = name; | 49 window.document.title = name; |
| 47 } else { | 50 } else { |
| 48 window.document.title = 'main guest'; | 51 window.document.title = 'main guest'; |
| 49 } | 52 } |
| 50 } | 53 } |
| 51 } | 54 } |
| 52 | 55 |
| 53 var plugin = document.getElementById('plugin'); | 56 function attachPlugin() { |
| 54 window.addEventListener('message', receiveMessage, false); | 57 document.getElementById('pluginContainer').appendChild(thePlugin); |
| 55 plugin.addEventListener('-internal-instanceid-allocated', function(e) { | 58 } |
| 56 plugin['-internal-attach']({}); | 59 |
| 57 }); | |
| 58 </script> | 60 </script> |
| 61 | |
| 62 <div id="pluginContainer"></div> | |
| OLD | NEW |