| 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;
|
| +}
|
|
|