1 <script type=
"text/javascript">
2 function sizeChanged(evt
) {
3 var data
= JSON
.parse(evt
.detail
);
4 document
.title
= "AutoSize(" + data
.newWidth
+ ", " + data
.newHeight
+ ")";
7 function loadAbort(evt
) {
8 document
.title
= JSON
.parse(evt
.detail
).reason
;
10 function loadStart(evt
) {
11 document
.title
= JSON
.parse(evt
.detail
).url
;
13 function loadStop(evt
) {
14 document
.title
= "loadStop";
18 function loadCommit(evt
) {
19 var detail
= JSON
.parse(evt
.detail
);
20 document
.title
= "loadCommit:" + detail
.url
;
21 commitIsTopLevel
= detail
.isTopLevel
;
26 function loadRedirect(event
) {
27 document
.title
= "redirected";
28 var detail
= JSON
.parse(event
.detail
);
29 if (detail
.isTopLevel
) {
30 redirectOldUrl
= detail
.oldUrl
;
31 redirectNewUrl
= detail
.newUrl
;
34 function SetSrc(src
) {
35 var plugin
= document
.getElementById('plugin');
38 function SetSize(w
, h
) {
39 var plugin
= document
.getElementById('plugin');
43 function PostMessage(data
, shouldTargetIframe
) {
44 plugin
= document
.getElementById('plugin');
45 // TODO(fsamuel): contentWindow can be accessed directly once
46 // http://wkbug.com/85679 lands.
47 if (shouldTargetIframe
) {
48 plugin
.contentWindow
.frames
[0].postMessage('testing123', '*');
50 plugin
.contentWindow
.frames
.postMessage('testing123', '*');
54 var plugin
= document
.getElementById('plugin');
57 function CanGoBack() {
58 var plugin
= document
.getElementById('plugin');
59 return plugin
.canGoBack();
61 function CanGoForward() {
62 var plugin
= document
.getElementById('plugin');
63 return plugin
.canGoForward();
66 var plugin
= document
.getElementById('plugin');
69 function Go(relativeIndex
) {
70 var plugin
= document
.getElementById('plugin');
71 plugin
.go(relativeIndex
);
73 function SetTitle(str
) {
76 document
.title
= 'embedder';
81 type=
"application/browser-plugin"
84 border=
"0px"></object>
85 <script type=
"text/javascript">
87 function receiveMessage(event
) {
90 document
.title
= 'ready';
93 if (msg
.indexOf('stop_ack') == -1) {
94 event
.source
.postMessage('stop', '*');
96 var name
= msg
.replace("stop_ack", "").trim();
98 window
.document
.title
= name
;
100 window
.document
.title
= 'main guest';
104 var plugin
= document
.getElementById('plugin');
105 plugin
.addEventListener('-internal-loadstart', loadStart
);
106 plugin
.addEventListener('-internal-loadabort', loadAbort
);
107 plugin
.addEventListener('-internal-loadredirect', loadRedirect
);
108 window
.addEventListener('message', receiveMessage
, false);
109 plugin
.addEventListener('-internal-loadstop', loadStop
);
110 plugin
.addEventListener('-internal-loadcommit', loadCommit
);
111 plugin
.addEventListener('-internal-sizechanged', sizeChanged
);