Revision: 6291
Author: [email protected]
Date: Fri Oct  2 15:38:34 2009
Log: 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)
http://code.google.com/p/google-web-toolkit/source/detail?r=6291

Added:
  /trunk/plugins/npapi/prebuilt/gwtdmp/background.html
  /trunk/plugins/npapi/prebuilt/gwtdmp/record_tab_id.js
Modified:
  /trunk/plugins/npapi/prebuilt/gwtdmp/manifest.json

=======================================
--- /dev/null
+++ /trunk/plugins/npapi/prebuilt/gwtdmp/background.html        Fri Oct  2  
15:38:34 2009
@@ -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>
=======================================
--- /dev/null
+++ /trunk/plugins/npapi/prebuilt/gwtdmp/record_tab_id.js       Fri Oct  2  
15:38:34 2009
@@ -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);
+    }
+  });
+}
=======================================
--- /trunk/plugins/npapi/prebuilt/gwtdmp/manifest.json  Thu Sep 10 15:17:21  
2009
+++ /trunk/plugins/npapi/prebuilt/gwtdmp/manifest.json  Fri Oct  2 15:38:34  
2009
@@ -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 }
    ]

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to