Commit 8fe3998a authored by Xinghui Lu's avatar Xinghui Lu Committed by Commit Bot

Remove content/ dependency in policy_engine.

To make policy_engine build on iOS, replace browser_context with
pref_service and is_off_the_record.


Bug: 1050859,1028755
Change-Id: I343b1b9f83dc1e69cdb5304d0b64f062120e844c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2071159
Commit-Queue: Xinghui Lu <xinghuilu@chromium.org>
Reviewed-by: default avatarVarun Khaneja <vakh@chromium.org>
Reviewed-by: default avatarAli Juma <ajuma@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746122}
parent bdd7d1be
...@@ -4231,7 +4231,7 @@ ChromeContentBrowserClient::CreateURLLoaderThrottles( ...@@ -4231,7 +4231,7 @@ ChromeContentBrowserClient::CreateURLLoaderThrottles(
// |safe_browsing_service_| may be unavailable in tests. // |safe_browsing_service_| may be unavailable in tests.
safe_browsing_service_ && safe_browsing_service_ &&
safe_browsing::RealTimePolicyEngine::CanPerformFullURLLookup( safe_browsing::RealTimePolicyEngine::CanPerformFullURLLookup(
profile) profile->GetPrefs(), profile->IsOffTheRecord())
? safe_browsing::RealTimeUrlLookupServiceFactory::GetForProfile( ? safe_browsing::RealTimeUrlLookupServiceFactory::GetForProfile(
profile) profile)
: nullptr; : nullptr;
......
...@@ -55,7 +55,8 @@ KeyedService* RealTimeUrlLookupServiceFactory::BuildServiceInstanceFor( ...@@ -55,7 +55,8 @@ KeyedService* RealTimeUrlLookupServiceFactory::BuildServiceInstanceFor(
DCHECK(cache_manager); DCHECK(cache_manager);
return new RealTimeUrlLookupService( return new RealTimeUrlLookupService(
network::SharedURLLoaderFactory::Create(std::move(url_loader_factory)), network::SharedURLLoaderFactory::Create(std::move(url_loader_factory)),
cache_manager, IdentityManagerFactory::GetForProfile(profile)); cache_manager, IdentityManagerFactory::GetForProfile(profile),
profile->GetPrefs(), profile->IsOffTheRecord());
} }
} // namespace safe_browsing } // namespace safe_browsing
...@@ -159,11 +159,9 @@ BrowserURLLoaderThrottle::BrowserURLLoaderThrottle( ...@@ -159,11 +159,9 @@ BrowserURLLoaderThrottle::BrowserURLLoaderThrottle(
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
// Decide whether to do real time URL lookups or not. // Decide whether to do real time URL lookups or not.
content::WebContents* web_contents = web_contents_getter.Run();
bool real_time_lookup_enabled = bool real_time_lookup_enabled =
web_contents ? RealTimePolicyEngine::CanPerformFullURLLookup( url_lookup_service ? url_lookup_service->CanPerformFullURLLookup()
web_contents->GetBrowserContext()) : false;
: false;
io_checker_ = std::make_unique<CheckerOnIO>( io_checker_ = std::make_unique<CheckerOnIO>(
std::move(delegate_getter), frame_tree_node_id, web_contents_getter, std::move(delegate_getter), frame_tree_node_id, web_contents_getter,
......
...@@ -19,6 +19,7 @@ jumbo_source_set("browser") { ...@@ -19,6 +19,7 @@ jumbo_source_set("browser") {
"//components/safe_browsing/core/common:thread_utils", "//components/safe_browsing/core/common:thread_utils",
"//components/safe_browsing/core/db:database_manager", "//components/safe_browsing/core/db:database_manager",
"//components/safe_browsing/core/db:util", "//components/safe_browsing/core/db:util",
"//components/safe_browsing/core/realtime:policy_engine",
"//components/safe_browsing/core/realtime:url_lookup_service", "//components/safe_browsing/core/realtime:url_lookup_service",
"//components/safe_browsing/core/web_ui:constants", "//components/safe_browsing/core/web_ui:constants",
"//components/security_interstitials/core:unsafe_resource", "//components/security_interstitials/core:unsafe_resource",
...@@ -29,10 +30,7 @@ jumbo_source_set("browser") { ...@@ -29,10 +30,7 @@ jumbo_source_set("browser") {
sources += [ "//components/safe_browsing/ios/browser/safe_browsing_url_checker_impl_ios.cc" ] sources += [ "//components/safe_browsing/ios/browser/safe_browsing_url_checker_impl_ios.cc" ]
} else { } else {
sources += [ "//components/safe_browsing/content/browser/safe_browsing_url_checker_impl_content.cc" ] sources += [ "//components/safe_browsing/content/browser/safe_browsing_url_checker_impl_content.cc" ]
deps += [ deps += [ "//components/safe_browsing/content/web_ui" ]
"//components/safe_browsing/content/web_ui",
"//components/safe_browsing/core/realtime:policy_engine",
]
} }
} }
......
...@@ -9,7 +9,9 @@ static_library("url_lookup_service") { ...@@ -9,7 +9,9 @@ static_library("url_lookup_service") {
] ]
deps = [ deps = [
":policy_engine",
"//base:base", "//base:base",
"//components/prefs",
"//components/safe_browsing/core:realtimeapi_proto", "//components/safe_browsing/core:realtimeapi_proto",
"//components/safe_browsing/core:verdict_cache_manager", "//components/safe_browsing/core:verdict_cache_manager",
"//components/safe_browsing/core/common:thread_utils", "//components/safe_browsing/core/common:thread_utils",
...@@ -20,52 +22,46 @@ static_library("url_lookup_service") { ...@@ -20,52 +22,46 @@ static_library("url_lookup_service") {
] ]
} }
# TODO(crbug.com/1028755): Remove this condition once there are no longer any static_library("policy_engine") {
# dependencies on content/. sources = [
if (!is_ios) { "policy_engine.cc",
static_library("policy_engine") { "policy_engine.h",
sources = [ ]
"policy_engine.cc",
"policy_engine.h",
]
deps = [ deps = [
"//base:base", "//base:base",
"//components/prefs", "//components/prefs",
"//components/safe_browsing/core:features", "//components/safe_browsing/core:features",
"//components/safe_browsing/core:realtimeapi_proto", "//components/safe_browsing/core:realtimeapi_proto",
"//components/safe_browsing/core/common", "//components/safe_browsing/core/common",
"//components/safe_browsing/core/common:safe_browsing_prefs", "//components/safe_browsing/core/common:safe_browsing_prefs",
"//components/unified_consent", "//components/unified_consent",
"//components/user_prefs", "//components/user_prefs",
"//content/public/browser", ]
] }
}
source_set("unit_tests") { source_set("unit_tests") {
testonly = true testonly = true
sources = [ sources = [
"policy_engine_unittest.cc", "policy_engine_unittest.cc",
"url_lookup_service_unittest.cc", "url_lookup_service_unittest.cc",
] ]
deps = [ deps = [
":policy_engine", ":policy_engine",
":url_lookup_service", ":url_lookup_service",
"//base/test:test_support", "//base/test:test_support",
"//components/content_settings/core/browser", "//components/content_settings/core/browser",
"//components/safe_browsing/core:features", "//components/safe_browsing/core:features",
"//components/safe_browsing/core:verdict_cache_manager", "//components/safe_browsing/core:verdict_cache_manager",
"//components/safe_browsing/core/common", "//components/safe_browsing/core/common",
"//components/safe_browsing/core/common:safe_browsing_prefs", "//components/safe_browsing/core/common:safe_browsing_prefs",
"//components/safe_browsing/core/common:test_support", "//components/safe_browsing/core/common:test_support",
"//components/signin/public/identity_manager:test_support", "//components/signin/public/identity_manager:test_support",
"//components/sync_preferences:test_support", "//components/sync_preferences:test_support",
"//components/unified_consent", "//components/unified_consent",
"//components/user_prefs", "//components/user_prefs",
"//content/test:test_support", "//services/network:test_support",
"//services/network:test_support", "//services/network/public/cpp:cpp",
"//services/network/public/cpp:cpp", "//testing/gtest",
"//testing/gtest", ]
]
}
} }
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "components/safe_browsing/core/features.h" #include "components/safe_browsing/core/features.h"
#include "components/unified_consent/pref_names.h" #include "components/unified_consent/pref_names.h"
#include "components/user_prefs/user_prefs.h" #include "components/user_prefs/user_prefs.h"
#include "content/public/browser/browser_context.h"
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
#include "base/metrics/field_trial_params.h" #include "base/metrics/field_trial_params.h"
...@@ -44,35 +43,34 @@ bool RealTimePolicyEngine::IsUrlLookupEnabled() { ...@@ -44,35 +43,34 @@ bool RealTimePolicyEngine::IsUrlLookupEnabled() {
} }
// static // static
bool RealTimePolicyEngine::IsUserOptedIn( bool RealTimePolicyEngine::IsUserOptedIn(PrefService* pref_service) {
content::BrowserContext* browser_context) {
PrefService* pref_service = user_prefs::UserPrefs::Get(browser_context);
return pref_service->GetBoolean( return pref_service->GetBoolean(
unified_consent::prefs::kUrlKeyedAnonymizedDataCollectionEnabled); unified_consent::prefs::kUrlKeyedAnonymizedDataCollectionEnabled);
} }
// static // static
bool RealTimePolicyEngine::IsEnabledByPolicy( // TODO(crbug.com/1050859): Remove this method.
content::BrowserContext* browser_context) { bool RealTimePolicyEngine::IsEnabledByPolicy() {
return false; return false;
} }
// static // static
bool RealTimePolicyEngine::CanPerformFullURLLookup( bool RealTimePolicyEngine::CanPerformFullURLLookup(PrefService* pref_service,
content::BrowserContext* browser_context) { bool is_off_the_record) {
if (browser_context->IsOffTheRecord()) if (is_off_the_record)
return false; return false;
if (IsEnabledByPolicy(browser_context)) if (IsEnabledByPolicy())
return true; return true;
return IsUrlLookupEnabled() && IsUserOptedIn(browser_context); return IsUrlLookupEnabled() && IsUserOptedIn(pref_service);
} }
// static // static
bool RealTimePolicyEngine::CanPerformFullURLLookupWithToken( bool RealTimePolicyEngine::CanPerformFullURLLookupWithToken(
content::BrowserContext* browser_context) { PrefService* pref_service,
if (!CanPerformFullURLLookup(browser_context)) { bool is_off_the_record) {
if (!CanPerformFullURLLookup(pref_service, is_off_the_record)) {
return false; return false;
} }
......
...@@ -7,9 +7,7 @@ ...@@ -7,9 +7,7 @@
#include "build/build_config.h" #include "build/build_config.h"
namespace content { class PrefService;
class BrowserContext;
}
namespace safe_browsing { namespace safe_browsing {
...@@ -39,13 +37,14 @@ class RealTimePolicyEngine { ...@@ -39,13 +37,14 @@ class RealTimePolicyEngine {
// Return true if the feature to enable full URL lookups is enabled and the // Return true if the feature to enable full URL lookups is enabled and the
// allowlist fetch is enabled for the profile represented by // allowlist fetch is enabled for the profile represented by
// |browser_context|. // |pref_service|.
static bool CanPerformFullURLLookup(content::BrowserContext* browser_context); static bool CanPerformFullURLLookup(PrefService* pref_service,
bool is_off_the_record);
// Return true if the OAuth token should be associated with the URL lookup // Return true if the OAuth token should be associated with the URL lookup
// pings. // pings.
static bool CanPerformFullURLLookupWithToken( static bool CanPerformFullURLLookupWithToken(PrefService* pref_service,
content::BrowserContext* browser_context); bool is_off_the_record);
friend class SafeBrowsingService; friend class SafeBrowsingService;
friend class SafeBrowsingUIHandler; friend class SafeBrowsingUIHandler;
...@@ -55,10 +54,10 @@ class RealTimePolicyEngine { ...@@ -55,10 +54,10 @@ class RealTimePolicyEngine {
static bool IsUrlLookupEnabled(); static bool IsUrlLookupEnabled();
// Is user opted-in to the feature? // Is user opted-in to the feature?
static bool IsUserOptedIn(content::BrowserContext* browser_context); static bool IsUserOptedIn(PrefService* pref_service);
// Is the feature enabled due to enterprise policy? // Is the feature enabled due to enterprise policy?
static bool IsEnabledByPolicy(content::BrowserContext* browser_context); static bool IsEnabledByPolicy();
friend class RealTimePolicyEngineTest; friend class RealTimePolicyEngineTest;
}; // class RealTimePolicyEngine }; // class RealTimePolicyEngine
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include "components/unified_consent/pref_names.h" #include "components/unified_consent/pref_names.h"
#include "components/unified_consent/unified_consent_service.h" #include "components/unified_consent/unified_consent_service.h"
#include "components/user_prefs/user_prefs.h" #include "components/user_prefs/user_prefs.h"
#include "content/public/test/test_browser_context.h"
#include "testing/platform_test.h" #include "testing/platform_test.h"
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
...@@ -29,22 +28,21 @@ class RealTimePolicyEngineTest : public PlatformTest { ...@@ -29,22 +28,21 @@ class RealTimePolicyEngineTest : public PlatformTest {
RealTimePolicyEngineTest() : task_environment_(CreateTestTaskEnvironment()) {} RealTimePolicyEngineTest() : task_environment_(CreateTestTaskEnvironment()) {}
void SetUp() override { void SetUp() override {
user_prefs::UserPrefs::Set(&test_context_, &pref_service_);
RegisterProfilePrefs(pref_service_.registry()); RegisterProfilePrefs(pref_service_.registry());
unified_consent::UnifiedConsentService::RegisterPrefs( unified_consent::UnifiedConsentService::RegisterPrefs(
pref_service_.registry()); pref_service_.registry());
} }
bool IsUserOptedIn() { bool IsUserOptedIn() {
return RealTimePolicyEngine::IsUserOptedIn(&test_context_); return RealTimePolicyEngine::IsUserOptedIn(&pref_service_);
} }
bool CanPerformFullURLLookup() { bool CanPerformFullURLLookup(bool is_off_the_record) {
return RealTimePolicyEngine::CanPerformFullURLLookup(&test_context_); return RealTimePolicyEngine::CanPerformFullURLLookup(&pref_service_,
is_off_the_record);
} }
std::unique_ptr<base::test::TaskEnvironment> task_environment_; std::unique_ptr<base::test::TaskEnvironment> task_environment_;
content::TestBrowserContext test_context_;
sync_preferences::TestingPrefServiceSyncable pref_service_; sync_preferences::TestingPrefServiceSyncable pref_service_;
}; };
...@@ -64,7 +62,7 @@ TEST_F(RealTimePolicyEngineTest, TestCanPerformFullURLLookup_LargeMemorySize) { ...@@ -64,7 +62,7 @@ TEST_F(RealTimePolicyEngineTest, TestCanPerformFullURLLookup_LargeMemorySize) {
pref_service_.SetUserPref( pref_service_.SetUserPref(
unified_consent::prefs::kUrlKeyedAnonymizedDataCollectionEnabled, unified_consent::prefs::kUrlKeyedAnonymizedDataCollectionEnabled,
std::make_unique<base::Value>(true)); std::make_unique<base::Value>(true));
EXPECT_TRUE(CanPerformFullURLLookup()); EXPECT_TRUE(CanPerformFullURLLookup(/* is_off_the_record */ false));
} }
TEST_F(RealTimePolicyEngineTest, TestCanPerformFullURLLookup_SmallMemorySize) { TEST_F(RealTimePolicyEngineTest, TestCanPerformFullURLLookup_SmallMemorySize) {
...@@ -80,7 +78,7 @@ TEST_F(RealTimePolicyEngineTest, TestCanPerformFullURLLookup_SmallMemorySize) { ...@@ -80,7 +78,7 @@ TEST_F(RealTimePolicyEngineTest, TestCanPerformFullURLLookup_SmallMemorySize) {
pref_service_.SetUserPref( pref_service_.SetUserPref(
unified_consent::prefs::kUrlKeyedAnonymizedDataCollectionEnabled, unified_consent::prefs::kUrlKeyedAnonymizedDataCollectionEnabled,
std::make_unique<base::Value>(true)); std::make_unique<base::Value>(true));
EXPECT_FALSE(CanPerformFullURLLookup()); EXPECT_FALSE(CanPerformFullURLLookup(/* is_off_the_record */ false));
} }
TEST_F(RealTimePolicyEngineTest, TEST_F(RealTimePolicyEngineTest,
...@@ -89,7 +87,7 @@ TEST_F(RealTimePolicyEngineTest, ...@@ -89,7 +87,7 @@ TEST_F(RealTimePolicyEngineTest,
feature_list.InitWithFeaturesAndParameters( feature_list.InitWithFeaturesAndParameters(
/* enabled_features */ {}, /* enabled_features */ {},
/* disabled_features */ {kRealTimeUrlLookupEnabled}); /* disabled_features */ {kRealTimeUrlLookupEnabled});
EXPECT_FALSE(CanPerformFullURLLookup()); EXPECT_FALSE(CanPerformFullURLLookup(/* is_off_the_record */ false));
} }
#endif // defined(OS_ANDROID) #endif // defined(OS_ANDROID)
...@@ -99,14 +97,14 @@ TEST_F(RealTimePolicyEngineTest, TestCanPerformFullURLLookup_EnabledByPolicy) { ...@@ -99,14 +97,14 @@ TEST_F(RealTimePolicyEngineTest, TestCanPerformFullURLLookup_EnabledByPolicy) {
std::make_unique<base::Value>(true)); std::make_unique<base::Value>(true));
// Verifies that setting the pref still doesn't enable the feature. // Verifies that setting the pref still doesn't enable the feature.
// See crbug.com/1030815 for details. // See crbug.com/1030815 for details.
EXPECT_FALSE(CanPerformFullURLLookup()); EXPECT_FALSE(CanPerformFullURLLookup(/* is_off_the_record */ false));
} }
TEST_F(RealTimePolicyEngineTest, TEST_F(RealTimePolicyEngineTest,
TestCanPerformFullURLLookup_DisabledUrlLookup) { TestCanPerformFullURLLookup_DisabledUrlLookup) {
base::test::ScopedFeatureList feature_list; base::test::ScopedFeatureList feature_list;
feature_list.InitAndDisableFeature(kRealTimeUrlLookupEnabled); feature_list.InitAndDisableFeature(kRealTimeUrlLookupEnabled);
EXPECT_FALSE(CanPerformFullURLLookup()); EXPECT_FALSE(CanPerformFullURLLookup(/* is_off_the_record */ false));
} }
TEST_F(RealTimePolicyEngineTest, TEST_F(RealTimePolicyEngineTest,
...@@ -114,8 +112,7 @@ TEST_F(RealTimePolicyEngineTest, ...@@ -114,8 +112,7 @@ TEST_F(RealTimePolicyEngineTest,
base::test::ScopedFeatureList feature_list; base::test::ScopedFeatureList feature_list;
pref_service_.SetManagedPref(prefs::kSafeBrowsingRealTimeLookupEnabled, pref_service_.SetManagedPref(prefs::kSafeBrowsingRealTimeLookupEnabled,
std::make_unique<base::Value>(true)); std::make_unique<base::Value>(true));
test_context_.set_is_off_the_record(true); EXPECT_FALSE(CanPerformFullURLLookup(/* is_off_the_record */ true));
EXPECT_FALSE(CanPerformFullURLLookup());
} }
TEST_F(RealTimePolicyEngineTest, TEST_F(RealTimePolicyEngineTest,
......
...@@ -10,8 +10,10 @@ ...@@ -10,8 +10,10 @@
#include "base/strings/string_piece.h" #include "base/strings/string_piece.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "components/prefs/pref_service.h"
#include "components/safe_browsing/core/common/thread_utils.h" #include "components/safe_browsing/core/common/thread_utils.h"
#include "components/safe_browsing/core/db/v4_protocol_manager_util.h" #include "components/safe_browsing/core/db/v4_protocol_manager_util.h"
#include "components/safe_browsing/core/realtime/policy_engine.h"
#include "components/safe_browsing/core/verdict_cache_manager.h" #include "components/safe_browsing/core/verdict_cache_manager.h"
#include "components/signin/public/identity_manager/identity_manager.h" #include "components/signin/public/identity_manager/identity_manager.h"
#include "net/base/ip_address.h" #include "net/base/ip_address.h"
...@@ -52,12 +54,17 @@ GURL SanitizeURL(const GURL& url) { ...@@ -52,12 +54,17 @@ GURL SanitizeURL(const GURL& url) {
RealTimeUrlLookupService::RealTimeUrlLookupService( RealTimeUrlLookupService::RealTimeUrlLookupService(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
VerdictCacheManager* cache_manager, VerdictCacheManager* cache_manager,
signin::IdentityManager* identity_manager) signin::IdentityManager* identity_manager,
PrefService* pref_service,
bool is_off_the_record)
: url_loader_factory_(url_loader_factory), : url_loader_factory_(url_loader_factory),
cache_manager_(cache_manager), cache_manager_(cache_manager),
identity_manager_(identity_manager) { identity_manager_(identity_manager),
pref_service_(pref_service),
is_off_the_record_(is_off_the_record) {
DCHECK(cache_manager_); DCHECK(cache_manager_);
DCHECK(identity_manager_); DCHECK(identity_manager_);
DCHECK(pref_service_);
} }
void RealTimeUrlLookupService::StartLookup( void RealTimeUrlLookupService::StartLookup(
...@@ -324,6 +331,11 @@ void RealTimeUrlLookupService::ResetFailures() { ...@@ -324,6 +331,11 @@ void RealTimeUrlLookupService::ResetFailures() {
backoff_timer_.Stop(); backoff_timer_.Stop();
} }
bool RealTimeUrlLookupService::CanPerformFullURLLookup() const {
return RealTimePolicyEngine::CanPerformFullURLLookup(pref_service_,
is_off_the_record_);
}
// static // static
SBThreatType RealTimeUrlLookupService::GetSBThreatTypeForRTThreatType( SBThreatType RealTimeUrlLookupService::GetSBThreatTypeForRTThreatType(
RTLookupResponse::ThreatInfo::ThreatType rt_threat_type) { RTLookupResponse::ThreatInfo::ThreatType rt_threat_type) {
......
...@@ -27,6 +27,8 @@ namespace signin { ...@@ -27,6 +27,8 @@ namespace signin {
class IdentityManager; class IdentityManager;
} }
class PrefService;
namespace safe_browsing { namespace safe_browsing {
using RTLookupRequestCallback = using RTLookupRequestCallback =
...@@ -45,12 +47,19 @@ class RealTimeUrlLookupService : public KeyedService { ...@@ -45,12 +47,19 @@ class RealTimeUrlLookupService : public KeyedService {
RealTimeUrlLookupService( RealTimeUrlLookupService(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
VerdictCacheManager* cache_manager, VerdictCacheManager* cache_manager,
signin::IdentityManager* identity_manager); signin::IdentityManager* identity_manager,
PrefService* pref_service,
bool is_off_the_record);
~RealTimeUrlLookupService() override; ~RealTimeUrlLookupService() override;
// Returns true if |url|'s scheme can be checked. // Returns true if |url|'s scheme can be checked.
bool CanCheckUrl(const GURL& url) const; bool CanCheckUrl(const GURL& url) const;
// Returns true if real time URL lookup is enabled. The check is based on
// pref settings of the associated profile, whether the profile is an off the
// record profile and the finch flag.
bool CanPerformFullURLLookup() const;
// Returns true if the real time lookups are currently in backoff mode due to // Returns true if the real time lookups are currently in backoff mode due to
// too many prior errors. If this happens, the checking falls back to // too many prior errors. If this happens, the checking falls back to
// local hash-based method. // local hash-based method.
...@@ -150,6 +159,13 @@ class RealTimeUrlLookupService : public KeyedService { ...@@ -150,6 +159,13 @@ class RealTimeUrlLookupService : public KeyedService {
// token is enabled. // token is enabled.
signin::IdentityManager* identity_manager_; signin::IdentityManager* identity_manager_;
// Unowned object used for getting preference settings.
PrefService* pref_service_;
// A boolean indicates whether the profile associated with this
// |url_lookup_service| is an off the record profile.
bool is_off_the_record_;
friend class RealTimeUrlLookupServiceTest; friend class RealTimeUrlLookupServiceTest;
base::WeakPtrFactory<RealTimeUrlLookupService> weak_factory_{this}; base::WeakPtrFactory<RealTimeUrlLookupService> weak_factory_{this};
......
...@@ -39,7 +39,8 @@ class RealTimeUrlLookupServiceTest : public PlatformTest { ...@@ -39,7 +39,8 @@ class RealTimeUrlLookupServiceTest : public PlatformTest {
signin::IdentityTestEnvironment identity_test_env; signin::IdentityTestEnvironment identity_test_env;
rt_service_ = std::make_unique<RealTimeUrlLookupService>( rt_service_ = std::make_unique<RealTimeUrlLookupService>(
test_shared_loader_factory_, cache_manager_.get(), test_shared_loader_factory_, cache_manager_.get(),
identity_test_env.identity_manager()); identity_test_env.identity_manager(), &test_pref_service_,
/* is_off_the_record */ false);
} }
void TearDown() override { void TearDown() override {
......
...@@ -13,5 +13,6 @@ source_set("unit_tests") { ...@@ -13,5 +13,6 @@ source_set("unit_tests") {
"//components/safe_browsing/core/common", "//components/safe_browsing/core/common",
"//components/safe_browsing/core/common:unit_tests", "//components/safe_browsing/core/common:unit_tests",
"//components/safe_browsing/core/db:unit_tests_local_db", "//components/safe_browsing/core/db:unit_tests_local_db",
"//components/safe_browsing/core/realtime:unit_tests",
] ]
} }
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