#include "chrome/browser/sync/sync_ui_util.h"
#include <utility>
#include "base/feature_list.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/ui_thread_search_terms_data.h"
#include "chrome/browser/signin/chrome_signin_client_factory.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/signin/signin_util.h"
#include "chrome/browser/sync/sync_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/singleton_tabs.h"
#include "chrome/grit/branded_strings.h"
#include "chrome/grit/generated_resources.h"
#include "components/password_manager/core/browser/features/password_manager_features_util.h"
#include "components/prefs/pref_service.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "components/strings/grit/components_strings.h"
#include "components/sync/base/features.h"
#include "components/sync/service/sync_service.h"
#include "components/sync/service/sync_user_settings.h"
#include "google_apis/gaia/gaia_urls.h"
#include "google_apis/gaia/google_service_auth_error.h"
#include "net/base/url_util.h"
#include "ui/base/l10n/l10n_util.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "ash/constants/ash_features.h"
#endif
#if BUILDFLAG(IS_CHROMEOS)
#include "chrome/browser/ui/webui/trusted_vault/trusted_vault_dialog_delegate.h"
#endif
namespace {
SyncStatusLabels GetStatusForUnrecoverableError(
bool is_user_clear_primary_account_allowed) { … }
SyncStatusLabels GetSyncStatusLabelsImpl(
const syncer::SyncService* service,
bool is_user_clear_primary_account_allowed,
const GoogleServiceAuthError& auth_error) { … }
void FocusWebContents(Browser* browser) { … }
void OpenTabForSyncTrustedVaultUserAction(Browser* browser, const GURL& url) { … }
std::optional<AvatarSyncErrorType> GetTrustedVaultError(
const syncer::SyncService* sync_service) { … }
}
SyncStatusLabels GetSyncStatusLabels(
syncer::SyncService* sync_service,
signin::IdentityManager* identity_manager,
bool is_user_clear_primary_account_allowed) { … }
SyncStatusLabels GetSyncStatusLabels(Profile* profile) { … }
SyncStatusMessageType GetSyncStatusMessageType(Profile* profile) { … }
std::optional<AvatarSyncErrorType> GetAvatarSyncErrorType(Profile* profile) { … }
std::u16string GetAvatarSyncErrorDescription(AvatarSyncErrorType error,
bool is_sync_feature_enabled) { … }
bool ShouldRequestSyncConfirmation(const syncer::SyncService* service) { … }
bool ShouldShowSyncPassphraseError(const syncer::SyncService* service) { … }
void OpenTabForSyncKeyRetrieval(
Browser* browser,
syncer::TrustedVaultUserActionTriggerForUMA trigger) { … }
void OpenTabForSyncKeyRecoverabilityDegraded(
Browser* browser,
syncer::TrustedVaultUserActionTriggerForUMA trigger) { … }
#if BUILDFLAG(IS_CHROMEOS)
void OpenDialogForSyncKeyRetrieval(
Profile* profile,
syncer::TrustedVaultUserActionTriggerForUMA trigger) {
RecordKeyRetrievalTrigger(trigger);
TrustedVaultDialogDelegate::ShowDialogForProfile(
profile,
GaiaUrls::GetInstance()->signin_chrome_sync_keys_retrieval_url());
}
void OpenDialogForSyncKeyRecoverabilityDegraded(
Profile* profile,
syncer::TrustedVaultUserActionTriggerForUMA trigger) {
RecordRecoverabilityDegradedFixTrigger(trigger);
TrustedVaultDialogDelegate::ShowDialogForProfile(
profile, GaiaUrls::GetInstance()
->signin_chrome_sync_keys_recoverability_degraded_url());
}
#endif