MCPcopy
hub / github.com/NeverDecaf/chromium-web-store / msgHandler

Function msgHandler

src/scripts/background.js:130–172  ·  view source on GitHub ↗
(request, sender, sendResponse)

Source from the content-addressed store, hash-verified

128 });
129});
130const msgHandler = function (request, sender, sendResponse) {
131 if (request.nonWebstoreDownloadUrl) {
132 chrome.downloads.download(
133 {
134 url: request.nonWebstoreDownloadUrl,
135 },
136 (dlid) => {
137 nonWebstoreExtensionsDownloading.add(dlid);
138 },
139 );
140 }
141 if (request.manualInstallDownloadUrl) {
142 chrome.downloads.download(
143 {
144 url: request.manualInstallDownloadUrl,
145 saveAs: true, // required to suppress warning: "Apps, extensions and user scripts cannot be added from this website"
146 },
147 (dlid) => {
148 manualInstallExtensionsDownloading.add(dlid);
149 },
150 );
151 }
152 if (request.newTabUrl) {
153 chrome.tabs.create({ active: false, url: request.newTabUrl });
154 }
155 if (request.checkExtInstalledId) {
156 chrome.management.get(request.checkExtInstalledId, (extinfo) => {
157 sendResponse({
158 installed: !(chrome.runtime.lastError && !extinfo),
159 });
160 });
161 return true;
162 }
163 if (request.uninstallExt) {
164 chrome.management.uninstall(request.uninstallExt, () => {
165 sendResponse({ uninstalled: !chrome.runtime.lastError });
166 });
167 return true;
168 }
169 if (request.installExt) {
170 tabsAwaitingInstall.add(sender.tab.id);
171 }
172};
173chrome.runtime.onMessage.addListener(msgHandler);
174chrome.downloads.onChanged.addListener((d) => {
175 // open chrome://extensions if user has "Always download CRX files" checked, for easy drag-and-drop installation

Callers 1

promptInstallFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected