Commit 1cfa8e38 authored by Jérôme Lebel's avatar Jérôme Lebel Committed by Commit Bot

[iOS] Reload Google services settings when sync state changes

Needs to reload the sync error item when the sync state changes.

Bug introduced with cleanup in: crrev.com/c/1390004

Bug: 918474
Change-Id: I868ec7358de6741c75970c4003dacf54fa11bdfd
Reviewed-on: https://chromium-review.googlesource.com/c/1392948
Commit-Queue: Jérôme Lebel <jlebel@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#619395}
parent a824bc44
......@@ -61,6 +61,8 @@
self.mediator.consumer = viewController;
self.mediator.authService = self.authService;
self.mediator.commandHandler = self;
self.mediator.syncService =
ProfileSyncServiceFactory::GetForBrowserState(self.browserState);
viewController.modelDelegate = self.mediator;
viewController.serviceDelegate = self.mediator;
DCHECK(self.navigationController);
......
......@@ -18,6 +18,9 @@ class AuthenticationService;
class PrefService;
class SyncSetupService;
namespace browser_sync {
class ProfileSyncService;
} // namespace browser_sync
namespace unified_consent {
class UnifiedConsentService;
} // namespace unified_consent
......@@ -34,17 +37,20 @@ class UnifiedConsentService;
// Command handler.
@property(nonatomic, weak) id<GoogleServicesSettingsCommandHandler>
commandHandler;
// Sync service.
@property(nonatomic, assign) browser_sync::ProfileSyncService* syncService;
// Designated initializer. All the paramters should not be null.
// |userPrefService|: preference service from the browser state.
// |localPrefService|: preference service from the application context.
- (instancetype)
initWithUserPrefService:(PrefService*)userPrefService
localPrefService:(PrefService*)localPrefService
syncSetupService:(SyncSetupService*)syncSetupService
unifiedConsentService:
(unified_consent::UnifiedConsentService*)unifiedConsentService
NS_DESIGNATED_INITIALIZER;
// |syncSetupService|: allows configuring sync.
// |unifiedConsentService|: manage the user consent.
- (instancetype)initWithUserPrefService:(PrefService*)userPrefService
localPrefService:(PrefService*)localPrefService
syncSetupService:(SyncSetupService*)syncSetupService
unifiedConsentService:
(unified_consent::UnifiedConsentService*)
unifiedConsentService NS_DESIGNATED_INITIALIZER;
- (instancetype)init NS_UNAVAILABLE;
......
......@@ -7,12 +7,14 @@
#include "base/auto_reset.h"
#include "base/mac/foundation_util.h"
#include "components/autofill/core/common/autofill_prefs.h"
#include "components/browser_sync/profile_sync_service.h"
#include "components/metrics/metrics_pref_names.h"
#include "components/prefs/pref_service.h"
#include "components/unified_consent/pref_names.h"
#include "ios/chrome/browser/pref_names.h"
#import "ios/chrome/browser/signin/authentication_service.h"
#import "ios/chrome/browser/signin/authentication_service_factory.h"
#include "ios/chrome/browser/sync/sync_observer_bridge.h"
#import "ios/chrome/browser/ui/settings/cells/settings_image_detail_text_item.h"
#import "ios/chrome/browser/ui/settings/cells/sync_switch_item.h"
#import "ios/chrome/browser/ui/settings/google_services_settings_command_handler.h"
......@@ -54,7 +56,11 @@ typedef NS_ENUM(NSInteger, ItemType) {
} // namespace
@interface GoogleServicesSettingsMediator () <BooleanObserver>
@interface GoogleServicesSettingsMediator () <BooleanObserver,
SyncObserverModelBridge> {
// Sync observer.
std::unique_ptr<SyncObserverBridge> _syncObserver;
}
// Unified consent service.
@property(nonatomic, assign)
......@@ -107,12 +113,12 @@ typedef NS_ENUM(NSInteger, ItemType) {
#pragma mark - Load model
- (instancetype)
initWithUserPrefService:(PrefService*)userPrefService
localPrefService:(PrefService*)localPrefService
syncSetupService:(SyncSetupService*)syncSetupService
unifiedConsentService:
(unified_consent::UnifiedConsentService*)unifiedConsentService {
- (instancetype)initWithUserPrefService:(PrefService*)userPrefService
localPrefService:(PrefService*)localPrefService
syncSetupService:(SyncSetupService*)syncSetupService
unifiedConsentService:
(unified_consent::UnifiedConsentService*)
unifiedConsentService {
self = [super init];
if (self) {
DCHECK(userPrefService);
......@@ -346,6 +352,8 @@ initWithUserPrefService:(PrefService*)userPrefService
DCHECK_EQ(self.consumer, controller);
[self loadNonPersonalizedSection];
[self updateSyncErrorSectionAndNotifyConsumer:NO];
DCHECK(self.syncService);
_syncObserver.reset(new SyncObserverBridge(self, self.syncService));
}
#pragma mark - GoogleServicesSettingsServiceDelegate
......@@ -401,6 +409,12 @@ initWithUserPrefService:(PrefService*)userPrefService
}
}
#pragma mark - SyncObserverModelBridge
- (void)onSyncStateChanged {
[self updateSyncErrorSectionAndNotifyConsumer:YES];
}
#pragma mark - BooleanObserver
- (void)booleanDidChange:(id<ObservableBoolean>)observableBoolean {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment