LEFT | RIGHT |
1 "use strict"; | 1 "use strict"; |
2 | 2 |
3 Components.utils.import("resource://gre/modules/Messaging.jsm"); | 3 Components.utils.import("resource://gre/modules/Messaging.jsm"); |
4 | 4 |
5 this.runtime = class extends ExtensionAPI { | 5 this.runtime = class extends ExtensionAPI { |
6 getAPI(context) { | 6 getAPI(context) { |
7 let {extension} = context; | 7 let {extension} = context; |
8 | 8 |
9 return { | 9 return { |
10 runtime: { | 10 runtime: { |
11 | 11 |
12 // Added functions in order to make possible the communication between | 12 // Added functions in order to make possible the communication between |
13 // the Android part and the extension. | 13 // the Android part and the extension. |
14 // See https://issues.adblockplus.org/ticket/6865 | 14 // See https://issues.adblockplus.org/ticket/6865 |
15 abbRegisterRequestListener: function(listener) { | 15 registerAbbMessageListener: function(listener) { |
16 EventDispatcher.instance.registerListener((event, data, callback) => | 16 EventDispatcher.instance.registerListener((event, data, callback) => |
17 { | 17 { |
18 let result = context.runSafe(listener, data); | 18 let result = context.runSafe(listener, data); |
19 if (result["success"]) { | 19 if (result["success"]) { |
20 callback.onSuccess(result); | 20 callback.onSuccess(result); |
21 } else { | 21 } else { |
22 let errorMsg = result["error"] ? result["error"] : "An error has o
curred"; | 22 let errorMsg = result["error"] ? result["error"] : "An error has o
curred"; |
23 callback.onError(errorMsg); | 23 callback.onError(errorMsg); |
24 } | 24 } |
25 }, "Abb:Api"); | 25 }, "Abb:Api"); |
26 }, | 26 }, |
27 abbSendRequest: function(type) { | 27 sendAbbMessage: function(type) { |
28 EventDispatcher.instance.sendRequest({"type": type}); | 28 EventDispatcher.instance.sendRequest({"type": "Abb:" + type}); |
29 }, | 29 }, |
30 | 30 |
31 onConnect: context.messenger.onConnect("runtime.onConnect"), | 31 onConnect: context.messenger.onConnect("runtime.onConnect"), |
32 | 32 |
33 onMessage: context.messenger.onMessage("runtime.onMessage"), | 33 onMessage: context.messenger.onMessage("runtime.onMessage"), |
34 | 34 |
35 onConnectExternal: context.messenger.onConnectExternal("runtime.onConnec
tExternal"), | 35 onConnectExternal: context.messenger.onConnectExternal("runtime.onConnec
tExternal"), |
36 | 36 |
37 onMessageExternal: context.messenger.onMessageExternal("runtime.onMessag
eExternal"), | 37 onMessageExternal: context.messenger.onMessageExternal("runtime.onMessag
eExternal"), |
38 | 38 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 | 142 |
143 id: extension.id, | 143 id: extension.id, |
144 | 144 |
145 getURL: function(url) { | 145 getURL: function(url) { |
146 return extension.baseURI.resolve(url); | 146 return extension.baseURI.resolve(url); |
147 }, | 147 }, |
148 }, | 148 }, |
149 }; | 149 }; |
150 } | 150 } |
151 }; | 151 }; |
LEFT | RIGHT |