0

In my extension I use chrome.webRequest to catch requests from any web pages and it works like a charm.
But I can not catch any requests initialized from another extension. My manifest:

"permissions": [
    "tabs",
    "webRequest",
    "webRequestBlocking",
    "<all_urls>"
  ], 

background.js:

chrome.webRequest.onBeforeRequest.addListener(function (data) {
  console.log('catched', data);
}, {urls: ['<all_urls>']});

Tests:

  1. open tab with http://google.com:
    catched https://www.google.com/

  2. open extension console and run fetch('http://google.com'):
    catched http://google.com/

  3. open another extension console and run fetch('http://google.com'):
    // no output

Does anybody know if is it possible and if so, how to set it up? Thanks!

Noam Hacker
  • 4,671
  • 7
  • 34
  • 55
vitalets
  • 4,675
  • 1
  • 35
  • 35

1 Answers1

2

Updated

My previous answer it not correct, see @Rob W's comments.

But when @Xan mentioned that extension URLs were visible to other extensions, it became apparent that this behavior is undesirable and a security issue, so I removed the ability for extensions to see other extensions' requests

Previous answer

It's not allowed to handle requests sent from other extensions.

In addition, even certain requests with URLs using one of the above schemes are hidden, e.g., chrome-extension://other_extension_id where other_extension_id is not the ID of the extension to handle the request, https://www.google.com/chrome, and others (this list is not complete).

Haibara Ai
  • 10,703
  • 2
  • 31
  • 47
  • Does not it mean that requests **targeting** these URLs are hidden, not the requests **sent from** these URLs? Btw with `https://www.google.com/chrome` everything works.. – vitalets Jun 21 '16 at 09:28
  • That documentation note is about the **target** URL, not the requesting URL. But when [@Xan mentioned that extension URLs were visible to other extensions](https://stackoverflow.com/questions/31450304/do-chrome-extensions-have-access-to-chrome-apps/31451082#31451082), it became apparent that this behavior [is undesirable and a security issue](https://crbug.com/510802), so [I removed the ability for extensions to see other extensions' requests](https://crbug.com/510802#c37). – Rob W Jun 21 '16 at 12:29
  • @vitalets, sorry, it seems I have misunderstood the documentation. See Rob W's comments – Haibara Ai Jun 21 '16 at 12:33
  • @Row W, thanks for mentioning that, if convenient, could you please extract that into an answer? And I will remove this answer – Haibara Ai Jun 21 '16 at 12:34