Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixes #128 - use postFailure instead of postError

  • Loading branch information...
commit a8ed84553ac142f6d16962894046d393ac947f44 1 parent 9ad9bc9
Paul Kinlan authored
View
10 src/webintents.js
@@ -47,13 +47,13 @@
/*
* Starts an activity.
*/
- Intents.prototype.startActivity = function (intent, onResult, onError) {
+ Intents.prototype.startActivity = function (intent, onResult, onFailure) {
var id = "intent" + new Date().valueOf();
var params = "directories=no,menubar=no,status=0,location=0,fullscreen=no,width=300,height=300";
var iframe = document.getElementById("webintents_channel");
intent._id = id;
intent._callback = (onResult) ? true : false;
- intent._error = (onError) ? true : false;
+ intent._error = (onFailure) ? true : false;
intents[id] = { intent: intent };
var w = window.open(pickerSource, encodeNameTransport(intent), params);
@@ -65,11 +65,11 @@
intents[id].callback = onResult;
}
- if(onError) {
+ if(onFailure) {
iframe.contentWindow.postMessage(
_str({"request": "registerErrorCallback", "id": id }),
server );
- intents[id].errorCallback = onError;
+ intents[id].errorCallback = onFailure;
}
};
@@ -170,7 +170,7 @@
closed = true;
};
- this.postError = function(data) {
+ this.postFailure = function(data) {
if(closed) return;
var iframe = document.getElementById("webintents_channel");
View
19 tools/chrome/extensions/save/background.html
@@ -7,13 +7,22 @@
info.mediaType == "video" ||
info.mediaType == "audio") {
var intent = new Intent("http://webintents.org/save", info.mediaType + "/*", info.srcUrl);
-
- chrome.tabs.sendRequest(tab.id, intent);
+ try {
+ var intent = new Intent("http://webintents.org/save", "text/uri-list", info.linkUrl);
+ window.navigator.startActivity(intent);
+ }
+ catch(e) {
+ console.log(e);
+ }
}
else if(!!info.linkUrl) {
- var intent = new Intent("http://webintents.org/save", "text/uri-list", info.linkUrl);
-
- chrome.tabs.sendRequest(tab.id, intent);
+ try {
+ var intent = new Intent("http://webintents.org/save", "text/uri-list", info.linkUrl);
+ window.navigator.startActivity(intent);
+ }
+ catch(e) {
+ console.log(e);
+ }
}
};
View
6 tools/chrome/extensions/save/manifest.json
@@ -16,12 +16,6 @@
"permissions" : [
"http://*/*", "https://*/*", "contextMenus"
],
- "content_scripts": [
- {
- "matches" : ["http://*/*", "https://*/*"],
- "js" : ["webintents.js", "startActivity.js"]
- }
- ],
"version": "0.0.0.2",
"background_page": "background.html"
}
View
1  webintents.idl
@@ -11,6 +11,7 @@ interface Intent {
object data;
void postResult(in object data);
+ void postFailure(in object data);
}
[NoInterfaceObject]
Please sign in to comment.
Something went wrong with that request. Please try again.