Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <script type="text/javascript"> | 1 <script type="text/javascript"> |
| 2 function loadAbort(evt) { | 2 function loadAbort(evt) { |
| 3 document.title = evt.type; | 3 document.title = evt.type; |
| 4 } | 4 } |
| 5 function loadStart(evt) { | 5 function loadStart(evt) { |
| 6 document.title = evt.url; | 6 document.title = evt.url; |
| 7 } | 7 } |
| 8 var redirectOldUrl; | 8 var redirectOldUrl; |
| 9 var redirectNewUrl; | 9 var redirectNewUrl; |
| 10 function loadRedirect(event) { | 10 function loadRedirect(event) { |
| 11 document.title = "redirected"; | 11 document.title = "redirected"; |
| 12 if (event.isTopLevel) { | 12 if (event.isTopLevel) { |
| 13 redirectOldUrl = event.oldUrl; | 13 redirectOldUrl = event.oldUrl; |
| 14 redirectNewUrl = event.newUrl; | 14 redirectNewUrl = event.newUrl; |
| 15 } | 15 } |
| 16 } | 16 } |
| 17 function SetSrc(src) { | 17 function SetSrc(src) { |
| 18 var plugin = document.getElementById('plugin'); | 18 var plugin = document.getElementById('plugin'); |
| 19 plugin.src = src; | 19 plugin.src = src; |
| 20 } | 20 } |
| 21 function SetSize(w, h) { | 21 function SetSize(w, h) { |
| 22 var plugin = document.getElementById('plugin'); | 22 var plugin = document.getElementById('plugin'); |
| 23 plugin.width = w; | 23 plugin.width = w; |
| 24 plugin.height = h; | 24 plugin.height = h; |
| 25 } | 25 } |
| 26 function PostMessage(data, targetiframe) { | |
|
Charlie Reis
2012/10/12 00:31:43
nit: shouldTargetIframe
(Otherwise it sounds like
Fady Samuel
2012/10/12 18:07:53
Done.
| |
| 27 plugin = document.getElementById('plugin'); | |
| 28 // TODO(fsamuel): contentWindow can be accessed directly once | |
| 29 // http://wkbug.com/85679 lands. | |
| 30 if (targetiframe) { | |
| 31 plugin.contentWindow.frames[0].postMessage('testing123', '*'); | |
| 32 } else { | |
| 33 plugin.contentWindow.frames.postMessage('testing123', '*'); | |
| 34 } | |
| 35 } | |
| 26 function Back() { | 36 function Back() { |
| 27 var plugin = document.getElementById('plugin'); | 37 var plugin = document.getElementById('plugin'); |
| 28 plugin.back(); | 38 plugin.back(); |
| 29 } | 39 } |
| 30 function Forward() { | 40 function Forward() { |
| 31 var plugin = document.getElementById('plugin'); | 41 var plugin = document.getElementById('plugin'); |
| 32 plugin.forward(); | 42 plugin.forward(); |
| 33 } | 43 } |
| 34 function Go(relativeIndex) { | 44 function Go(relativeIndex) { |
| 35 var plugin = document.getElementById('plugin'); | 45 var plugin = document.getElementById('plugin'); |
| 36 plugin.go(relativeIndex); | 46 plugin.go(relativeIndex); |
| 37 } | 47 } |
| 38 function SetTitle(str) { | 48 function SetTitle(str) { |
| 39 document.title = str; | 49 document.title = str; |
| 40 } | 50 } |
| 41 document.title = 'embedder'; | 51 document.title = 'embedder'; |
| 42 </script> | 52 </script> |
| 43 | 53 |
| 44 <object id="plugin" | 54 <object id="plugin" |
| 45 tabindex="0" | 55 tabindex="0" |
| 46 type="application/browser-plugin" | 56 type="application/browser-plugin" |
| 47 width="640" | 57 width="640" |
| 48 height="480" | 58 height="480" |
| 49 border="0px"></object> | 59 border="0px"></object> |
| 50 | 60 <script type="text/javascript"> |
| 51 <script> | 61 var msg; |
| 62 function receiveMessage(event) { | |
| 63 msg = event.data; | |
| 64 if (msg == 'ready') { | |
| 65 document.title = 'ready'; | |
| 66 return; | |
| 67 } | |
| 68 if (msg.indexOf('stop_ack') == -1) { | |
| 69 event.source.postMessage('stop', '*'); | |
| 70 } else { | |
| 71 var name = msg.replace("stop_ack", "").trim(); | |
| 72 if (name !== '') { | |
| 73 window.document.title = name; | |
| 74 } else { | |
| 75 window.document.title = 'main guest'; | |
| 76 } | |
| 77 } | |
| 78 } | |
| 52 var plugin = document.getElementById('plugin'); | 79 var plugin = document.getElementById('plugin'); |
| 53 plugin.addEventListener('loadStart', loadStart); | 80 plugin.addEventListener('loadStart', loadStart); |
| 54 plugin.addEventListener('loadAbort', loadAbort); | 81 plugin.addEventListener('loadAbort', loadAbort); |
| 55 plugin.addEventListener('loadRedirect', loadRedirect); | 82 plugin.addEventListener('loadRedirect', loadRedirect); |
| 83 window.addEventListener('message', receiveMessage, false); | |
| 56 </script> | 84 </script> |
| OLD | NEW |