From 691d2625d723977ce04503627b8935b901c43ee6 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sat, 8 Oct 2016 16:37:50 -0400 Subject: [PATCH] added hotkey commands to launch browser action popup and generate new password --- src/background.js | 9 +++++++++ src/manifest.json | 15 +++++++++++++++ 2 files changed, 24 insertions(+) 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" ]