summaryrefslogtreecommitdiff
path: root/chrome
diff options
context:
space:
mode:
authorMichal Hruby <michal.mhr@gmail.com>2010-11-25 17:26:14 +0100
committerMichal Hruby <michal.mhr@gmail.com>2010-11-25 17:26:14 +0100
commite38f0714c784bf4c903853c44f8d5d8a7ab29703 (patch)
treecc2ca922ead4dd3f5a5022c9a1a923777a9de78c /chrome
parent615f6aea6d1205714bf4746362cca1b5f1181c08 (diff)
Fix up chrome extension
Diffstat (limited to 'chrome')
-rw-r--r--chrome/content_script.js4
-rw-r--r--chrome/manifest.json3
-rw-r--r--chrome/zeitgeist.js29
3 files changed, 24 insertions, 12 deletions
diff --git a/chrome/content_script.js b/chrome/content_script.js
index af0d9ac..949c60a 100644
--- a/chrome/content_script.js
+++ b/chrome/content_script.js
@@ -30,7 +30,7 @@ function zgGetDocumentInfo () {
var contentType = zgGetContentTypeFromHeader();
if (contentType) {
docInfo["mimeType"] = contentType;
- chrome.extension.sendRequest({name: "zgPlugin"}, docInfo);
+ chrome.extension.sendRequest(docInfo);
} else {
// send extra request to get the mime type
var request = new XMLHttpRequest();
@@ -40,7 +40,7 @@ function zgGetDocumentInfo () {
var content = request.getResponseHeader("Content-Type");
if (!content) return;
docInfo["mimeType"] = content.split(';')[0];
- chrome.extension.sendRequest({name: "zgPlugin"}, docInfo);
+ chrome.extension.sendRequest(docInfo);
}
}
request.send(null);
diff --git a/chrome/manifest.json b/chrome/manifest.json
index fdb4fb7..8f1e2bb 100644
--- a/chrome/manifest.json
+++ b/chrome/manifest.json
@@ -1,7 +1,8 @@
{
"name": "Zeitgeist Plugin",
"description": "Sends events to Zeitgeist about sites you visit",
- "version": "1",
+ "version": "1.1",
+ "minimum_chrome_version": "6",
"background_page": "background.html",
"permissions": [
"bookmarks", "tabs", "http://*/*", "https://*/*"
diff --git a/chrome/zeitgeist.js b/chrome/zeitgeist.js
index e6b6a29..b02f4fc 100644
--- a/chrome/zeitgeist.js
+++ b/chrome/zeitgeist.js
@@ -21,24 +21,35 @@ function onBookmarkCreated (bookmarkid, bookmark) {
plugin.insertEvent(url, url, mimetype, title, plugin.BOOKMARK);
}
+function sendAccessEvent (documentInfo) {
+ var url = documentInfo.url;
+ var origin = documentInfo.origin;
+ var mimetype = documentInfo.mimeType;
+ var title = documentInfo.title;
+ plugin.insertEvent(url,
+ origin ? origin : url,
+ mimetype ? mimetype : "text/html",
+ title);
+}
+
+// yea, this worked in chrome 5
function onExtensionConnect (port) {
port.onMessage.addListener(
function(message) {
- var url = message.url;
- var origin = message.origin;
- var mimetype = message.mimeType;
- var title = message.title;
- plugin.insertEvent(url,
- origin ? origin : url,
- mimetype ? mimetype : "text/html",
- title);
+ sendAccessEvent(message);
}
);
}
+// and this works in chrome 7
+function onExtensionRequest (request, sender, sendResponse) {
+ sendAccessEvent(request);
+}
+
plugin.setActor("application://google-chrome.desktop");
-chrome.extension.onConnect.addListener (onExtensionConnect);
+//chrome.extension.onConnect.addListener (onExtensionConnect);
+chrome.extension.onRequest.addListener (onExtensionRequest);
chrome.bookmarks.onCreated.addListener (onBookmarkCreated);
chrome.tabs.onUpdated.addListener (onTabUpdated);
chrome.tabs.onCreated.addListener (onTabCreated);