Opened on 09/20/2018 at 09:57:00 PM
Closed on 09/21/2018 at 12:20:34 PM
Last modified on 09/21/2018 at 05:01:57 PM
#6970 closed change (rejected)
Add commands section to manifest template and packagerChrome.py
| Reported by: | weissmar | Assignee: | |
|---|---|---|---|
| Priority: | Unknown | Milestone: | |
| Module: | Unknown | Keywords: | |
| Cc: | BrentM, sebastian | Blocked By: | |
| Blocking: | Platform: | Unknown / Cross platform | |
| Ready: | no | Confidential: | no |
| Tester: | Unknown | Verified working: | no |
| Review URL(s): | |||
Description (last modified by weissmar)
Background
We want to add the ability to add keyboard shortcuts to AdBlock for Chrome using the commands API (https://developer.chrome.com/apps/commands). In order to do this, a couple of changes need to be made to the build process, so that we can add something like the following to our metadata.adblock file:
[commands] toggle_pause = Ctrl+Shift+P Ctrl+Shift+P Command+Shift+P Ctrl+Shift+P Ctrl+Shift+P Toggle_Pause/Resume_on_all_sites
and then run the build.py script and end up with the following in our manifest.json file:
"commands": {
"toggle_pause": {
"description": "Toggle Pause/Resume on all sites",
"suggested_key": {
"chromeos": "Ctrl+Shift+P",
"default": "Ctrl+Shift+P",
"linux": "Ctrl+Shift+P",
"mac": "Command+Shift+P",
"windows": "Ctrl+Shift+P"
}
}
},
What to change
We'd like to add the following to packagerChrome.py (in the buildtools repo) in the createManifest function:
if metadata.has_section('commands'):
commands = {}
for key, values in metadata.items('commands'):
if key == '':
continue
default, windows, mac, chromeos, linux, description = values.split()
commands[key] = {
'suggested_key': {
'default': default,
'windows': windows,
'mac': mac,
'chromeos': chromeos,
'linux': linux
},
'description': description.replace('_', ' ')
}
templateData['commands'] = commands
That code should go before the line that renders the template (manifest = template.render(templateData))
We'd also like to add the following to manifest.json.tmpl (in the templates folder of the buildtools repo):
{%- if commands %}
"commands": {{commands|json}},
{%- endif %}

You can already configure arbitrary manifest keys (see #6552). In the case here you would add folowing to the mainfest section in metadata.adblock: