Skip to content

Commit a8ed845

Browse files
committed
Fixes #128 - use postFailure instead of postError
1 parent 9ad9bc9 commit a8ed845

File tree

4 files changed

+20
-16
lines changed

4 files changed

+20
-16
lines changed

src/webintents.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@
4747
/*
4848
* Starts an activity.
4949
*/
50-
Intents.prototype.startActivity = function (intent, onResult, onError) {
50+
Intents.prototype.startActivity = function (intent, onResult, onFailure) {
5151
var id = "intent" + new Date().valueOf();
5252
var params = "directories=no,menubar=no,status=0,location=0,fullscreen=no,width=300,height=300";
5353
var iframe = document.getElementById("webintents_channel");
5454
intent._id = id;
5555
intent._callback = (onResult) ? true : false;
56-
intent._error = (onError) ? true : false;
56+
intent._error = (onFailure) ? true : false;
5757
intents[id] = { intent: intent };
5858

5959
var w = window.open(pickerSource, encodeNameTransport(intent), params);
@@ -65,11 +65,11 @@
6565
intents[id].callback = onResult;
6666
}
6767

68-
if(onError) {
68+
if(onFailure) {
6969
iframe.contentWindow.postMessage(
7070
_str({"request": "registerErrorCallback", "id": id }),
7171
server );
72-
intents[id].errorCallback = onError;
72+
intents[id].errorCallback = onFailure;
7373
}
7474
};
7575

@@ -170,7 +170,7 @@
170170
closed = true;
171171
};
172172

173-
this.postError = function(data) {
173+
this.postFailure = function(data) {
174174
if(closed) return;
175175

176176
var iframe = document.getElementById("webintents_channel");

tools/chrome/extensions/save/background.html

+14-5
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,22 @@
77
info.mediaType == "video" ||
88
info.mediaType == "audio") {
99
var intent = new Intent("http://webintents.org/save", info.mediaType + "/*", info.srcUrl);
10-
11-
chrome.tabs.sendRequest(tab.id, intent);
10+
try {
11+
var intent = new Intent("http://webintents.org/save", "text/uri-list", info.linkUrl);
12+
window.navigator.startActivity(intent);
13+
}
14+
catch(e) {
15+
console.log(e);
16+
}
1217
}
1318
else if(!!info.linkUrl) {
14-
var intent = new Intent("http://webintents.org/save", "text/uri-list", info.linkUrl);
15-
16-
chrome.tabs.sendRequest(tab.id, intent);
19+
try {
20+
var intent = new Intent("http://webintents.org/save", "text/uri-list", info.linkUrl);
21+
window.navigator.startActivity(intent);
22+
}
23+
catch(e) {
24+
console.log(e);
25+
}
1726
}
1827
};
1928

tools/chrome/extensions/save/manifest.json

-6
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@
1616
"permissions" : [
1717
"http://*/*", "https://*/*", "contextMenus"
1818
],
19-
"content_scripts": [
20-
{
21-
"matches" : ["http://*/*", "https://*/*"],
22-
"js" : ["webintents.js", "startActivity.js"]
23-
}
24-
],
2519
"version": "0.0.0.2",
2620
"background_page": "background.html"
2721
}

webintents.idl

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ interface Intent {
1111
object data;
1212

1313
void postResult(in object data);
14+
void postFailure(in object data);
1415
}
1516

1617
[NoInterfaceObject]

0 commit comments

Comments
 (0)