diff --git a/src/background.js b/src/background.js index 578a64fdfe..63c0eada53 100644 --- a/src/background.js +++ b/src/background.js @@ -11,6 +11,15 @@ var autofillService = new AutofillService(); var passwordGenerationService = new PasswordGenerationService(); var appIdService = new AppIdService(); +chrome.commands.onCommand.addListener(function (command) { + if (command === 'generate_password') { + passwordGenerationService.getOptions().then(function (options) { + var password = passwordGenerationService.generatePassword(options); + copyToClipboard(password); + }); + } +}); + chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) { if (msg.command === 'loggedOut') { setIcon(true); diff --git a/src/manifest.json b/src/manifest.json index 41665b277b..b58766e8d5 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -65,6 +65,21 @@ "http://*/*", "https://*/*" ], + "commands": { + "generate_password": { + "suggested_key": { + "default": "Ctrl+Shift+O", + "mac": "Command+Shift+O" + }, + "description": "Generate and copy a new random password to the clipboard." + }, + "_execute_browser_action": { + "suggested_key": { + "default": "Ctrl+Shift+Y", + "mac": "Command+Shift+Y" + } + } + }, "web_accessible_resources": [ "overlay/popup.html" ]