Commit f8cafb1d authored by Julie Jeongeun Kim's avatar Julie Jeongeun Kim Committed by Chromium LUCI CQ

Clean up resource_request_detector.{cc,h}

This CL cleans up resource_request_detector.{cc,h} and
ServicesDelegate::ProcessResourceRequest() along with
all the production and test code related to it.

Bug: 1059639
Change-Id: I353b6beecee4e6c00b06fdc8612f4ca2c00b459f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2560185Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarDaniel Rubery <drubery@chromium.org>
Commit-Queue: Julie Kim <jkim@igalia.com>
Cr-Commit-Position: refs/heads/master@{#834546}
parent d1314fbf
...@@ -223,8 +223,6 @@ static_library("safe_browsing") { ...@@ -223,8 +223,6 @@ static_library("safe_browsing") {
"incident_reporting/platform_state_store.h", "incident_reporting/platform_state_store.h",
"incident_reporting/preference_validation_delegate.cc", "incident_reporting/preference_validation_delegate.cc",
"incident_reporting/preference_validation_delegate.h", "incident_reporting/preference_validation_delegate.h",
"incident_reporting/resource_request_detector.cc",
"incident_reporting/resource_request_detector.h",
"incident_reporting/resource_request_incident.cc", "incident_reporting/resource_request_incident.cc",
"incident_reporting/resource_request_incident.h", "incident_reporting/resource_request_incident.h",
"incident_reporting/state_store.cc", "incident_reporting/state_store.cc",
......
...@@ -70,9 +70,6 @@ void ServicesDelegateAndroid::ShutdownServices() { ...@@ -70,9 +70,6 @@ void ServicesDelegateAndroid::ShutdownServices() {
void ServicesDelegateAndroid::RefreshState(bool enable) {} void ServicesDelegateAndroid::RefreshState(bool enable) {}
void ServicesDelegateAndroid::ProcessResourceRequest(
const ResourceRequestInfo* request) {}
std::unique_ptr<prefs::mojom::TrackedPreferenceValidationDelegate> std::unique_ptr<prefs::mojom::TrackedPreferenceValidationDelegate>
ServicesDelegateAndroid::CreatePreferenceValidationDelegate(Profile* profile) { ServicesDelegateAndroid::CreatePreferenceValidationDelegate(Profile* profile) {
return nullptr; return nullptr;
......
...@@ -29,7 +29,6 @@ class ServicesDelegateAndroid : public ServicesDelegate { ...@@ -29,7 +29,6 @@ class ServicesDelegateAndroid : public ServicesDelegate {
SafeBrowsingDatabaseManager* database_manager) override; SafeBrowsingDatabaseManager* database_manager) override;
void ShutdownServices() override; void ShutdownServices() override;
void RefreshState(bool enable) override; void RefreshState(bool enable) override;
void ProcessResourceRequest(const ResourceRequestInfo* request) override;
std::unique_ptr<prefs::mojom::TrackedPreferenceValidationDelegate> std::unique_ptr<prefs::mojom::TrackedPreferenceValidationDelegate>
CreatePreferenceValidationDelegate(Profile* profile) override; CreatePreferenceValidationDelegate(Profile* profile) override;
void RegisterDelayedAnalysisCallback( void RegisterDelayedAnalysisCallback(
......
// Copyright 2015 The Chromium Authors. All rights reserved.
// 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/incident_reporting/resource_request_detector.h"
#include <utility>
#include "base/bind.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/safe_browsing/incident_reporting/incident_receiver.h"
#include "chrome/browser/safe_browsing/incident_reporting/resource_request_incident.h"
#include "components/safe_browsing/core/proto/csd.pb.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/site_instance.h"
#include "crypto/sha2.h"
#include "third_party/blink/public/mojom/loader/resource_load_info.mojom-shared.h"
#include "url/gurl.h"
namespace {
Profile* GetProfileForRenderProcessId(int render_process_id) {
// How to get a profile from a RenderProcess id:
// 1) Get the RenderProcessHost
// 2) From 1) Get the BrowserContext
// 3) From 2) Get the Profile.
Profile* profile = nullptr;
content::RenderProcessHost* render_process_host =
content::RenderProcessHost::FromID(render_process_id);
if (render_process_host) {
content::BrowserContext* browser_context =
render_process_host->GetBrowserContext();
if (browser_context)
profile = Profile::FromBrowserContext(browser_context);
}
return profile;
}
GURL GetUrlForRenderFrameId(int render_process_id, int render_frame_id) {
content::RenderFrameHost* render_frame_host =
content::RenderFrameHost::FromID(render_process_id, render_frame_id);
if (render_frame_host)
return render_frame_host->GetLastCommittedURL();
return GURL();
}
} // namespace
namespace safe_browsing {
namespace {
// Implementation of SafeBrowsingDatabaseManager::Client that is used to lookup
// a resource blacklist. Can be constructed on any thread.
class ResourceRequestDetectorClient
: public SafeBrowsingDatabaseManager::Client,
public base::RefCountedThreadSafe<ResourceRequestDetectorClient> {
public:
using ResourceRequestIncidentMessage =
ClientIncidentReport::IncidentData::ResourceRequestIncident;
using OnResultCallback =
base::OnceCallback<void(std::unique_ptr<ResourceRequestIncidentMessage>)>;
static void Start(
const GURL& resource_url,
const scoped_refptr<SafeBrowsingDatabaseManager>& database_manager,
OnResultCallback callback) {
auto client = base::WrapRefCounted(new ResourceRequestDetectorClient(
std::move(database_manager), std::move(callback)));
content::GetIOThreadTaskRunner({})->PostTask(
FROM_HERE, base::BindOnce(&ResourceRequestDetectorClient::StartCheck,
client, resource_url));
}
private:
ResourceRequestDetectorClient(
scoped_refptr<SafeBrowsingDatabaseManager> database_manager,
OnResultCallback callback)
: database_manager_(std::move(database_manager)),
callback_(std::move(callback)) {}
friend class base::RefCountedThreadSafe<ResourceRequestDetectorClient>;
~ResourceRequestDetectorClient() override {}
void StartCheck(const GURL& resource_url) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
if (!database_manager_)
return;
AddRef();
// If database_manager_->CheckResourceUrl returns false, the resource might
// be blacklisted and the response will come in OnCheckResourceUrlResult
// callback, where AddRef() is balanced by Release().
// If the check returns true, the resource is not blacklisted and the
// client object may be destroyed immediately.
if (database_manager_->CheckResourceUrl(resource_url, this)) {
Release();
}
}
void OnCheckResourceUrlResult(const GURL& url,
SBThreatType threat_type,
const std::string& threat_hash) override {
if (threat_type == SB_THREAT_TYPE_BLACKLISTED_RESOURCE) {
std::unique_ptr<ResourceRequestIncidentMessage> incident_data(
new ResourceRequestIncidentMessage());
incident_data->set_type(ResourceRequestIncidentMessage::TYPE_PATTERN);
incident_data->set_digest(threat_hash);
content::GetUIThreadTaskRunner({})->PostTask(
FROM_HERE,
base::BindOnce(std::move(callback_), std::move(incident_data)));
}
Release(); // Balanced in StartCheck.
}
scoped_refptr<SafeBrowsingDatabaseManager> database_manager_;
OnResultCallback callback_;
DISALLOW_COPY_AND_ASSIGN(ResourceRequestDetectorClient);
};
} // namespace
ResourceRequestDetector::ResourceRequestDetector(
scoped_refptr<SafeBrowsingDatabaseManager> database_manager,
std::unique_ptr<IncidentReceiver> incident_receiver)
: incident_receiver_(std::move(incident_receiver)),
database_manager_(database_manager),
allow_null_profile_for_testing_(false) {}
ResourceRequestDetector::~ResourceRequestDetector() {
}
void ResourceRequestDetector::ProcessResourceRequest(
const ResourceRequestInfo* request) {
// Only look at actual net requests (e.g., not chrome-extensions://id/foo.js).
if (!request->url.SchemeIsHTTPOrHTTPS())
return;
if (request->resource_type == blink::mojom::ResourceType::kSubFrame ||
request->resource_type == blink::mojom::ResourceType::kScript ||
request->resource_type == blink::mojom::ResourceType::kObject) {
ResourceRequestDetectorClient::Start(
request->url, database_manager_,
base::BindOnce(&ResourceRequestDetector::ReportIncidentOnUIThread,
weak_ptr_factory_.GetWeakPtr(),
request->render_process_id, request->render_frame_id));
}
}
void ResourceRequestDetector::set_allow_null_profile_for_testing(
bool allow_null_profile_for_testing) {
allow_null_profile_for_testing_ = allow_null_profile_for_testing;
}
void ResourceRequestDetector::ReportIncidentOnUIThread(
int render_process_id,
int render_frame_id,
std::unique_ptr<ClientIncidentReport_IncidentData_ResourceRequestIncident>
incident_data) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
Profile* profile = GetProfileForRenderProcessId(render_process_id);
if (profile || allow_null_profile_for_testing_) {
// Add the URL obtained from the RenderFrameHost, if available.
GURL host_url = GetUrlForRenderFrameId(render_process_id, render_frame_id);
if (host_url.is_valid())
incident_data->set_origin(host_url.GetOrigin().spec());
incident_receiver_->AddIncidentForProfile(
profile,
std::make_unique<ResourceRequestIncident>(std::move(incident_data)));
}
}
} // namespace safe_browsing
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_RESOURCE_REQUEST_DETECTOR_H_
#define CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_RESOURCE_REQUEST_DETECTOR_H_
#include <memory>
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/safe_browsing/incident_reporting/incident_receiver.h"
#include "components/safe_browsing/core/db/database_manager.h"
namespace safe_browsing {
class ClientIncidentReport_IncidentData_ResourceRequestIncident;
struct ResourceRequestInfo {
GURL url;
blink::mojom::ResourceType resource_type;
int render_process_id;
int render_frame_id;
};
// Observes network requests and reports suspicious activity.
class ResourceRequestDetector {
public:
ResourceRequestDetector(
scoped_refptr<SafeBrowsingDatabaseManager> sb_database_manager,
std::unique_ptr<IncidentReceiver> incident_receiver);
~ResourceRequestDetector();
// Analyzes the |request| and triggers an incident report on suspicious
// script inclusion.
void ProcessResourceRequest(const ResourceRequestInfo* request);
protected:
// Testing hook.
void set_allow_null_profile_for_testing(bool allow_null_profile_for_testing);
private:
void ReportIncidentOnUIThread(
int render_process_id,
int render_frame_id,
std::unique_ptr<ClientIncidentReport_IncidentData_ResourceRequestIncident>
incident_data);
std::unique_ptr<IncidentReceiver> incident_receiver_;
scoped_refptr<SafeBrowsingDatabaseManager> database_manager_;
bool allow_null_profile_for_testing_;
base::WeakPtrFactory<ResourceRequestDetector> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(ResourceRequestDetector);
};
} // namespace safe_browsing
#endif // CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_RESOURCE_REQUEST_DETECTOR_H_
// Copyright 2015 The Chromium Authors. All rights reserved.
// 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/incident_reporting/resource_request_detector.h"
#include <utility>
#include "base/bind.h"
#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
#include "chrome/browser/safe_browsing/incident_reporting/incident.h"
#include "chrome/browser/safe_browsing/incident_reporting/incident_receiver.h"
#include "chrome/browser/safe_browsing/incident_reporting/mock_incident_receiver.h"
#include "components/safe_browsing/core/db/test_database_manager.h"
#include "components/safe_browsing/core/proto/csd.pb.h"
#include "content/public/test/browser_task_environment.h"
#include "crypto/sha2.h"
#include "ipc/ipc_message.h"
#include "net/base/request_priority.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/loader/previews_state.h"
#include "third_party/blink/public/mojom/loader/resource_load_info.mojom-shared.h"
#include "url/gurl.h"
using ::testing::IsNull;
using ::testing::Return;
using ::testing::StrictMock;
using ::testing::WithArg;
using ::testing::_;
namespace safe_browsing {
namespace {
class FakeResourceRequestDetector : public ResourceRequestDetector {
public:
FakeResourceRequestDetector(
scoped_refptr<SafeBrowsingDatabaseManager> database_manager,
std::unique_ptr<IncidentReceiver> incident_receiver)
: ResourceRequestDetector(database_manager,
std::move(incident_receiver)) {
FakeResourceRequestDetector::set_allow_null_profile_for_testing(true);
}
};
class MockSafeBrowsingDatabaseManager : public TestSafeBrowsingDatabaseManager {
public:
MockSafeBrowsingDatabaseManager() {}
MOCK_METHOD2(CheckResourceUrl, bool(
const GURL& url,
SafeBrowsingDatabaseManager::Client* client));
protected:
~MockSafeBrowsingDatabaseManager() override {}
private:
DISALLOW_COPY_AND_ASSIGN(MockSafeBrowsingDatabaseManager);
};
} // namespace
ACTION_P3(CallClientWithResult, url, threat_type, threat_hash) {
arg1->OnCheckResourceUrlResult(url, threat_type, threat_hash);
return false;
}
class ResourceRequestDetectorTest : public testing::Test {
protected:
using ResourceRequestIncidentMessage =
ClientIncidentReport::IncidentData::ResourceRequestIncident;
ResourceRequestDetectorTest()
: mock_incident_receiver_(
new StrictMock<safe_browsing::MockIncidentReceiver>()),
mock_database_manager_(new StrictMock<MockSafeBrowsingDatabaseManager>),
fake_resource_request_detector_(
std::make_unique<FakeResourceRequestDetector>(
mock_database_manager_,
base::WrapUnique(mock_incident_receiver_))) {}
void TearDown() override {
fake_resource_request_detector_.reset();
mock_database_manager_ = nullptr;
base::RunLoop().RunUntilIdle();
}
void ExpectNoDatabaseCheck() {
EXPECT_CALL(*mock_database_manager_, CheckResourceUrl(_, _))
.Times(0);
}
void ExpectNegativeSyncDatabaseCheck(const std::string& url) {
EXPECT_CALL(*mock_database_manager_, CheckResourceUrl(GURL(url), _))
.WillOnce(Return(true));
}
void ExpectAsyncDatabaseCheck(const std::string& url,
bool is_blacklisted,
const std::string& digest) {
SBThreatType threat_type = is_blacklisted
? SB_THREAT_TYPE_BLACKLISTED_RESOURCE
: SB_THREAT_TYPE_SAFE;
const GURL gurl(url);
EXPECT_CALL(*mock_database_manager_, CheckResourceUrl(gurl, _))
.WillOnce(CallClientWithResult(gurl, threat_type, digest));
}
void ExpectNoIncident(const std::string& url,
blink::mojom::ResourceType resource_type) {
EXPECT_CALL(*mock_incident_receiver_, DoAddIncidentForProfile(IsNull(), _))
.Times(0);
ResourceRequestInfo info;
info.url = GURL(url);
info.resource_type = resource_type;
fake_resource_request_detector_->ProcessResourceRequest(&info);
base::RunLoop().RunUntilIdle();
}
void ExpectIncidentAdded(const std::string& url,
blink::mojom::ResourceType resource_type,
ResourceRequestIncidentMessage::Type expected_type,
const std::string& expected_digest) {
std::unique_ptr<Incident> incident;
EXPECT_CALL(*mock_incident_receiver_, DoAddIncidentForProfile(IsNull(), _))
.WillOnce(WithArg<1>(TakeIncident(&incident)));
ResourceRequestInfo info;
info.url = GURL(url);
info.resource_type = resource_type;
fake_resource_request_detector_->ProcessResourceRequest(&info);
base::RunLoop().RunUntilIdle();
ASSERT_TRUE(incident);
std::unique_ptr<ClientIncidentReport_IncidentData> incident_data =
incident->TakePayload();
ASSERT_TRUE(incident_data && incident_data->has_resource_request());
const ResourceRequestIncidentMessage& script_request_incident =
incident_data->resource_request();
EXPECT_TRUE(script_request_incident.has_digest());
EXPECT_EQ(expected_digest, script_request_incident.digest());
EXPECT_EQ(expected_type, script_request_incident.type());
}
protected:
content::BrowserTaskEnvironment task_environment_;
public:
StrictMock<safe_browsing::MockIncidentReceiver>* mock_incident_receiver_;
scoped_refptr<MockSafeBrowsingDatabaseManager> mock_database_manager_;
std::unique_ptr<FakeResourceRequestDetector> fake_resource_request_detector_;
private:
};
TEST_F(ResourceRequestDetectorTest, NoDbCheckForIgnoredResourceTypes) {
ExpectNoDatabaseCheck();
ExpectNoIncident("http://www.example.com/index.html",
blink::mojom::ResourceType::kMainFrame);
}
TEST_F(ResourceRequestDetectorTest, NoDbCheckForUnsupportedSchemes) {
ExpectNoDatabaseCheck();
ExpectNoIncident("file:///usr/local/script.js",
blink::mojom::ResourceType::kScript);
ExpectNoIncident("chrome-extension://abcdefghi/script.js",
blink::mojom::ResourceType::kScript);
}
TEST_F(ResourceRequestDetectorTest, NoEventForNegativeSynchronousDbCheck) {
const std::string url = "http://www.example.com/script.js";
ExpectNegativeSyncDatabaseCheck(url);
ExpectNoIncident(url, blink::mojom::ResourceType::kScript);
}
TEST_F(ResourceRequestDetectorTest, NoEventForNegativeAsynchronousDbCheck) {
const std::string url = "http://www.example.com/script.js";
ExpectAsyncDatabaseCheck(url, false, "");
ExpectNoIncident(url, blink::mojom::ResourceType::kScript);
}
TEST_F(ResourceRequestDetectorTest, EventAddedForSupportedSchemes) {
std::string schemes[] = {"http", "https"};
const std::string digest = "dummydigest";
const std::string domain_path = "www.example.com/script.js";
for (const auto& scheme : schemes) {
const std::string url = scheme + "://" + domain_path;
ExpectAsyncDatabaseCheck(url, true, digest);
ExpectIncidentAdded(url, blink::mojom::ResourceType::kScript,
ResourceRequestIncidentMessage::TYPE_PATTERN, digest);
}
}
TEST_F(ResourceRequestDetectorTest, EventAddedForSupportedResourceTypes) {
blink::mojom::ResourceType supported_types[] = {
blink::mojom::ResourceType::kScript,
blink::mojom::ResourceType::kSubFrame,
blink::mojom::ResourceType::kObject,
};
const std::string url = "http://www.example.com/";
const std::string digest = "dummydigest";
for (auto resource_type : supported_types) {
ExpectAsyncDatabaseCheck(url, true, digest);
ExpectIncidentAdded(url, resource_type,
ResourceRequestIncidentMessage::TYPE_PATTERN, digest);
}
}
} // namespace safe_browsing
...@@ -67,7 +67,6 @@ ...@@ -67,7 +67,6 @@
#include "chrome/browser/safe_browsing/download_protection/download_protection_service.h" #include "chrome/browser/safe_browsing/download_protection/download_protection_service.h"
#include "chrome/browser/safe_browsing/incident_reporting/binary_integrity_analyzer.h" #include "chrome/browser/safe_browsing/incident_reporting/binary_integrity_analyzer.h"
#include "chrome/browser/safe_browsing/incident_reporting/incident_reporting_service.h" #include "chrome/browser/safe_browsing/incident_reporting/incident_reporting_service.h"
#include "chrome/browser/safe_browsing/incident_reporting/resource_request_detector.h"
#endif #endif
using content::BrowserThread; using content::BrowserThread;
......
...@@ -39,8 +39,6 @@ class DownloadProtectionService; ...@@ -39,8 +39,6 @@ class DownloadProtectionService;
#endif #endif
class IncidentReportingService; class IncidentReportingService;
class PasswordProtectionService; class PasswordProtectionService;
class ResourceRequestDetector;
struct ResourceRequestInfo;
class SafeBrowsingService; class SafeBrowsingService;
class SafeBrowsingDatabaseManager; class SafeBrowsingDatabaseManager;
struct V4ProtocolConfig; struct V4ProtocolConfig;
...@@ -64,7 +62,6 @@ class ServicesDelegate { ...@@ -64,7 +62,6 @@ class ServicesDelegate {
virtual bool CanCreateDownloadProtectionService() = 0; virtual bool CanCreateDownloadProtectionService() = 0;
#endif #endif
virtual bool CanCreateIncidentReportingService() = 0; virtual bool CanCreateIncidentReportingService() = 0;
virtual bool CanCreateResourceRequestDetector() = 0;
// Caller takes ownership of the returned object. Cannot use std::unique_ptr // Caller takes ownership of the returned object. Cannot use std::unique_ptr
// because services may not be implemented for some build configs. // because services may not be implemented for some build configs.
...@@ -73,7 +70,6 @@ class ServicesDelegate { ...@@ -73,7 +70,6 @@ class ServicesDelegate {
virtual DownloadProtectionService* CreateDownloadProtectionService() = 0; virtual DownloadProtectionService* CreateDownloadProtectionService() = 0;
#endif #endif
virtual IncidentReportingService* CreateIncidentReportingService() = 0; virtual IncidentReportingService* CreateIncidentReportingService() = 0;
virtual ResourceRequestDetector* CreateResourceRequestDetector() = 0;
}; };
// Creates the ServicesDelegate using its's default ServicesCreator. // Creates the ServicesDelegate using its's default ServicesCreator.
...@@ -106,7 +102,6 @@ class ServicesDelegate { ...@@ -106,7 +102,6 @@ class ServicesDelegate {
virtual void RefreshState(bool enable) = 0; virtual void RefreshState(bool enable) = 0;
// See the SafeBrowsingService methods of the same name. // See the SafeBrowsingService methods of the same name.
virtual void ProcessResourceRequest(const ResourceRequestInfo* request) = 0;
virtual std::unique_ptr<prefs::mojom::TrackedPreferenceValidationDelegate> virtual std::unique_ptr<prefs::mojom::TrackedPreferenceValidationDelegate>
CreatePreferenceValidationDelegate(Profile* profile) = 0; CreatePreferenceValidationDelegate(Profile* profile) = 0;
virtual void RegisterDelayedAnalysisCallback( virtual void RegisterDelayedAnalysisCallback(
......
...@@ -83,11 +83,6 @@ void ServicesDelegateDesktop::Initialize() { ...@@ -83,11 +83,6 @@ void ServicesDelegateDesktop::Initialize() {
services_creator_->CanCreateIncidentReportingService()) services_creator_->CanCreateIncidentReportingService())
? services_creator_->CreateIncidentReportingService() ? services_creator_->CreateIncidentReportingService()
: CreateIncidentReportingService()); : CreateIncidentReportingService());
resource_request_detector_.reset(
(services_creator_ &&
services_creator_->CanCreateResourceRequestDetector())
? services_creator_->CreateResourceRequestDetector()
: CreateResourceRequestDetector());
} }
void ServicesDelegateDesktop::SetDatabaseManagerForTest( void ServicesDelegateDesktop::SetDatabaseManagerForTest(
...@@ -102,7 +97,6 @@ void ServicesDelegateDesktop::ShutdownServices() { ...@@ -102,7 +97,6 @@ void ServicesDelegateDesktop::ShutdownServices() {
download_service_.reset(); download_service_.reset();
resource_request_detector_.reset();
incident_service_.reset(); incident_service_.reset();
ServicesDelegate::ShutdownServices(); ServicesDelegate::ShutdownServices();
...@@ -114,13 +108,6 @@ void ServicesDelegateDesktop::RefreshState(bool enable) { ...@@ -114,13 +108,6 @@ void ServicesDelegateDesktop::RefreshState(bool enable) {
download_service_->SetEnabled(enable); download_service_->SetEnabled(enable);
} }
void ServicesDelegateDesktop::ProcessResourceRequest(
const ResourceRequestInfo* request) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (resource_request_detector_)
resource_request_detector_->ProcessResourceRequest(request);
}
std::unique_ptr<prefs::mojom::TrackedPreferenceValidationDelegate> std::unique_ptr<prefs::mojom::TrackedPreferenceValidationDelegate>
ServicesDelegateDesktop::CreatePreferenceValidationDelegate(Profile* profile) { ServicesDelegateDesktop::CreatePreferenceValidationDelegate(Profile* profile) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
...@@ -163,12 +150,6 @@ ServicesDelegateDesktop::CreateIncidentReportingService() { ...@@ -163,12 +150,6 @@ ServicesDelegateDesktop::CreateIncidentReportingService() {
return new IncidentReportingService(safe_browsing_service_); return new IncidentReportingService(safe_browsing_service_);
} }
ResourceRequestDetector*
ServicesDelegateDesktop::CreateResourceRequestDetector() {
return new ResourceRequestDetector(safe_browsing_service_->database_manager(),
incident_service_->GetIncidentReceiver());
}
void ServicesDelegateDesktop::StartOnIOThread( void ServicesDelegateDesktop::StartOnIOThread(
scoped_refptr<network::SharedURLLoaderFactory> sb_url_loader_factory, scoped_refptr<network::SharedURLLoaderFactory> sb_url_loader_factory,
scoped_refptr<network::SharedURLLoaderFactory> browser_url_loader_factory, scoped_refptr<network::SharedURLLoaderFactory> browser_url_loader_factory,
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "chrome/browser/safe_browsing/client_side_detection_service.h" #include "chrome/browser/safe_browsing/client_side_detection_service.h"
#include "chrome/browser/safe_browsing/download_protection/download_protection_service.h" #include "chrome/browser/safe_browsing/download_protection/download_protection_service.h"
#include "chrome/browser/safe_browsing/incident_reporting/incident_reporting_service.h" #include "chrome/browser/safe_browsing/incident_reporting/incident_reporting_service.h"
#include "chrome/browser/safe_browsing/incident_reporting/resource_request_detector.h"
#include "chrome/browser/safe_browsing/services_delegate.h" #include "chrome/browser/safe_browsing/services_delegate.h"
namespace safe_browsing { namespace safe_browsing {
...@@ -36,7 +35,6 @@ class ServicesDelegateDesktop : public ServicesDelegate { ...@@ -36,7 +35,6 @@ class ServicesDelegateDesktop : public ServicesDelegate {
SafeBrowsingDatabaseManager* database_manager) override; SafeBrowsingDatabaseManager* database_manager) override;
void ShutdownServices() override; void ShutdownServices() override;
void RefreshState(bool enable) override; void RefreshState(bool enable) override;
void ProcessResourceRequest(const ResourceRequestInfo* request) override;
std::unique_ptr<prefs::mojom::TrackedPreferenceValidationDelegate> std::unique_ptr<prefs::mojom::TrackedPreferenceValidationDelegate>
CreatePreferenceValidationDelegate(Profile* profile) override; CreatePreferenceValidationDelegate(Profile* profile) override;
void RegisterDelayedAnalysisCallback( void RegisterDelayedAnalysisCallback(
...@@ -61,11 +59,9 @@ class ServicesDelegateDesktop : public ServicesDelegate { ...@@ -61,11 +59,9 @@ class ServicesDelegateDesktop : public ServicesDelegate {
scoped_refptr<SafeBrowsingDatabaseManager> CreateDatabaseManager(); scoped_refptr<SafeBrowsingDatabaseManager> CreateDatabaseManager();
DownloadProtectionService* CreateDownloadProtectionService(); DownloadProtectionService* CreateDownloadProtectionService();
IncidentReportingService* CreateIncidentReportingService(); IncidentReportingService* CreateIncidentReportingService();
ResourceRequestDetector* CreateResourceRequestDetector();
std::unique_ptr<DownloadProtectionService> download_service_; std::unique_ptr<DownloadProtectionService> download_service_;
std::unique_ptr<IncidentReportingService> incident_service_; std::unique_ptr<IncidentReportingService> incident_service_;
std::unique_ptr<ResourceRequestDetector> resource_request_detector_;
// The database manager that handles the database checking and update logic // The database manager that handles the database checking and update logic
// Accessed on both UI and IO thread. // Accessed on both UI and IO thread.
......
...@@ -110,9 +110,6 @@ bool TestSafeBrowsingService::CanCreateDownloadProtectionService() { ...@@ -110,9 +110,6 @@ bool TestSafeBrowsingService::CanCreateDownloadProtectionService() {
bool TestSafeBrowsingService::CanCreateIncidentReportingService() { bool TestSafeBrowsingService::CanCreateIncidentReportingService() {
return true; return true;
} }
bool TestSafeBrowsingService::CanCreateResourceRequestDetector() {
return false;
}
SafeBrowsingDatabaseManager* TestSafeBrowsingService::CreateDatabaseManager() { SafeBrowsingDatabaseManager* TestSafeBrowsingService::CreateDatabaseManager() {
DCHECK(!use_v4_local_db_manager_); DCHECK(!use_v4_local_db_manager_);
...@@ -140,11 +137,6 @@ TestSafeBrowsingService::CreateIncidentReportingService() { ...@@ -140,11 +137,6 @@ TestSafeBrowsingService::CreateIncidentReportingService() {
return nullptr; return nullptr;
#endif // BUILDFLAG(FULL_SAFE_BROWSING) #endif // BUILDFLAG(FULL_SAFE_BROWSING)
} }
ResourceRequestDetector*
TestSafeBrowsingService::CreateResourceRequestDetector() {
NOTIMPLEMENTED();
return nullptr;
}
scoped_refptr<network::SharedURLLoaderFactory> scoped_refptr<network::SharedURLLoaderFactory>
TestSafeBrowsingService::GetURLLoaderFactory() { TestSafeBrowsingService::GetURLLoaderFactory() {
......
...@@ -86,13 +86,11 @@ class TestSafeBrowsingService : public SafeBrowsingService, ...@@ -86,13 +86,11 @@ class TestSafeBrowsingService : public SafeBrowsingService,
bool CanCreateDownloadProtectionService() override; bool CanCreateDownloadProtectionService() override;
#endif #endif
bool CanCreateIncidentReportingService() override; bool CanCreateIncidentReportingService() override;
bool CanCreateResourceRequestDetector() override;
SafeBrowsingDatabaseManager* CreateDatabaseManager() override; SafeBrowsingDatabaseManager* CreateDatabaseManager() override;
#if BUILDFLAG(FULL_SAFE_BROWSING) #if BUILDFLAG(FULL_SAFE_BROWSING)
DownloadProtectionService* CreateDownloadProtectionService() override; DownloadProtectionService* CreateDownloadProtectionService() override;
#endif #endif
IncidentReportingService* CreateIncidentReportingService() override; IncidentReportingService* CreateIncidentReportingService() override;
ResourceRequestDetector* CreateResourceRequestDetector() override;
scoped_refptr<network::SharedURLLoaderFactory> GetURLLoaderFactory() override; scoped_refptr<network::SharedURLLoaderFactory> GetURLLoaderFactory() override;
scoped_refptr<network::SharedURLLoaderFactory> GetURLLoaderFactory( scoped_refptr<network::SharedURLLoaderFactory> GetURLLoaderFactory(
......
...@@ -5671,7 +5671,6 @@ test("unit_tests") { ...@@ -5671,7 +5671,6 @@ test("unit_tests") {
"../browser/safe_browsing/incident_reporting/mock_incident_receiver.h", "../browser/safe_browsing/incident_reporting/mock_incident_receiver.h",
"../browser/safe_browsing/incident_reporting/platform_state_store_unittest.cc", "../browser/safe_browsing/incident_reporting/platform_state_store_unittest.cc",
"../browser/safe_browsing/incident_reporting/preference_validation_delegate_unittest.cc", "../browser/safe_browsing/incident_reporting/preference_validation_delegate_unittest.cc",
"../browser/safe_browsing/incident_reporting/resource_request_detector_unittest.cc",
"../browser/safe_browsing/incident_reporting/state_store_unittest.cc", "../browser/safe_browsing/incident_reporting/state_store_unittest.cc",
"../browser/safe_browsing/incident_reporting/tracked_preference_incident_unittest.cc", "../browser/safe_browsing/incident_reporting/tracked_preference_incident_unittest.cc",
"../browser/safe_browsing/local_two_phase_testserver.cc", "../browser/safe_browsing/local_two_phase_testserver.cc",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment