Commit 5c590c23 authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

Remove SyncService::IsSyncAllowed

This deprecated method was already implemented in terms of the new
GetDisableReasons. This CL moves the remaining callers over to use
GetDisableReasons directly, and removes IsSyncAllowed.

Bug: 839834
Change-Id: I41d1a59aff323f0752431a281a432118d437df44
Reviewed-on: https://chromium-review.googlesource.com/1138250
Commit-Queue: Marc Treib <treib@chromium.org>
Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577546}
parent de4bde2c
......@@ -273,7 +273,12 @@ bool Profile::IsNewProfile() {
bool Profile::IsSyncAllowed() {
if (ProfileSyncServiceFactory::HasProfileSyncService(this)) {
return ProfileSyncServiceFactory::GetForProfile(this)->IsSyncAllowed();
browser_sync::ProfileSyncService* sync_service =
ProfileSyncServiceFactory::GetForProfile(this);
return !sync_service->HasDisableReason(
syncer::SyncService::DISABLE_REASON_PLATFORM_OVERRIDE) &&
!sync_service->HasDisableReason(
syncer::SyncService::DISABLE_REASON_ENTERPRISE_POLICY);
}
// No ProfileSyncService created yet - we don't want to create one, so just
......
......@@ -14,12 +14,10 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profiles_state.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h"
#include "components/browser_sync/profile_sync_service.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
......@@ -93,16 +91,15 @@ bool IsEligibleForIOSPromotion(
if (signin_error_controller && signin_error_controller->HasError())
return false;
const browser_sync::ProfileSyncService* sync_service =
ProfileSyncServiceFactory::GetForProfile(profile);
// Promotion should only show for english locale.
PrefService* local_state = g_browser_process->local_state();
std::string locale = base::i18n::GetConfiguredLocale();
if (locale != "en-US" && locale != "en-CA")
return false;
if (!base::FeatureList::IsEnabled(features::kDesktopIOSPromotion) ||
!sync_service || !sync_service->IsSyncAllowed())
!profile->IsSyncAllowed()) {
return false;
}
// Check if the specific entrypoint is enabled by Finch.
std::string targeted_entry_point = base::GetFieldTrialParamValueByFeature(
......
......@@ -60,9 +60,14 @@ void TurnOffAutoSignin(PrefService* prefs) {
bool ShouldShowChromeSignInPasswordPromo(
PrefService* prefs,
const syncer::SyncService* sync_service) {
if (!sync_service || !sync_service->IsSyncAllowed() ||
sync_service->IsFirstSetupComplete())
if (!sync_service ||
sync_service->HasDisableReason(
syncer::SyncService::DISABLE_REASON_PLATFORM_OVERRIDE) ||
sync_service->HasDisableReason(
syncer::SyncService::DISABLE_REASON_ENTERPRISE_POLICY) ||
sync_service->IsFirstSetupComplete()) {
return false;
}
// Don't show the promo more than 3 times.
constexpr int kThreshold = 3;
return !prefs->GetBoolean(
......
......@@ -17,11 +17,6 @@ bool SyncService::CanSyncStart() const {
return GetDisableReasons() == DISABLE_REASON_NONE;
}
bool SyncService::IsSyncAllowed() const {
return !HasDisableReason(DISABLE_REASON_PLATFORM_OVERRIDE) &&
!HasDisableReason(DISABLE_REASON_ENTERPRISE_POLICY);
}
bool SyncService::IsEngineInitialized() const {
switch (GetState()) {
case State::DISABLED:
......
......@@ -186,11 +186,6 @@ class SyncService : public DataTypeEncryptionHandler, public KeyedService {
// GetState() == State::CONFIGURING || GetState() == State::ACTIVE".
bool IsEngineInitialized() const;
// DEPRECATED! Use GetDisableReasons/HasDisableReason instead.
// Equivalent to "!HasDisableReason(DISABLE_REASON_PLATFORM_OVERRIDE) &&
// !HasDisableReason(DISABLE_REASON_ENTERPRISE_POLICY)".
bool IsSyncAllowed() const;
// DEPRECATED! Use GetDisableReasons/HasDisableReason instead.
// Equivalent to having no disable reasons, i.e.
// "GetDisableReasons() == DISABLE_REASON_NONE".
......
......@@ -135,7 +135,10 @@ void UnifiedConsentService::OnUnifiedConsentGivenPrefChanged() {
return;
}
DCHECK(sync_service_->IsSyncAllowed());
DCHECK(!sync_service_->HasDisableReason(
syncer::SyncService::DISABLE_REASON_PLATFORM_OVERRIDE));
DCHECK(!sync_service_->HasDisableReason(
syncer::SyncService::DISABLE_REASON_ENTERPRISE_POLICY));
DCHECK(identity_manager_->HasPrimaryAccount());
DCHECK_LT(MigrationState::NOT_INITIALIZED, GetMigrationState());
......
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