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

Side by Side Diff: chrome/browser/sync/avatar_sync_error.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: Prototype 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.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 AvatarSyncError::AvatarSyncError(Profile* profile)
12 : profile_(profile), has_sync_error_(false) {
13 SyncErrorController* sync_error_controller =
14 GetSyncErrorControllerIfNeeded(profile_);
15 if (sync_error_controller)
16 sync_error_controller->AddObserver(this);
17 }
18
19 AvatarSyncError::~AvatarSyncError() {
20 SyncErrorController* sync_error_controller =
21 GetSyncErrorControllerIfNeeded(profile_);
22 if (sync_error_controller)
23 sync_error_controller->RemoveObserver(this);
24 }
25
26 void AvatarSyncError::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_sync_error_ =
35 (sync_service->HasUnrecoverableError() ||
36 status.sync_protocol_error.action == syncer::UPGRADE_CLIENT ||
37 (sync_error_controller && sync_error_controller->HasError()));
38 }
39 }
40
41 SyncErrorController* AvatarSyncError::GetSyncErrorControllerIfNeeded(
42 Profile* profile) {
43 if (!switches::IsMaterialDesignUserMenu())
44 return nullptr;
45 ProfileSyncService* sync_service =
46 ProfileSyncServiceFactory::GetForProfile(profile);
47 return sync_service ? sync_service->sync_error_controller() : nullptr;
48 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698