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

Side by Side 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, 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/sync/avatar_sync_error_controller.h"
6
7 #include "chrome/browser/sync/profile_sync_service_factory.h"
8 #include "components/browser_sync/browser/profile_sync_service.h"
9 #include "components/signin/core/common/profile_management_switches.h"
10
11 AvatarSyncErrorController::AvatarSyncErrorController(Profile* profile)
12 : profile_(profile), has_error_(false) {
13 SyncErrorController* sync_error_controller =
14 GetSyncErrorControllerIfNeeded(profile_);
15 if (sync_error_controller)
16 sync_error_controller->AddObserver(this);
17 }
18
19 AvatarSyncErrorController::~AvatarSyncErrorController() {
20 SyncErrorController* sync_error_controller =
21 GetSyncErrorControllerIfNeeded(profile_);
22 if (sync_error_controller)
23 sync_error_controller->RemoveObserver(this);
24 }
25
26 void AvatarSyncErrorController::OnErrorChanged() {
27 ProfileSyncService* sync_service =
28 ProfileSyncServiceFactory::GetForProfile(profile_);
29 if (switches::IsMaterialDesignUserMenu() && sync_service) {
30 SyncErrorController* sync_error_controller =
31 sync_service->sync_error_controller();
32 ProfileSyncService::Status status;
33 sync_service->QueryDetailedSyncStatus(&status);
34 has_error_ = (sync_service->HasUnrecoverableError() ||
35 status.sync_protocol_error.action == syncer::UPGRADE_CLIENT ||
36 (sync_error_controller && sync_error_controller->HasError()));
37 }
38 }
39
40 SyncErrorController* AvatarSyncErrorController::GetSyncErrorControllerIfNeeded(
41 Profile* profile) {
42 if (!switches::IsMaterialDesignUserMenu())
43 return nullptr;
44 ProfileSyncService* sync_service =
45 ProfileSyncServiceFactory::GetForProfile(profile);
46 return sync_service ? sync_service->sync_error_controller() : nullptr;
47 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698