1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/safe_browsing/chrome_ui_manager_delegate.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/interstitials/enterprise_util.h"
#include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
#include "chrome/browser/preloading/prefetch/no_state_prefetch/chrome_no_state_prefetch_contents_delegate.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/safe_browsing/chrome_ping_manager_factory.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
#include "extensions/buildflags/buildflags.h"
#include "services/network/public/cpp/cross_thread_pending_shared_url_loader_factory.h"
#if BUILDFLAG(ENABLE_EXTENSIONS)
#include "extensions/browser/process_manager.h" // nogncheck
#endif
namespace safe_browsing {
ChromeSafeBrowsingUIManagerDelegate::ChromeSafeBrowsingUIManagerDelegate() =
default;
ChromeSafeBrowsingUIManagerDelegate::~ChromeSafeBrowsingUIManagerDelegate() =
default;
std::string ChromeSafeBrowsingUIManagerDelegate::GetApplicationLocale() {
return g_browser_process->GetApplicationLocale();
}
void ChromeSafeBrowsingUIManagerDelegate::
TriggerSecurityInterstitialShownExtensionEventIfDesired(
content::WebContents* web_contents,
const GURL& page_url,
const std::string& reason,
int net_error_code) {
MaybeTriggerSecurityInterstitialShownEvent(web_contents, page_url, reason,
net_error_code);
}
void ChromeSafeBrowsingUIManagerDelegate::
TriggerSecurityInterstitialProceededExtensionEventIfDesired(
content::WebContents* web_contents,
const GURL& page_url,
const std::string& reason,
int net_error_code) {
MaybeTriggerSecurityInterstitialProceededEvent(web_contents, page_url, reason,
net_error_code);
}
void ChromeSafeBrowsingUIManagerDelegate::
TriggerUrlFilteringInterstitialExtensionEventIfDesired(
content::WebContents* web_contents,
const GURL& page_url,
const std::string& threat_type,
safe_browsing::RTLookupResponse rt_lookup_response) {
MaybeTriggerUrlFilteringInterstitialEvent(web_contents, page_url, threat_type,
rt_lookup_response);
}
prerender::NoStatePrefetchContents*
ChromeSafeBrowsingUIManagerDelegate::GetNoStatePrefetchContentsIfExists(
content::WebContents* web_contents) {
return prerender::ChromeNoStatePrefetchContentsDelegate::FromWebContents(
web_contents);
}
bool ChromeSafeBrowsingUIManagerDelegate::IsHostingExtension(
content::WebContents* web_contents) {
#if BUILDFLAG(ENABLE_EXTENSIONS)
extensions::ProcessManager* extension_manager =
extensions::ProcessManager::Get(web_contents->GetBrowserContext());
if (!extension_manager)
return false;
extensions::ExtensionHost* extension_host =
extension_manager->GetBackgroundHostForRenderFrameHost(
web_contents->GetPrimaryMainFrame());
return extension_host != nullptr;
#else
return false;
#endif
}
PrefService* ChromeSafeBrowsingUIManagerDelegate::GetPrefs(
content::BrowserContext* browser_context) {
return Profile::FromBrowserContext(browser_context)->GetPrefs();
}
history::HistoryService* ChromeSafeBrowsingUIManagerDelegate::GetHistoryService(
content::BrowserContext* browser_context) {
return HistoryServiceFactory::GetForProfile(
Profile::FromBrowserContext(browser_context),
ServiceAccessType::EXPLICIT_ACCESS);
}
PingManager* ChromeSafeBrowsingUIManagerDelegate::GetPingManager(
content::BrowserContext* browser_context) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
return ChromePingManagerFactory::GetForBrowserContext(browser_context);
}
bool ChromeSafeBrowsingUIManagerDelegate::IsMetricsAndCrashReportingEnabled() {
return ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled();
}
bool ChromeSafeBrowsingUIManagerDelegate::IsSendingOfHitReportsEnabled() {
return true;
}
} // namespace safe_browsing
|