Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixing the Share button so that it works with Manifest v2

  • Loading branch information...
commit 133e15dc8eb1d6bae1460651aaca6113dd882793 1 parent 5fdec6b
Paul Kinlan authored
View
27 tools/chrome/extensions/share/background.html
@@ -1,27 +0,0 @@
-<script>
- function clickHandler(info, tab) {
- if(info.mediaType == "image" ||
- info.mediaType == "video" ||
- info.mediaType == "audio") {
-
- var i = new WebKitIntent({"action": "http://webintents.org/share", "type": info.mediaType + "/*", "data": info.srcUrl});
- window.navigator.startActivty(i);
- }
- else if(!!info.linkUrl) {
- var i = new WebKitIntent({"action": "http://webintents.org/share", "type": "text/uri-list", "data": info.linkUrl });
- window.navigator.webkitStartActivity(i, function() {}, function() {});
- }
- };
-
- chrome.browserAction.onClicked.addListener(function(tab) {
- clickHandler({linkUrl: tab.url}, tab);
- });
-
- chrome.contextMenus.create({
- "title" : "Share",
- "type" : "normal",
- "contexts" : ["link", "image", "page", "video", "audio"],
- "onclick" : clickHandler
- });
-
-</script>
View
24 tools/chrome/extensions/share/background.js
@@ -0,0 +1,24 @@
+function clickHandler(info, tab) {
+ if(info.mediaType == "image" ||
+ info.mediaType == "video" ||
+ info.mediaType == "audio") {
+
+ var i = new WebKitIntent({"action": "http://webintents.org/share", "type": info.mediaType + "/*", "data": info.srcUrl});
+ window.navigator.startActivty(i);
+ }
+ else if(!!info.linkUrl) {
+ var i = new WebKitIntent({"action": "http://webintents.org/share", "type": "text/uri-list", "data": info.linkUrl });
+ window.navigator.webkitStartActivity(i, function() {}, function() {});
+ }
+};
+
+chrome.browserAction.onClicked.addListener(function(tab) {
+ clickHandler({linkUrl: tab.url}, tab);
+});
+
+chrome.contextMenus.create({
+ "title" : "Share",
+ "type" : "normal",
+ "contexts" : ["link", "image", "page", "video", "audio"],
+ "onclick" : clickHandler
+});
View
14 tools/chrome/extensions/share/manifest.json
@@ -1,6 +1,7 @@
{
"name": "Share",
"description" : "Share images, and links",
+ "manifest_version": 2,
"permissions": [
"contextMenus"
],
@@ -14,14 +15,11 @@
"default_title": "Share this page"
},
"permissions" : [
- "http://*/*", "https://*/*", "contextMenus"
- ],
- "content_scripts": [
- {
- "matches" : ["http://*/*", "https://*/*"],
- "js" : ["webintents.js", "startActivity.js"]
- }
+ "contextMenus"
],
"version": "0.0.0.2",
- "background_page": "background.html"
+ "minimum_chrome_version": "23.0.0.0",
+ "background": {
+ "scripts": ["background.js"]
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.