diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/components/safe_browsing/content/browser | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-85-based.tar.gz |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/components/safe_browsing/content/browser')
8 files changed, 60 insertions, 52 deletions
diff --git a/chromium/components/safe_browsing/content/browser/BUILD.gn b/chromium/components/safe_browsing/content/browser/BUILD.gn index 6111969ed2b..0b942f26ce3 100644 --- a/chromium/components/safe_browsing/content/browser/BUILD.gn +++ b/chromium/components/safe_browsing/content/browser/BUILD.gn @@ -33,7 +33,7 @@ jumbo_source_set("browser") { "//components/safe_browsing/core/common:common", "//components/safe_browsing/core/db:database_manager", "//components/safe_browsing/core/realtime:policy_engine", - "//components/safe_browsing/core/realtime:url_lookup_service", + "//components/safe_browsing/core/realtime:url_lookup_service_base", "//components/safe_browsing/core/web_ui:constants", "//components/security_interstitials/content:security_interstitial_page", "//components/security_interstitials/core:unsafe_resource", diff --git a/chromium/components/safe_browsing/content/browser/browser_url_loader_throttle.cc b/chromium/components/safe_browsing/content/browser/browser_url_loader_throttle.cc index cb3aa4a82be..2fa3d9cc4c9 100644 --- a/chromium/components/safe_browsing/content/browser/browser_url_loader_throttle.cc +++ b/chromium/components/safe_browsing/content/browser/browser_url_loader_throttle.cc @@ -13,7 +13,7 @@ #include "components/safe_browsing/core/common/safebrowsing_constants.h" #include "components/safe_browsing/core/common/utils.h" #include "components/safe_browsing/core/realtime/policy_engine.h" -#include "components/safe_browsing/core/realtime/url_lookup_service.h" +#include "components/safe_browsing/core/realtime/url_lookup_service_base.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/web_contents.h" #include "net/log/net_log_event_type.h" @@ -34,14 +34,16 @@ class BrowserURLLoaderThrottle::CheckerOnIO base::RepeatingCallback<content::WebContents*()> web_contents_getter, base::WeakPtr<BrowserURLLoaderThrottle> throttle, bool real_time_lookup_enabled, - bool enhanced_protection_enabled, - base::WeakPtr<RealTimeUrlLookupService> url_lookup_service) + bool can_rt_check_subresource_url, + bool can_check_db, + base::WeakPtr<RealTimeUrlLookupServiceBase> url_lookup_service) : delegate_getter_(std::move(delegate_getter)), frame_tree_node_id_(frame_tree_node_id), web_contents_getter_(web_contents_getter), throttle_(std::move(throttle)), real_time_lookup_enabled_(real_time_lookup_enabled), - enhanced_protection_enabled_(enhanced_protection_enabled), + can_rt_check_subresource_url_(can_rt_check_subresource_url), + can_check_db_(can_check_db), url_lookup_service_(url_lookup_service) {} // Starts the initial safe browsing check. This check and future checks may be @@ -63,8 +65,8 @@ class BrowserURLLoaderThrottle::CheckerOnIO url, frame_tree_node_id_, -1 /* render_process_id */, -1 /* render_frame_id */, originated_from_service_worker); if (skip_checks_) { - base::PostTask( - FROM_HERE, {content::BrowserThread::UI}, + content::GetUIThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&BrowserURLLoaderThrottle::SkipChecks, throttle_)); return; } @@ -72,7 +74,7 @@ class BrowserURLLoaderThrottle::CheckerOnIO url_checker_ = std::make_unique<SafeBrowsingUrlCheckerImpl>( headers, load_flags, resource_type, has_user_gesture, url_checker_delegate, web_contents_getter_, real_time_lookup_enabled_, - enhanced_protection_enabled_, url_lookup_service_); + can_rt_check_subresource_url_, can_check_db_, url_lookup_service_); CheckUrl(url, method); } @@ -81,8 +83,8 @@ class BrowserURLLoaderThrottle::CheckerOnIO void CheckUrl(const GURL& url, const std::string& method) { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); if (skip_checks_) { - base::PostTask( - FROM_HERE, {content::BrowserThread::UI}, + content::GetUIThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&BrowserURLLoaderThrottle::SkipChecks, throttle_)); return; } @@ -108,8 +110,8 @@ class BrowserURLLoaderThrottle::CheckerOnIO return; } - base::PostTask( - FROM_HERE, {content::BrowserThread::UI}, + content::GetUIThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&BrowserURLLoaderThrottle::NotifySlowCheck, throttle_)); // In this case |proceed| and |showed_interstitial| should be ignored. The @@ -124,8 +126,8 @@ class BrowserURLLoaderThrottle::CheckerOnIO void OnCompleteCheck(bool slow_check, bool proceed, bool showed_interstitial) { - base::PostTask( - FROM_HERE, {content::BrowserThread::UI}, + content::GetUIThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&BrowserURLLoaderThrottle::OnCompleteCheck, throttle_, slow_check, proceed, showed_interstitial)); } @@ -139,8 +141,9 @@ class BrowserURLLoaderThrottle::CheckerOnIO bool skip_checks_ = false; base::WeakPtr<BrowserURLLoaderThrottle> throttle_; bool real_time_lookup_enabled_ = false; - bool enhanced_protection_enabled_ = false; - base::WeakPtr<RealTimeUrlLookupService> url_lookup_service_; + bool can_rt_check_subresource_url_ = false; + bool can_check_db_ = true; + base::WeakPtr<RealTimeUrlLookupServiceBase> url_lookup_service_; }; // static @@ -148,7 +151,7 @@ std::unique_ptr<BrowserURLLoaderThrottle> BrowserURLLoaderThrottle::Create( GetDelegateCallback delegate_getter, const base::RepeatingCallback<content::WebContents*()>& web_contents_getter, int frame_tree_node_id, - base::WeakPtr<RealTimeUrlLookupService> url_lookup_service) { + base::WeakPtr<RealTimeUrlLookupServiceBase> url_lookup_service) { return base::WrapUnique<BrowserURLLoaderThrottle>( new BrowserURLLoaderThrottle(std::move(delegate_getter), web_contents_getter, frame_tree_node_id, @@ -159,7 +162,7 @@ BrowserURLLoaderThrottle::BrowserURLLoaderThrottle( GetDelegateCallback delegate_getter, const base::RepeatingCallback<content::WebContents*()>& web_contents_getter, int frame_tree_node_id, - base::WeakPtr<RealTimeUrlLookupService> url_lookup_service) { + base::WeakPtr<RealTimeUrlLookupServiceBase> url_lookup_service) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); // Decide whether to do real time URL lookups or not. @@ -167,13 +170,18 @@ BrowserURLLoaderThrottle::BrowserURLLoaderThrottle( url_lookup_service ? url_lookup_service->CanPerformFullURLLookup() : false; - bool enhanced_protection_enabled = - url_lookup_service && url_lookup_service->IsUserEpOptedIn(); + bool can_rt_check_subresource_url = + url_lookup_service && url_lookup_service->CanCheckSubresourceURL(); + // Decide whether safe browsing database can be checked. + // If url_lookup_service is null, safe browsing database should be checked by + // default. + bool can_check_db = + url_lookup_service ? url_lookup_service->CanCheckSafeBrowsingDb() : true; io_checker_ = std::make_unique<CheckerOnIO>( std::move(delegate_getter), frame_tree_node_id, web_contents_getter, weak_factory_.GetWeakPtr(), real_time_lookup_enabled, - enhanced_protection_enabled, url_lookup_service); + can_rt_check_subresource_url, can_check_db, url_lookup_service); } BrowserURLLoaderThrottle::~BrowserURLLoaderThrottle() { @@ -193,8 +201,8 @@ void BrowserURLLoaderThrottle::WillStartRequest( original_url_ = request->url; pending_checks_++; - base::PostTask( - FROM_HERE, {content::BrowserThread::IO}, + content::GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce( &BrowserURLLoaderThrottle::CheckerOnIO::Start, io_checker_->AsWeakPtr(), request->headers, request->load_flags, @@ -223,8 +231,8 @@ void BrowserURLLoaderThrottle::WillRedirectRequest( return; pending_checks_++; - base::PostTask( - FROM_HERE, {content::BrowserThread::IO}, + content::GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&BrowserURLLoaderThrottle::CheckerOnIO::CheckUrl, io_checker_->AsWeakPtr(), redirect_info->new_url, redirect_info->new_method)); @@ -324,8 +332,8 @@ void BrowserURLLoaderThrottle::NotifySlowCheck() { } void BrowserURLLoaderThrottle::DeleteCheckerOnIO() { - base::DeleteSoon(FROM_HERE, {content::BrowserThread::IO}, - std::move(io_checker_)); + content::GetIOThreadTaskRunner({})->DeleteSoon(FROM_HERE, + std::move(io_checker_)); } } // namespace safe_browsing diff --git a/chromium/components/safe_browsing/content/browser/browser_url_loader_throttle.h b/chromium/components/safe_browsing/content/browser/browser_url_loader_throttle.h index d31b38a3dbc..fbd0536a4c7 100644 --- a/chromium/components/safe_browsing/content/browser/browser_url_loader_throttle.h +++ b/chromium/components/safe_browsing/content/browser/browser_url_loader_throttle.h @@ -28,7 +28,7 @@ namespace safe_browsing { class UrlCheckerDelegate; -class RealTimeUrlLookupService; +class RealTimeUrlLookupServiceBase; // BrowserURLLoaderThrottle is used in the browser process to query // SafeBrowsing to determine whether a URL and also its redirect URLs are safe @@ -49,7 +49,7 @@ class BrowserURLLoaderThrottle : public blink::URLLoaderThrottle { const base::RepeatingCallback<content::WebContents*()>& web_contents_getter, int frame_tree_node_id, - base::WeakPtr<RealTimeUrlLookupService> url_lookup_service); + base::WeakPtr<RealTimeUrlLookupServiceBase> url_lookup_service); ~BrowserURLLoaderThrottle() override; @@ -86,7 +86,7 @@ class BrowserURLLoaderThrottle : public blink::URLLoaderThrottle { const base::RepeatingCallback<content::WebContents*()>& web_contents_getter, int frame_tree_node_id, - base::WeakPtr<RealTimeUrlLookupService> url_lookup_service); + base::WeakPtr<RealTimeUrlLookupServiceBase> url_lookup_service); // |slow_check| indicates whether it reports the result of a slow check. // (Please see comments of CheckerOnIO::OnCheckUrlResult() for what slow check diff --git a/chromium/components/safe_browsing/content/browser/mojo_safe_browsing_impl.cc b/chromium/components/safe_browsing/content/browser/mojo_safe_browsing_impl.cc index 43e5f816d0b..b9dc2d53324 100644 --- a/chromium/components/safe_browsing/content/browser/mojo_safe_browsing_impl.cc +++ b/chromium/components/safe_browsing/content/browser/mojo_safe_browsing_impl.cc @@ -156,7 +156,9 @@ void MojoSafeBrowsingImpl::CreateCheckerAndCheck( delegate_, base::BindRepeating(&GetWebContentsFromID, render_process_id_, static_cast<int>(render_frame_id)), - /*real_time_lookup_enabled=*/false, /*enhanced_protection_enabled=*/false, + /*real_time_lookup_enabled=*/false, + /*can_rt_check_subresource_url=*/false, + /*can_check_db=*/true, /*url_lookup_service=*/nullptr); checker_impl->CheckUrl( diff --git a/chromium/components/safe_browsing/content/browser/safe_browsing_url_checker_impl_content.cc b/chromium/components/safe_browsing/content/browser/safe_browsing_url_checker_impl_content.cc index 4ac3714571e..b22dc6eed7d 100644 --- a/chromium/components/safe_browsing/content/browser/safe_browsing_url_checker_impl_content.cc +++ b/chromium/components/safe_browsing/content/browser/safe_browsing_url_checker_impl_content.cc @@ -13,7 +13,7 @@ #include "components/safe_browsing/core/common/safebrowsing_constants.h" #include "components/safe_browsing/core/common/thread_utils.h" #include "components/safe_browsing/core/realtime/policy_engine.h" -#include "components/safe_browsing/core/realtime/url_lookup_service.h" +#include "components/safe_browsing/core/realtime/url_lookup_service_base.h" #include "components/safe_browsing/core/web_ui/constants.h" namespace safe_browsing { @@ -21,8 +21,8 @@ namespace safe_browsing { bool SafeBrowsingUrlCheckerImpl::CanPerformFullURLLookup(const GURL& url) { return real_time_lookup_enabled_ && RealTimePolicyEngine::CanPerformFullURLLookupForResourceType( - resource_type_, enhanced_protection_enabled_) && - RealTimeUrlLookupService::CanCheckUrl(url); + resource_type_, can_rt_check_subresource_url_) && + RealTimeUrlLookupServiceBase::CanCheckUrl(url); } void SafeBrowsingUrlCheckerImpl::OnRTLookupRequest( @@ -48,7 +48,7 @@ void SafeBrowsingUrlCheckerImpl::OnRTLookupResponse( bool is_expected_resource_type = (ResourceType::kMainFrame == resource_type_) || ((ResourceType::kSubFrame == resource_type_) && - enhanced_protection_enabled_); + can_rt_check_subresource_url_); DCHECK(is_expected_resource_type); const GURL& url = urls_[next_index_].url; @@ -75,8 +75,9 @@ void SafeBrowsingUrlCheckerImpl::OnRTLookupResponse( // TODO(crbug.com/1033692): Only take the first threat info into account // because threat infos are returned in decreasing order of severity. // Consider extend it to support multiple threat types. - sb_threat_type = RealTimeUrlLookupService::GetSBThreatTypeForRTThreatType( - response->threat_info(0).threat_type()); + sb_threat_type = + RealTimeUrlLookupServiceBase::GetSBThreatTypeForRTThreatType( + response->threat_info(0).threat_type()); } OnUrlResult(url, sb_threat_type, ThreatMetadata()); } diff --git a/chromium/components/safe_browsing/content/browser/threat_details.cc b/chromium/components/safe_browsing/content/browser/threat_details.cc index a71ac3092c4..c63087e8c8f 100644 --- a/chromium/components/safe_browsing/content/browser/threat_details.cc +++ b/chromium/components/safe_browsing/content/browser/threat_details.cc @@ -20,7 +20,6 @@ #include "base/stl_util.h" #include "base/strings/string_piece.h" #include "base/strings/string_util.h" -#include "base/task/post_task.h" #include "components/history/core/browser/history_service.h" #include "components/safe_browsing/content/base_ui_manager.h" #include "components/safe_browsing/content/browser/threat_details_cache.h" @@ -849,8 +848,8 @@ void ThreatDetails::OnCacheCollectionReady() { return; } - base::PostTask( - FROM_HERE, {content::BrowserThread::UI}, + content::GetUIThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&WebUIInfoSingleton::AddToCSBRRsSent, base::Unretained(WebUIInfoSingleton::GetInstance()), std::move(report_))); @@ -877,8 +876,8 @@ void ThreatDetails::MaybeFillReferrerChain() { void ThreatDetails::AllDone() { is_all_done_ = true; - base::PostTask(FROM_HERE, {content::BrowserThread::UI}, - base::BindOnce(std::move(done_callback_), + content::GetUIThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(std::move(done_callback_), base::Unretained(web_contents()))); } diff --git a/chromium/components/safe_browsing/content/browser/threat_details_cache.cc b/chromium/components/safe_browsing/content/browser/threat_details_cache.cc index d0ea614c3bd..70c5ee9278c 100644 --- a/chromium/components/safe_browsing/content/browser/threat_details_cache.cc +++ b/chromium/components/safe_browsing/content/browser/threat_details_cache.cc @@ -12,7 +12,6 @@ #include "base/hash/md5.h" #include "base/lazy_instance.h" #include "base/strings/string_util.h" -#include "base/task/post_task.h" #include "components/safe_browsing/content/browser/threat_details.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" @@ -52,8 +51,8 @@ void ThreatDetailsCacheCollector::StartCacheCollection( // Post a task in the message loop, so the callers don't need to // check if we call their callback immediately. - base::PostTask(FROM_HERE, {BrowserThread::UI}, - base::BindOnce(&ThreatDetailsCacheCollector::OpenEntry, this)); + content::GetUIThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&ThreatDetailsCacheCollector::OpenEntry, this)); } bool ThreatDetailsCacheCollector::HasStarted() { @@ -227,15 +226,15 @@ void ThreatDetailsCacheCollector::AdvanceEntry() { current_load_.reset(); // Create a task so we don't take over the UI thread for too long. - base::PostTask(FROM_HERE, {BrowserThread::UI}, - base::BindOnce(&ThreatDetailsCacheCollector::OpenEntry, this)); + content::GetUIThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&ThreatDetailsCacheCollector::OpenEntry, this)); } void ThreatDetailsCacheCollector::AllDone(bool success) { DVLOG(1) << "AllDone"; DCHECK_CURRENTLY_ON(BrowserThread::UI); *result_ = success; - base::PostTask(FROM_HERE, {BrowserThread::UI}, std::move(callback_)); + content::GetUIThreadTaskRunner({})->PostTask(FROM_HERE, std::move(callback_)); } } // namespace safe_browsing diff --git a/chromium/components/safe_browsing/content/browser/threat_details_history.cc b/chromium/components/safe_browsing/content/browser/threat_details_history.cc index d434e97c4ac..c9976122b8c 100644 --- a/chromium/components/safe_browsing/content/browser/threat_details_history.cc +++ b/chromium/components/safe_browsing/content/browser/threat_details_history.cc @@ -10,7 +10,6 @@ #include "base/bind.h" #include "base/bind_helpers.h" -#include "base/task/post_task.h" #include "components/safe_browsing/content/browser/threat_details.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" @@ -41,8 +40,8 @@ void ThreatDetailsRedirectsCollector::StartHistoryCollection( return; } - base::PostTask( - FROM_HERE, {BrowserThread::UI}, + content::GetUIThreadTaskRunner({})->PostTask( + FROM_HERE, base::BindOnce(&ThreatDetailsRedirectsCollector::StartGetRedirects, this, urls)); } @@ -107,7 +106,7 @@ void ThreatDetailsRedirectsCollector::OnGotQueryRedirectsTo( void ThreatDetailsRedirectsCollector::AllDone() { DVLOG(1) << "AllDone"; - base::PostTask(FROM_HERE, {BrowserThread::UI}, std::move(callback_)); + content::GetUIThreadTaskRunner({})->PostTask(FROM_HERE, std::move(callback_)); } void ThreatDetailsRedirectsCollector::HistoryServiceBeingDeleted( |