Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Unified Diff: chrome/browser/sync/sync_ui_util.cc

Issue 2179283002: Refactored signin/sync error controllers for the avatar button (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Uninitialized ptr Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/sync/sync_ui_util.h ('k') | chrome/browser/ui/avatar_button_error_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/sync_ui_util.cc
diff --git a/chrome/browser/sync/sync_ui_util.cc b/chrome/browser/sync/sync_ui_util.cc
index 10f359bd74d19cfad92a2d317524a2b9b290d432..8f85f706e00ad3d31360a61670887cf9abd5e240 100644
--- a/chrome/browser/sync/sync_ui_util.cc
+++ b/chrome/browser/sync/sync_ui_util.cc
@@ -43,6 +43,9 @@
#if defined(OS_CHROMEOS)
#include "components/signin/core/account_id/account_id.h"
#include "components/user_manager/user_manager.h"
+#else
+#include "chrome/browser/signin/signin_manager_factory.h"
+#include "components/sync_driver/sync_error_controller.h"
#endif // defined(OS_CHROMEOS)
typedef GoogleServiceAuthError AuthError;
@@ -398,6 +401,71 @@ void GetStatusLabelsForSyncGlobalError(const ProfileSyncService* service,
return;
}
}
+
+AvatarSyncErrorType GetMessagesForAvatarSyncError(Profile* profile,
+ int* content_string_id,
+ int* button_string_id) {
+ ProfileSyncService* service =
+ ProfileSyncServiceFactory::GetForProfile(profile);
+
+ // The order or priority is going to be: 1. Unrecoverable errors.
+ // 2. Auth errors. 3. Protocol errors. 4. Passphrase errors.
+ if (service && service->HasUnrecoverableError()) {
+ // An unrecoverable error is sometimes accompanied by an actionable error.
+ // If an actionable error is not set to be UPGRADE_CLIENT, then show a
+ // generic unrecoverable error message.
+ ProfileSyncService::Status status;
+ service->QueryDetailedSyncStatus(&status);
+ if (status.sync_protocol_error.action != syncer::UPGRADE_CLIENT) {
+ // Display different messages and buttons for managed accounts.
+ if (SigninManagerFactory::GetForProfile(profile)->IsSignoutProhibited()) {
+ // For a managed user, the user is directed to the signout
+ // confirmation dialogue in the settings page.
+ *content_string_id = IDS_SYNC_ERROR_USER_MENU_SIGNOUT_MESSAGE;
+ *button_string_id = IDS_SYNC_ERROR_USER_MENU_SIGNOUT_BUTTON;
+ return MANAGED_USER_UNRECOVERABLE_ERROR;
+ }
+ // For a non-managed user, we sign out on the user's behalf and prompt
+ // the user to sign in again.
+ *content_string_id = IDS_SYNC_ERROR_USER_MENU_SIGNIN_AGAIN_MESSAGE;
+ *button_string_id = IDS_SYNC_ERROR_USER_MENU_SIGNIN_AGAIN_BUTTON;
+ return UNRECOVERABLE_ERROR;
+ }
+ }
+
+ // Check for an auth error.
+ SigninErrorController* signin_error_controller =
+ SigninErrorControllerFactory::GetForProfile(profile);
+ if (signin_error_controller && signin_error_controller->HasError()) {
+ *content_string_id = IDS_SYNC_ERROR_USER_MENU_SIGNIN_MESSAGE;
+ *button_string_id = IDS_SYNC_ERROR_USER_MENU_SIGNIN_BUTTON;
+ return AUTH_ERROR;
+ }
+
+ // Check for sync errors if the sync service is enabled.
+ if (service) {
+ // Check for an actionable UPGRADE_CLIENT error.
+ ProfileSyncService::Status status;
+ service->QueryDetailedSyncStatus(&status);
+ if (status.sync_protocol_error.action == syncer::UPGRADE_CLIENT) {
+ *content_string_id = IDS_SYNC_ERROR_USER_MENU_UPGRADE_MESSAGE;
+ *button_string_id = IDS_SYNC_ERROR_USER_MENU_UPGRADE_BUTTON;
+ return UPGRADE_CLIENT_ERROR;
+ }
+
+ // Check for a sync passphrase error.
+ SyncErrorController* sync_error_controller =
+ service->sync_error_controller();
+ if (sync_error_controller && sync_error_controller->HasError()) {
+ *content_string_id = IDS_SYNC_ERROR_USER_MENU_PASSPHRASE_MESSAGE;
+ *button_string_id = IDS_SYNC_ERROR_USER_MENU_PASSPHRASE_BUTTON;
+ return PASSPHRASE_ERROR;
+ }
+ }
+
+ // There is no error.
+ return NO_SYNC_ERROR;
+}
#endif
MessageType GetStatus(Profile* profile,
« no previous file with comments | « chrome/browser/sync/sync_ui_util.h ('k') | chrome/browser/ui/avatar_button_error_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698