Adds a magic way to get a unique tab id to the OOPHM Chrome extension. A div with id "$__gwt_tab_id" is appended to the hosted.html IFRAME's body; the textContent of this div contains the tab id. TODO: This data needs to be passed into the NPAPI plugin somehow. Review by: jat (desk) git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@6291 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/plugins/npapi/prebuilt/gwtdmp/background.html b/plugins/npapi/prebuilt/gwtdmp/background.html new file mode 100644 index 0000000..be794d4 --- /dev/null +++ b/plugins/npapi/prebuilt/gwtdmp/background.html
@@ -0,0 +1,10 @@ +<html> +<head> +<script> + chrome.extension.onConnect.addListener(function(port) { + // Tell my caller his tabId + port.postMessage( { name:"tabId", tabId:port.tab.id } ); + }); +</script> +</head> +</html>
diff --git a/plugins/npapi/prebuilt/gwtdmp/manifest.json b/plugins/npapi/prebuilt/gwtdmp/manifest.json index ad68f94..4dfc66a 100644 --- a/plugins/npapi/prebuilt/gwtdmp/manifest.json +++ b/plugins/npapi/prebuilt/gwtdmp/manifest.json
@@ -9,6 +9,13 @@ "64": "gwt64.png", "128": "gwt128.png" }, + "background_page": "background.html", + "content_scripts": [ + { + "matches": ["http://*/*", "https://*/*", "file:///*"], + "js": ["record_tab_id.js"] + } + ], "plugins": [ { "path": "WINNT_x86-msvc/npOOPHM.dll", "public": true } ]
diff --git a/plugins/npapi/prebuilt/gwtdmp/record_tab_id.js b/plugins/npapi/prebuilt/gwtdmp/record_tab_id.js new file mode 100644 index 0000000..df8c075 --- /dev/null +++ b/plugins/npapi/prebuilt/gwtdmp/record_tab_id.js
@@ -0,0 +1,13 @@ +if (window != top && location.href.indexOf("hosted.html") >= 0) { + var port = chrome.extension.connect(); + port.onMessage.addListener(function(msg) { + if (msg.name == "tabId") { + var doc = window.document; + var div = document.createElement("div"); + div.id = "$__gwt_tab_id"; + div.textContent = "" + msg.tabId; + doc.body.appendChild(div); + // console.log("record_tab_id.js " + msg.tabId); + } + }); +}