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

Unified Diff: chrome/browser/sync/avatar_sync_error_controller.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: Refactored logic for classifying errors Created 4 years, 5 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
Index: chrome/browser/sync/avatar_sync_error_controller.cc
diff --git a/chrome/browser/sync/avatar_sync_error_controller.cc b/chrome/browser/sync/avatar_sync_error_controller.cc
new file mode 100644
index 0000000000000000000000000000000000000000..166b6c45d151f352d8634377f3b8ce90e9c77f69
--- /dev/null
+++ b/chrome/browser/sync/avatar_sync_error_controller.cc
@@ -0,0 +1,47 @@
+// Copyright (c) 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/sync/avatar_sync_error_controller.h"
+
+#include "chrome/browser/sync/profile_sync_service_factory.h"
+#include "components/browser_sync/browser/profile_sync_service.h"
+#include "components/signin/core/common/profile_management_switches.h"
+
+AvatarSyncErrorController::AvatarSyncErrorController(Profile* profile)
+ : profile_(profile), has_error_(false) {
+ SyncErrorController* sync_error_controller =
+ GetSyncErrorControllerIfNeeded(profile_);
+ if (sync_error_controller)
+ sync_error_controller->AddObserver(this);
+}
+
+AvatarSyncErrorController::~AvatarSyncErrorController() {
+ SyncErrorController* sync_error_controller =
+ GetSyncErrorControllerIfNeeded(profile_);
+ if (sync_error_controller)
+ sync_error_controller->RemoveObserver(this);
+}
+
+void AvatarSyncErrorController::OnErrorChanged() {
+ ProfileSyncService* sync_service =
+ ProfileSyncServiceFactory::GetForProfile(profile_);
+ if (switches::IsMaterialDesignUserMenu() && sync_service) {
+ SyncErrorController* sync_error_controller =
+ sync_service->sync_error_controller();
+ ProfileSyncService::Status status;
+ sync_service->QueryDetailedSyncStatus(&status);
+ has_error_ = (sync_service->HasUnrecoverableError() ||
+ status.sync_protocol_error.action == syncer::UPGRADE_CLIENT ||
+ (sync_error_controller && sync_error_controller->HasError()));
+ }
+}
+
+SyncErrorController* AvatarSyncErrorController::GetSyncErrorControllerIfNeeded(
+ Profile* profile) {
+ if (!switches::IsMaterialDesignUserMenu())
+ return nullptr;
+ ProfileSyncService* sync_service =
+ ProfileSyncServiceFactory::GetForProfile(profile);
+ return sync_service ? sync_service->sync_error_controller() : nullptr;
+}

Powered by Google App Engine
This is Rietveld 408576698