Commit 5ec96ead authored by Anastasiia Nikolaienko's avatar Anastasiia Nikolaienko Committed by Commit Bot

Check service for null in GetMessagesForAvatarSyncError

Bug: 989849
Change-Id: Id3d68e7fadae8a87722169900fe91b865448af02
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1732091
Commit-Queue: Anastasiia Nikolaienko <anastasiian@chromium.org>
Reviewed-by: default avatarKush Sinha <sinhak@chromium.org>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#683536}
parent ac90f55c
...@@ -260,12 +260,16 @@ AvatarSyncErrorType GetMessagesForAvatarSyncError( ...@@ -260,12 +260,16 @@ AvatarSyncErrorType GetMessagesForAvatarSyncError(
const syncer::SyncService* service = const syncer::SyncService* service =
ProfileSyncServiceFactory::GetForProfile(profile); ProfileSyncServiceFactory::GetForProfile(profile);
// If there is no SyncService (probably because sync is disabled from the
// command line), then there's no error to show.
if (!service)
return NO_SYNC_ERROR;
// The order or priority is going to be: 1. Unrecoverable errors. // The order or priority is going to be: 1. Unrecoverable errors.
// 2. Auth errors. 3. Outdated client errors. 4. Passphrase errors. // 2. Auth errors. 3. Outdated client errors. 4. Passphrase errors.
// Note that an unrecoverable error is sometimes caused by the Chrome client // Note that an unrecoverable error is sometimes caused by the Chrome client
// being outdated; that case is handled separately below. // being outdated; that case is handled separately below.
if (service && service->HasUnrecoverableError() && if (service->HasUnrecoverableError() && !service->RequiresClientUpgrade()) {
!service->RequiresClientUpgrade()) {
// Display different messages and buttons for managed accounts. // Display different messages and buttons for managed accounts.
if (!signin_util::IsUserSignoutAllowedForProfile(profile)) { if (!signin_util::IsUserSignoutAllowedForProfile(profile)) {
// For a managed user, the user is directed to the signout // For a managed user, the user is directed to the signout
...@@ -294,28 +298,25 @@ AvatarSyncErrorType GetMessagesForAvatarSyncError( ...@@ -294,28 +298,25 @@ AvatarSyncErrorType GetMessagesForAvatarSyncError(
return AUTH_ERROR; return AUTH_ERROR;
} }
// Check for sync errors if the sync service is enabled. // Check if the Chrome client needs to be updated.
if (service) { if (service->RequiresClientUpgrade()) {
// Check if the Chrome client needs to be updated. *content_string_id = IDS_SYNC_ERROR_USER_MENU_UPGRADE_MESSAGE;
if (service->RequiresClientUpgrade()) { *button_string_id = IDS_SYNC_ERROR_USER_MENU_UPGRADE_BUTTON;
*content_string_id = IDS_SYNC_ERROR_USER_MENU_UPGRADE_MESSAGE; return UPGRADE_CLIENT_ERROR;
*button_string_id = IDS_SYNC_ERROR_USER_MENU_UPGRADE_BUTTON; }
return UPGRADE_CLIENT_ERROR;
}
// Check for a sync passphrase error. // Check for a sync passphrase error.
if (ShouldShowPassphraseError(service)) { if (ShouldShowPassphraseError(service)) {
*content_string_id = IDS_SYNC_ERROR_USER_MENU_PASSPHRASE_MESSAGE; *content_string_id = IDS_SYNC_ERROR_USER_MENU_PASSPHRASE_MESSAGE;
*button_string_id = IDS_SYNC_ERROR_USER_MENU_PASSPHRASE_BUTTON; *button_string_id = IDS_SYNC_ERROR_USER_MENU_PASSPHRASE_BUTTON;
return PASSPHRASE_ERROR; return PASSPHRASE_ERROR;
} }
// Check for a sync confirmation error. // Check for a sync confirmation error.
if (ShouldRequestSyncConfirmation(service)) { if (ShouldRequestSyncConfirmation(service)) {
*content_string_id = IDS_SYNC_SETTINGS_NOT_CONFIRMED; *content_string_id = IDS_SYNC_SETTINGS_NOT_CONFIRMED;
*button_string_id = IDS_SYNC_ERROR_USER_MENU_CONFIRM_SYNC_SETTINGS_BUTTON; *button_string_id = IDS_SYNC_ERROR_USER_MENU_CONFIRM_SYNC_SETTINGS_BUTTON;
return SETTINGS_UNCONFIRMED_ERROR; return SETTINGS_UNCONFIRMED_ERROR;
}
} }
// There is no error. // There is no error.
......
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