mirror of
https://github.com/bitwarden/browser
synced 2025-12-13 06:43:35 +00:00
Safari Web Extension Port from App Extension (#1531)
This commit is contained in:
@@ -27,9 +27,7 @@ export default class BrowserPlatformUtilsService implements PlatformUtilsService
|
||||
return this.deviceCache;
|
||||
}
|
||||
|
||||
if (this.isSafariExtension()) {
|
||||
this.deviceCache = DeviceType.SafariExtension;
|
||||
} else if (navigator.userAgent.indexOf(' Firefox/') !== -1 || navigator.userAgent.indexOf(' Gecko/') !== -1) {
|
||||
if (navigator.userAgent.indexOf(' Firefox/') !== -1 || navigator.userAgent.indexOf(' Gecko/') !== -1) {
|
||||
this.deviceCache = DeviceType.FirefoxExtension;
|
||||
} else if ((!!(window as any).opr && !!opr.addons) || !!(window as any).opera ||
|
||||
navigator.userAgent.indexOf(' OPR/') >= 0) {
|
||||
@@ -40,6 +38,8 @@ export default class BrowserPlatformUtilsService implements PlatformUtilsService
|
||||
this.deviceCache = DeviceType.VivaldiExtension;
|
||||
} else if ((window as any).chrome && navigator.userAgent.indexOf(' Chrome/') !== -1) {
|
||||
this.deviceCache = DeviceType.ChromeExtension;
|
||||
} else if (navigator.userAgent.indexOf(' Safari/') !== -1) {
|
||||
this.deviceCache = DeviceType.SafariExtension;
|
||||
}
|
||||
|
||||
return this.deviceCache;
|
||||
@@ -190,13 +190,7 @@ export default class BrowserPlatformUtilsService implements PlatformUtilsService
|
||||
}
|
||||
const clearing = options ? !!options.clearing : false;
|
||||
const clearMs: number = options && options.clearMs ? options.clearMs : null;
|
||||
if (this.isSafariExtension()) {
|
||||
SafariApp.sendMessageToApp('copyToClipboard', text).then(() => {
|
||||
if (!clearing && this.clipboardWriteCallback != null) {
|
||||
this.clipboardWriteCallback(text, clearMs);
|
||||
}
|
||||
});
|
||||
} else if (this.isFirefox() && (win as any).navigator.clipboard && (win as any).navigator.clipboard.writeText) {
|
||||
if (this.isFirefox() && (win as any).navigator.clipboard && (win as any).navigator.clipboard.writeText) {
|
||||
(win as any).navigator.clipboard.writeText(text).then(() => {
|
||||
if (!clearing && this.clipboardWriteCallback != null) {
|
||||
this.clipboardWriteCallback(text, clearMs);
|
||||
@@ -244,7 +238,7 @@ export default class BrowserPlatformUtilsService implements PlatformUtilsService
|
||||
doc = options.doc;
|
||||
}
|
||||
|
||||
if (this.isSafariExtension()) {
|
||||
if (this.isSafari()) {
|
||||
return await SafariApp.sendMessageToApp('readFromClipboard');
|
||||
} else if (this.isFirefox() && (win as any).navigator.clipboard && (win as any).navigator.clipboard.readText) {
|
||||
return await (win as any).navigator.clipboard.readText();
|
||||
@@ -311,10 +305,6 @@ export default class BrowserPlatformUtilsService implements PlatformUtilsService
|
||||
return false;
|
||||
}
|
||||
|
||||
private isSafariExtension(): boolean {
|
||||
return (window as any).safariAppExtension === true;
|
||||
}
|
||||
|
||||
getDefaultSystemTheme() {
|
||||
return this.prefersColorSchemeDark.matches ? 'dark' : 'light';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user