Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: toolkit/components/extensions/ext-c-runtime.js

Issue 29863604: Issue 6865 - Update ABP dependency to version 3.2 (Closed)
Patch Set: Adjusting code style Created Jan. 16, 2019, 1:45 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mobile/android/chrome/content/browser.js ('k') | toolkit/components/extensions/schemas/runtime.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: toolkit/components/extensions/ext-c-runtime.js
===================================================================
--- a/toolkit/components/extensions/ext-c-runtime.js
+++ b/toolkit/components/extensions/ext-c-runtime.js
@@ -1,16 +1,38 @@
"use strict";
+Components.utils.import("resource://gre/modules/Messaging.jsm");
+
this.runtime = class extends ExtensionAPI {
getAPI(context) {
let {extension} = context;
return {
runtime: {
+
+ // Added functions in order to make possible the communication between
+ // the Android part and the extension.
+ // See https://issues.adblockplus.org/ticket/6865
+ registerAbbMessageListener: function(listener) {
+ EventDispatcher.instance.registerListener((event, data, callback) =>
+ {
+ let result = context.runSafe(listener, data);
+ if (result["success"]) {
+ callback.onSuccess(result);
+ } else {
+ let errorMsg = result["error"] ? result["error"] : "An error has ocurred";
+ callback.onError(errorMsg);
+ }
+ }, "Abb:Api");
+ },
+ sendAbbMessage: function(type) {
+ EventDispatcher.instance.sendRequest({"type": "Abb:" + type});
+ },
+
onConnect: context.messenger.onConnect("runtime.onConnect"),
onMessage: context.messenger.onMessage("runtime.onMessage"),
onConnectExternal: context.messenger.onConnectExternal("runtime.onConnectExternal"),
onMessageExternal: context.messenger.onMessageExternal("runtime.onMessageExternal"),
« no previous file with comments | « mobile/android/chrome/content/browser.js ('k') | toolkit/components/extensions/schemas/runtime.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld