Changeset View
Changeset View
Standalone View
Standalone View
extension/extension.js
Show First 20 Lines • Show All 80 Lines • ▼ Show 20 Line(s) | |||||
81 | // When connecting to native host fails (e.g. not installed), we immediately get a disconnect | 81 | // When connecting to native host fails (e.g. not installed), we immediately get a disconnect | ||
82 | // event immediately afterwards. Also avoid infinite restart loop then. | 82 | // event immediately afterwards. Also avoid infinite restart loop then. | ||
83 | var receivedMessageOnce = false; | 83 | var receivedMessageOnce = false; | ||
84 | 84 | | |||
85 | var portStatus = ""; | 85 | var portStatus = ""; | ||
86 | var portLastErrorMessage = undefined; | 86 | var portLastErrorMessage = undefined; | ||
87 | 87 | | |||
88 | function updateBrowserAction() { | 88 | function updateBrowserAction() { | ||
89 | let enableAction = false; | | |||
90 | if (portStatus === "UNSUPPORTED_OS" || portStatus === "STARTUP_FAILED") { | 89 | if (portStatus === "UNSUPPORTED_OS" || portStatus === "STARTUP_FAILED") { | ||
91 | chrome.browserAction.setIcon({ | 90 | chrome.browserAction.setIcon({ | ||
92 | path: { | 91 | path: { | ||
93 | "16": "icons/plasma-disabled-16.png", | 92 | "16": "icons/plasma-disabled-16.png", | ||
94 | "32": "icons/plasma-disabled-32.png", | 93 | "32": "icons/plasma-disabled-32.png", | ||
95 | "48": "icons/plasma-disabled-48.png", | 94 | "48": "icons/plasma-disabled-48.png", | ||
96 | "128": "icons/plasma-disabled-128.png" | 95 | "128": "icons/plasma-disabled-128.png" | ||
97 | } | 96 | } | ||
98 | }); | 97 | }); | ||
99 | enableAction = true; | | |||
100 | } | 98 | } | ||
101 | 99 | | |||
102 | if (portLastErrorMessage) { | 100 | if (portLastErrorMessage) { | ||
103 | chrome.browserAction.setBadgeText({ text: "!" }); | 101 | chrome.browserAction.setBadgeText({ text: "!" }); | ||
104 | chrome.browserAction.setBadgeBackgroundColor({ color: "#da4453" }); // breeze "negative" color | 102 | chrome.browserAction.setBadgeBackgroundColor({ color: "#da4453" }); // breeze "negative" color | ||
105 | enableAction = true; | | |||
106 | } else { | 103 | } else { | ||
107 | chrome.browserAction.setBadgeText({ text: "" }); | 104 | chrome.browserAction.setBadgeText({ text: "" }); | ||
108 | } | 105 | } | ||
109 | | ||||
110 | if (enableAction) { | | |||
111 | chrome.browserAction.enable(); | | |||
112 | } else { | | |||
113 | chrome.browserAction.disable(); | | |||
114 | } | | |||
115 | } | 106 | } | ||
116 | updateBrowserAction(); | 107 | updateBrowserAction(); | ||
117 | 108 | | |||
118 | // Check for supported platform to avoid loading it on e.g. Windows and then failing | 109 | // Check for supported platform to avoid loading it on e.g. Windows and then failing | ||
119 | // when the extension got synced to another device and then failing | 110 | // when the extension got synced to another device and then failing | ||
120 | chrome.runtime.getPlatformInfo(function (info) { | 111 | chrome.runtime.getPlatformInfo(function (info) { | ||
121 | if (!SUPPORTED_PLATFORMS.includes(info.os)) { | 112 | if (!SUPPORTED_PLATFORMS.includes(info.os)) { | ||
122 | console.log("This extension is not supported on", info.os); | 113 | console.log("This extension is not supported on", info.os); | ||
▲ Show 20 Lines • Show All 124 Lines • Show Last 20 Lines |