1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 00:33:44 +00:00

use navigator.clipboard to copy text if available

This commit is contained in:
Kyle Spearrin
2018-08-13 09:44:59 -04:00
parent 2a9cd36a01
commit ada83aae8f
6 changed files with 23 additions and 15 deletions

View File

@@ -65,7 +65,7 @@ export default class CommandsBackground {
const options = await this.passwordGenerationService.getOptions();
const password = await this.passwordGenerationService.generatePassword(options);
this.platformUtilsService.copyToClipboard(password);
this.platformUtilsService.copyToClipboard(password, { window: window });
this.passwordGenerationService.addHistory(password);
this.analytics.ga('send', {

View File

@@ -37,7 +37,7 @@ export default class ContextMenusBackground {
private async generatePasswordToClipboard() {
const options = await this.passwordGenerationService.getOptions();
const password = await this.passwordGenerationService.generatePassword(options);
this.platformUtilsService.copyToClipboard(password);
this.platformUtilsService.copyToClipboard(password, { window: window });
this.passwordGenerationService.addHistory(password);
this.analytics.ga('send', {
@@ -73,13 +73,13 @@ export default class ContextMenusBackground {
hitType: 'event',
eventAction: 'Copied Username From Context Menu',
});
this.platformUtilsService.copyToClipboard(cipher.login.username);
this.platformUtilsService.copyToClipboard(cipher.login.username, { window: window });
} else if (info.parentMenuItemId === 'copy-password') {
this.analytics.ga('send', {
hitType: 'event',
eventAction: 'Copied Password From Context Menu',
});
this.platformUtilsService.copyToClipboard(cipher.login.password);
this.platformUtilsService.copyToClipboard(cipher.login.password, { window: window });
}
break;

View File

@@ -149,9 +149,8 @@ export default class RuntimeBackground {
tab: msg.tab,
details: msg.details,
}], msg.sender === 'autofill_cmd');
if (totpCode !== null && !this.platformUtilsService.isFirefox()) {
this.platformUtilsService.copyToClipboard(totpCode);
if (totpCode !== null) {
this.platformUtilsService.copyToClipboard(totpCode, { window: window });
}
break;
case 'contextMenu':
@@ -178,8 +177,8 @@ export default class RuntimeBackground {
pageDetails: this.pageDetailsToAutoFill,
});
if (totpCode !== null && !this.platformUtilsService.isFirefox()) {
this.platformUtilsService.copyToClipboard(totpCode);
if (totpCode !== null) {
this.platformUtilsService.copyToClipboard(totpCode, { window: window });
}
// reset