mirror of
https://github.com/bitwarden/browser
synced 2026-02-09 13:10:17 +00:00
[PM-19814] Use webNavigation.onCompleted for redirect to ensure that the redirect only happens when they land on the page.
This commit is contained in:
@@ -226,19 +226,27 @@ export class PhishingDetectionService {
|
||||
}
|
||||
|
||||
static setupListeners(): void {
|
||||
chrome.webRequest.onCompleted.addListener(
|
||||
(details: chrome.webRequest.WebRequestDetails): void => {
|
||||
chrome.webNavigation.onCompleted.addListener(
|
||||
(details: chrome.webNavigation.WebNavigationFramedCallbackDetails): void => {
|
||||
const url = new URL(details.url);
|
||||
const result = PhishingDetectionService.knownPhishingDomains.has(url.hostname);
|
||||
|
||||
if (PhishingDetectionService.knownPhishingDomains.has(url.hostname)) {
|
||||
this.logService.debug("Phishing detection check", {
|
||||
details,
|
||||
result,
|
||||
url,
|
||||
});
|
||||
|
||||
if (result) {
|
||||
PhishingDetectionService.RedirectToWarningPage(url.hostname, details.tabId);
|
||||
}
|
||||
},
|
||||
{ urls: ["<all_urls>"], types: ["main_frame"] },
|
||||
);
|
||||
}
|
||||
|
||||
static RedirectToWarningPage(hostname: string, tabId: number) {
|
||||
this.logService.debug("Redirecting to warning page.");
|
||||
|
||||
const phishingWarningPage = chrome.runtime.getURL(
|
||||
"popup/index.html#/security/phishing-warning",
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user