mirror of
https://github.com/bitwarden/browser
synced 2025-12-13 14:53:33 +00:00
stronger device type checks
This commit is contained in:
@@ -994,7 +994,8 @@
|
|||||||
End 1Password Extension
|
End 1Password Extension
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ((typeof safari !== 'undefined')) {
|
if ((typeof safari !== 'undefined') && navigator.userAgent.indexOf(' Safari/') !== -1 &&
|
||||||
|
navigator.userAgent.indexOf('Chrome') === -1) {
|
||||||
safari.self.addEventListener('message', function (msgEvent) {
|
safari.self.addEventListener('message', function (msgEvent) {
|
||||||
var msg = msgEvent.message;
|
var msg = msgEvent.message;
|
||||||
if (msg.command === 'collectPageDetails') {
|
if (msg.command === 'collectPageDetails') {
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
document.addEventListener('DOMContentLoaded', (event) => {
|
document.addEventListener('DOMContentLoaded', (event) => {
|
||||||
let pageHref = null;
|
let pageHref = null;
|
||||||
|
|
||||||
if ((typeof safari !== 'undefined')) {
|
if ((typeof safari !== 'undefined') && navigator.userAgent.indexOf(' Safari/') !== -1 &&
|
||||||
|
navigator.userAgent.indexOf('Chrome') === -1) {
|
||||||
const responseCommand = 'autofillerAutofillOnPageLoadEnabledResponse';
|
const responseCommand = 'autofillerAutofillOnPageLoadEnabledResponse';
|
||||||
safari.self.tab.dispatchMessage('bitwarden', {
|
safari.self.tab.dispatchMessage('bitwarden', {
|
||||||
command: 'bgGetDataForTab',
|
command: 'bgGetDataForTab',
|
||||||
|
|||||||
@@ -14,9 +14,10 @@ document.addEventListener('DOMContentLoaded', function (event) {
|
|||||||
iframed = isIframed(),
|
iframed = isIframed(),
|
||||||
submitButtonNames = ['log in', 'sign in', 'login', 'go', 'submit', 'continue', 'next'],
|
submitButtonNames = ['log in', 'sign in', 'login', 'go', 'submit', 'continue', 'next'],
|
||||||
notificationBarData = null,
|
notificationBarData = null,
|
||||||
isSafariApi = (typeof safari !== 'undefined');
|
isSafari = (typeof safari !== 'undefined') && navigator.userAgent.indexOf(' Safari/') !== -1 &&
|
||||||
|
navigator.userAgent.indexOf('Chrome') === -1;
|
||||||
|
|
||||||
if (isSafariApi) {
|
if (isSafari) {
|
||||||
const responseCommand = 'notificationBarDataResponse';
|
const responseCommand = 'notificationBarDataResponse';
|
||||||
safari.self.tab.dispatchMessage('bitwarden', {
|
safari.self.tab.dispatchMessage('bitwarden', {
|
||||||
command: 'bgGetDataForTab',
|
command: 'bgGetDataForTab',
|
||||||
@@ -385,7 +386,7 @@ document.addEventListener('DOMContentLoaded', function (event) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var barPageUrl = isSafariApi ? (safari.extension.baseURI + barPage) : chrome.extension.getURL(barPage);
|
var barPageUrl = isSafari ? (safari.extension.baseURI + barPage) : chrome.extension.getURL(barPage);
|
||||||
|
|
||||||
var iframe = document.createElement('iframe');
|
var iframe = document.createElement('iframe');
|
||||||
iframe.src = barPageUrl;
|
iframe.src = barPageUrl;
|
||||||
@@ -447,7 +448,7 @@ document.addEventListener('DOMContentLoaded', function (event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function sendPlatformMessage(msg) {
|
function sendPlatformMessage(msg) {
|
||||||
if (isSafariApi) {
|
if (isSafari) {
|
||||||
safari.self.tab.dispatchMessage('bitwarden', msg);
|
safari.self.tab.dispatchMessage('bitwarden', msg);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ export default class BrowserPlatformUtilsService implements PlatformUtilsService
|
|||||||
return this.deviceCache;
|
return this.deviceCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
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.Firefox;
|
this.deviceCache = DeviceType.Firefox;
|
||||||
} else if ((!!(window as any).opr && !!opr.addons) || !!(window as any).opera ||
|
} else if ((!!(window as any).opr && !!opr.addons) || !!(window as any).opera ||
|
||||||
navigator.userAgent.indexOf(' OPR/') >= 0) {
|
navigator.userAgent.indexOf(' OPR/') >= 0) {
|
||||||
@@ -70,9 +70,10 @@ export default class BrowserPlatformUtilsService implements PlatformUtilsService
|
|||||||
this.deviceCache = DeviceType.Edge;
|
this.deviceCache = DeviceType.Edge;
|
||||||
} else if (navigator.userAgent.indexOf(' Vivaldi/') !== -1) {
|
} else if (navigator.userAgent.indexOf(' Vivaldi/') !== -1) {
|
||||||
this.deviceCache = DeviceType.Vivaldi;
|
this.deviceCache = DeviceType.Vivaldi;
|
||||||
} else if (navigator.userAgent.indexOf('Safari') !== -1 && navigator.userAgent.indexOf('Chrome') === -1) {
|
} else if ((window as any).safari && navigator.userAgent.indexOf(' Safari/') !== -1 &&
|
||||||
|
navigator.userAgent.indexOf('Chrome') === -1) {
|
||||||
this.deviceCache = DeviceType.Safari;
|
this.deviceCache = DeviceType.Safari;
|
||||||
} else if ((window as any).chrome) {
|
} else if ((window as any).chrome && navigator.userAgent.indexOf(' Chrome/') !== -1) {
|
||||||
this.deviceCache = DeviceType.Chrome;
|
this.deviceCache = DeviceType.Chrome;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user