Inject off the record profile value into enterprise url lookup service
Remove a dependency on Profile by passing the profile's off the record status on initialization. This is part of the effort to move the enterprise service to components so it can be used for iOS Url filtering. Bug: 373081568 Change-Id: I6a24e5413d902c5337a731d4f7935e2b4469b90a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6383116 Reviewed-by: thefrog <thefrog@chromium.org> Commit-Queue: Ernesto Izquierdo Clua <eic@google.com> Cr-Commit-Position: refs/heads/main@{#1436256}
This commit is contained in:
parent
ad47f44c6e
commit
10fd37550e
@ -78,7 +78,8 @@ ChromeEnterpriseRealTimeUrlLookupService::
|
||||
enterprise_connectors::ConnectorsService* connectors_service,
|
||||
ReferrerChainProvider* referrer_chain_provider,
|
||||
PrefService* pref_service,
|
||||
signin::IdentityManager* identity_manager)
|
||||
signin::IdentityManager* identity_manager,
|
||||
bool is_off_the_record)
|
||||
: RealTimeUrlLookupServiceBase(
|
||||
url_loader_factory,
|
||||
cache_manager,
|
||||
@ -90,7 +91,8 @@ ChromeEnterpriseRealTimeUrlLookupService::
|
||||
connectors_service_(connectors_service),
|
||||
token_fetcher_(std::move(token_fetcher)),
|
||||
pref_service_(pref_service),
|
||||
identity_manager_(identity_manager) {}
|
||||
identity_manager_(identity_manager),
|
||||
is_off_the_record_(is_off_the_record) {}
|
||||
|
||||
ChromeEnterpriseRealTimeUrlLookupService::
|
||||
~ChromeEnterpriseRealTimeUrlLookupService() = default;
|
||||
@ -99,7 +101,7 @@ bool ChromeEnterpriseRealTimeUrlLookupService::CanPerformFullURLLookup() const {
|
||||
return RealTimePolicyEngine::CanPerformEnterpriseFullURLLookup(
|
||||
pref_service_,
|
||||
connectors_service_->GetDMTokenForRealTimeUrlCheck().has_value(),
|
||||
profile_->IsOffTheRecord(), profile_->IsGuestSession());
|
||||
is_off_the_record_, profile_->IsGuestSession());
|
||||
}
|
||||
|
||||
bool ChromeEnterpriseRealTimeUrlLookupService::
|
||||
|
@ -53,7 +53,8 @@ class ChromeEnterpriseRealTimeUrlLookupService
|
||||
enterprise_connectors::ConnectorsService* connectors_service,
|
||||
ReferrerChainProvider* referrer_chain_provider,
|
||||
PrefService* pref_service,
|
||||
signin::IdentityManager* identity_manager);
|
||||
signin::IdentityManager* identity_manager,
|
||||
bool is_off_the_record);
|
||||
|
||||
ChromeEnterpriseRealTimeUrlLookupService(
|
||||
const ChromeEnterpriseRealTimeUrlLookupService&) = delete;
|
||||
@ -122,6 +123,9 @@ class ChromeEnterpriseRealTimeUrlLookupService
|
||||
// Unowned object used for accessing the user's Google identity.
|
||||
raw_ptr<signin::IdentityManager> identity_manager_;
|
||||
|
||||
// Indicates if the service is bound to an off the record browsing session.
|
||||
bool is_off_the_record_;
|
||||
|
||||
friend class ChromeEnterpriseRealTimeUrlLookupServiceTest;
|
||||
|
||||
base::WeakPtrFactory<ChromeEnterpriseRealTimeUrlLookupService> weak_factory_{
|
||||
|
@ -81,7 +81,8 @@ std::unique_ptr<KeyedService> ChromeEnterpriseRealTimeUrlLookupServiceFactory::
|
||||
profile),
|
||||
SafeBrowsingNavigationObserverManagerFactory::GetForBrowserContext(
|
||||
profile),
|
||||
profile->GetPrefs(), IdentityManagerFactory::GetForProfile(profile));
|
||||
profile->GetPrefs(), IdentityManagerFactory::GetForProfile(profile),
|
||||
profile->IsOffTheRecord());
|
||||
}
|
||||
|
||||
} // namespace safe_browsing
|
||||
|
@ -138,8 +138,9 @@ class ChromeEnterpriseRealTimeUrlLookupServiceTest : public PlatformTest {
|
||||
identity_test_env_.MakePrimaryAccountAvailable(
|
||||
"test@example.com", signin::ConsentLevel::kSignin);
|
||||
|
||||
enterprise_rt_service_ = CreateServiceAndEnablePolicy(
|
||||
test_profile_, /*set_raw_token_fetcher=*/true);
|
||||
enterprise_rt_service_ =
|
||||
CreateServiceAndEnablePolicy(test_profile_, /*is_off_the_record=*/false,
|
||||
/*set_raw_token_fetcher=*/true);
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
@ -149,6 +150,7 @@ class ChromeEnterpriseRealTimeUrlLookupServiceTest : public PlatformTest {
|
||||
|
||||
std::unique_ptr<ChromeEnterpriseRealTimeUrlLookupService>
|
||||
CreateServiceAndEnablePolicy(Profile* profile,
|
||||
bool is_off_the_record = false,
|
||||
bool set_raw_token_fetcher = false) {
|
||||
auto token_fetcher = std::make_unique<TestSafeBrowsingTokenFetcher>();
|
||||
if (set_raw_token_fetcher) {
|
||||
@ -175,7 +177,7 @@ class ChromeEnterpriseRealTimeUrlLookupServiceTest : public PlatformTest {
|
||||
enterprise_connectors::ConnectorsServiceFactory::GetForBrowserContext(
|
||||
profile),
|
||||
referrer_chain_provider_.get(), &test_pref_service_,
|
||||
identity_test_env_.identity_manager());
|
||||
identity_test_env_.identity_manager(), is_off_the_record);
|
||||
|
||||
test_pref_service_.SetInteger(
|
||||
enterprise_connectors::kEnterpriseRealTimeUrlCheckMode,
|
||||
@ -499,10 +501,8 @@ TEST_F(ChromeEnterpriseRealTimeUrlLookupServiceTest,
|
||||
TEST_F(ChromeEnterpriseRealTimeUrlLookupServiceTest,
|
||||
CanPerformFullURLLookup_OffTheRecordDisabled) {
|
||||
SetDMTokenForTesting(policy::DMToken::CreateValidToken("dm_token"));
|
||||
Profile* off_the_record_profile =
|
||||
TestingProfile::Builder().BuildIncognito(test_profile_);
|
||||
auto off_the_record_rt_service =
|
||||
CreateServiceAndEnablePolicy(off_the_record_profile);
|
||||
CreateServiceAndEnablePolicy(test_profile_, /*is_off_the_record=*/true);
|
||||
EXPECT_FALSE(off_the_record_rt_service->CanPerformFullURLLookup());
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user