chrome.management reports an extension's content scripts

#41131764 Area: Extensions>API / management CL 8623059 In Review

What it does

chrome.management.get() and getAll() now return a contentScripts field: the content scripts an extension declares in its manifest, with their matches, excludeMatches, js and css.

The field is omitted for extensions that declare none, and it only covers manifest-declared scripts, not ones registered at runtime through scripting or userScripts.

Requested in 2014 so that an extension with the management permission can tell what another extension actually touches, without parsing locale-dependent permission warnings.

Demo extension

The screenshots below come from hjanuschka/cl-8623059-extension, a small extension that calls chrome.management.getAll() and prints the content scripts of every installed extension. It ships a second extension, sample-target, that declares two content scripts so there is something to list.

git clone https://github.com/hjanuschka/cl-8623059-extension
chrome --load-extension=cl-8623059-extension,cl-8623059-extension/sample-target

The demo extension's panel

After: content scripts are listed
With the CL: the matches, excludeMatches, js and css of both declared content scripts.
Before: no contentScripts
Same build without the CL: the field does not exist, so every extension reports nothing.

Verification

Open questions for review

Links

Issue 41131764 CL 8623059 Demo extension capture_screenshots.py