Commit 74c7050a authored by Thomas Tangl's avatar Thomas Tangl Committed by Commit Bot

[unified-consent] Do *not* enable Google services during opt-in

- Google services in the service client are marked as
  not-supported, so they will *not* be turned on during opt-in.
- UrlKeyedAnonymizedDataCollection is still part of the opt-in
  and will get turned on.

Note: This CL is kept small for an easy merge back. In a follow
up, all dead code will be removed.

Bug: 927423
Change-Id: Ia853cef207dbbe86360de45c8a6bfd4195d1b3d2
Reviewed-on: https://chromium-review.googlesource.com/c/1449598Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Commit-Queue: Thomas Tangl <tangltom@chromium.org>
Cr-Commit-Position: refs/heads/master@{#628312}
parent dae1d252
......@@ -4,97 +4,15 @@
#include "chrome/browser/unified_consent/chrome_unified_consent_service_client.h"
#include "build/build_config.h"
#include "chrome/common/pref_names.h"
#include "components/contextual_search/buildflags.h"
#include "components/prefs/pref_service.h"
#include "components/safe_browsing/common/safe_browsing_prefs.h"
#if !defined(OS_ANDROID)
#include "components/spellcheck/browser/pref_names.h"
#endif
#if BUILDFLAG(BUILD_CONTEXTUAL_SEARCH)
#include "components/contextual_search/core/browser/contextual_search_preference.h"
#endif
ChromeUnifiedConsentServiceClient::ChromeUnifiedConsentServiceClient(
PrefService* pref_service)
: pref_service_(pref_service) {
DCHECK(pref_service_);
ObserveServicePrefChange(Service::kSafeBrowsingExtendedReporting,
prefs::kSafeBrowsingScoutReportingEnabled,
pref_service_);
#if !defined(OS_ANDROID)
ObserveServicePrefChange(Service::kSpellCheck,
spellcheck::prefs::kSpellCheckUseSpellingService,
pref_service_);
#endif
#if BUILDFLAG(BUILD_CONTEXTUAL_SEARCH)
ObserveServicePrefChange(Service::kContextualSearch,
contextual_search::GetPrefName(), pref_service_);
#endif
}
PrefService* pref_service) {}
ChromeUnifiedConsentServiceClient::~ChromeUnifiedConsentServiceClient() {}
ChromeUnifiedConsentServiceClient::ServiceState
ChromeUnifiedConsentServiceClient::GetServiceState(Service service) {
switch (service) {
case Service::kSafeBrowsingExtendedReporting:
return safe_browsing::IsExtendedReportingEnabled(*pref_service_)
? ServiceState::kEnabled
: ServiceState::kDisabled;
case Service::kSpellCheck:
#if !defined(OS_ANDROID)
return pref_service_->GetBoolean(
spellcheck::prefs::kSpellCheckUseSpellingService)
? ServiceState::kEnabled
: ServiceState::kDisabled;
#else
return ServiceState::kNotSupported;
#endif
case Service::kContextualSearch:
#if BUILDFLAG(BUILD_CONTEXTUAL_SEARCH)
return contextual_search::IsEnabled(*pref_service_)
? ServiceState::kEnabled
: ServiceState::kDisabled;
#else
return ServiceState::kNotSupported;
#endif
}
NOTREACHED();
return ServiceState::kNotSupported;
}
void ChromeUnifiedConsentServiceClient::SetServiceEnabled(Service service,
bool enabled) {
if (GetServiceState(service) == ServiceState::kNotSupported)
return;
switch (service) {
case Service::kSafeBrowsingExtendedReporting:
safe_browsing::SetExtendedReportingPref(pref_service_, enabled);
break;
case Service::kSpellCheck:
#if !defined(OS_ANDROID)
pref_service_->SetBoolean(
spellcheck::prefs::kSpellCheckUseSpellingService, enabled);
#else
NOTREACHED();
#endif
break;
case Service::kContextualSearch: {
#if BUILDFLAG(BUILD_CONTEXTUAL_SEARCH)
contextual_search::ContextualSearchPreference* contextual_search_pref =
contextual_search::ContextualSearchPreference::GetInstance();
if (enabled)
contextual_search_pref->EnableIfUndecided(pref_service_);
else
contextual_search_pref->SetPref(pref_service_, false);
#else
NOTREACHED();
#endif
break;
}
}
}
bool enabled) {}
......@@ -20,9 +20,6 @@ class ChromeUnifiedConsentServiceClient
ServiceState GetServiceState(Service service) override;
void SetServiceEnabled(Service service, bool enabled) override;
private:
PrefService* pref_service_;
DISALLOW_COPY_AND_ASSIGN(ChromeUnifiedConsentServiceClient);
};
......
......@@ -128,12 +128,12 @@ IN_PROC_BROWSER_TEST_F(UnifiedConsentBrowserTest,
metrics::SettingsHistogramValue::kUrlKeyedAnonymizedDataCollection, 1);
histogram_tester_.ExpectBucketCount(
"UnifiedConsent.SyncAndGoogleServicesSettings",
metrics::SettingsHistogramValue::kSafeBrowsingExtendedReporting, 1);
metrics::SettingsHistogramValue::kSafeBrowsingExtendedReporting, 0);
histogram_tester_.ExpectBucketCount(
"UnifiedConsent.SyncAndGoogleServicesSettings",
metrics::SettingsHistogramValue::kSpellCheck, 1);
metrics::SettingsHistogramValue::kSpellCheck, 0);
histogram_tester_.ExpectTotalCount(
"UnifiedConsent.SyncAndGoogleServicesSettings", 4);
"UnifiedConsent.SyncAndGoogleServicesSettings", 2);
}
} // namespace
......
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