2 Copyright (C) 2017, 2019 Kai Uwe Broulik <kde@privat.broulik.de>
3 Copyright (C) 2018 David Edmundson <davidedmundson@kde.org>
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as
7 published by the Free Software Foundation; either version 3 of
8 the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 function sendMessage(subsystem, action, payload) {
26 if (chrome.extension && chrome.extension.sendMessage) {
27 return new Promise((resolve, reject) => {
28 chrome.extension.sendMessage(data, (reply) => {
29 if (chrome.runtime.lastError) {
30 if (chrome.runtime.lastError.message === "The message port closed before a response was received.") {
33 reject(chrome.runtime.lastError);
38 if (reply && reply.rejected) {
47 return browser.runtime.sendMessage(data);