Commit d70ca123 authored by David Roger's avatar David Roger Committed by Commit Bot

[signin] Remove dependency of IOSWebViewSigninClient on SigninErrorController

SigninClient implementations should not depend on SigninErrorController.
The dependency should be the other way around.
This CL fixes the WebView implementation of SigninClient.

NOTRY=true

Change-Id: I0592028bd988036bc01a2a48d375337f077bfbd7
Bug: 836212
Reviewed-on: https://chromium-review.googlesource.com/c/1348035
Commit-Queue: David Roger <droger@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611090}
parent c6b97a0f
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "ios/web_view/internal/signin/web_view_account_tracker_service_factory.h" #include "ios/web_view/internal/signin/web_view_account_tracker_service_factory.h"
#include "ios/web_view/internal/signin/web_view_oauth2_token_service_factory.h" #include "ios/web_view/internal/signin/web_view_oauth2_token_service_factory.h"
#include "ios/web_view/internal/signin/web_view_signin_client_factory.h" #include "ios/web_view/internal/signin/web_view_signin_client_factory.h"
#include "ios/web_view/internal/signin/web_view_signin_error_controller_factory.h"
#include "ios/web_view/internal/signin/web_view_signin_manager_factory.h" #include "ios/web_view/internal/signin/web_view_signin_manager_factory.h"
#import "ios/web_view/internal/sync/cwv_sync_controller_internal.h" #import "ios/web_view/internal/sync/cwv_sync_controller_internal.h"
#import "ios/web_view/internal/sync/web_view_profile_sync_service_factory.h" #import "ios/web_view/internal/sync/web_view_profile_sync_service_factory.h"
...@@ -166,12 +167,16 @@ CWVWebViewConfiguration* gIncognitoConfiguration = nil; ...@@ -166,12 +167,16 @@ CWVWebViewConfiguration* gIncognitoConfiguration = nil;
ProfileOAuth2TokenService* tokenService = ProfileOAuth2TokenService* tokenService =
ios_web_view::WebViewOAuth2TokenServiceFactory::GetForBrowserState( ios_web_view::WebViewOAuth2TokenServiceFactory::GetForBrowserState(
self.browserState); self.browserState);
SigninErrorController* signinErrorController =
ios_web_view::WebViewSigninErrorControllerFactory::GetForBrowserState(
self.browserState);
_syncController = [[CWVSyncController alloc] _syncController = [[CWVSyncController alloc]
initWithProfileSyncService:profileSyncService initWithProfileSyncService:profileSyncService
accountTrackerService:accountTrackerService accountTrackerService:accountTrackerService
signinManager:signinManager signinManager:signinManager
tokenService:tokenService]; tokenService:tokenService
signinErrorController:signinErrorController];
// Set the newly created CWVSyncController on IOSWebViewSigninClient to // Set the newly created CWVSyncController on IOSWebViewSigninClient to
// so access tokens can be fetched. // so access tokens can be fetched.
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "components/content_settings/core/browser/cookie_settings.h" #include "components/content_settings/core/browser/cookie_settings.h"
#include "components/content_settings/core/browser/host_content_settings_map.h" #include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/signin/core/browser/signin_client.h" #include "components/signin/core/browser/signin_client.h"
#include "components/signin/core/browser/signin_error_controller.h"
#include "components/signin/ios/browser/wait_for_network_callback_helper.h" #include "components/signin/ios/browser/wait_for_network_callback_helper.h"
#include "net/cookies/cookie_change_dispatcher.h" #include "net/cookies/cookie_change_dispatcher.h"
#include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/network/public/cpp/shared_url_loader_factory.h"
...@@ -19,14 +18,12 @@ ...@@ -19,14 +18,12 @@
@class CWVSyncController; @class CWVSyncController;
// iOS WebView specific signin client. // iOS WebView specific signin client.
class IOSWebViewSigninClient : public SigninClient, class IOSWebViewSigninClient : public SigninClient {
public SigninErrorController::Observer {
public: public:
IOSWebViewSigninClient( IOSWebViewSigninClient(
PrefService* pref_service, PrefService* pref_service,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
network::mojom::CookieManager* cookie_manager, network::mojom::CookieManager* cookie_manager,
SigninErrorController* signin_error_controller,
scoped_refptr<content_settings::CookieSettings> cookie_settings, scoped_refptr<content_settings::CookieSettings> cookie_settings,
scoped_refptr<HostContentSettingsMap> host_content_settings_map); scoped_refptr<HostContentSettingsMap> host_content_settings_map);
...@@ -59,9 +56,6 @@ class IOSWebViewSigninClient : public SigninClient, ...@@ -59,9 +56,6 @@ class IOSWebViewSigninClient : public SigninClient,
override; override;
void OnSignedOut() override; void OnSignedOut() override;
// SigninErrorController::Observer implementation.
void OnErrorChanged() override;
// CWVSyncController setter/getter. // CWVSyncController setter/getter.
void SetSyncController(CWVSyncController* sync_controller); void SetSyncController(CWVSyncController* sync_controller);
CWVSyncController* GetSyncController() const; CWVSyncController* GetSyncController() const;
...@@ -73,8 +67,6 @@ class IOSWebViewSigninClient : public SigninClient, ...@@ -73,8 +67,6 @@ class IOSWebViewSigninClient : public SigninClient,
PrefService* pref_service_; PrefService* pref_service_;
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory_; scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory_;
network::mojom::CookieManager* cookie_manager_; network::mojom::CookieManager* cookie_manager_;
// Used to check for errors related to signing in.
SigninErrorController* signin_error_controller_;
// Used to check if sign in cookies are allowed. // Used to check if sign in cookies are allowed.
scoped_refptr<content_settings::CookieSettings> cookie_settings_; scoped_refptr<content_settings::CookieSettings> cookie_settings_;
// Used to add and remove content settings observers. // Used to add and remove content settings observers.
......
...@@ -18,7 +18,6 @@ IOSWebViewSigninClient::IOSWebViewSigninClient( ...@@ -18,7 +18,6 @@ IOSWebViewSigninClient::IOSWebViewSigninClient(
PrefService* pref_service, PrefService* pref_service,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
network::mojom::CookieManager* cookie_manager, network::mojom::CookieManager* cookie_manager,
SigninErrorController* signin_error_controller,
scoped_refptr<content_settings::CookieSettings> cookie_settings, scoped_refptr<content_settings::CookieSettings> cookie_settings,
scoped_refptr<HostContentSettingsMap> host_content_settings_map) scoped_refptr<HostContentSettingsMap> host_content_settings_map)
: network_callback_helper_( : network_callback_helper_(
...@@ -26,14 +25,11 @@ IOSWebViewSigninClient::IOSWebViewSigninClient( ...@@ -26,14 +25,11 @@ IOSWebViewSigninClient::IOSWebViewSigninClient(
pref_service_(pref_service), pref_service_(pref_service),
url_loader_factory_(url_loader_factory), url_loader_factory_(url_loader_factory),
cookie_manager_(cookie_manager), cookie_manager_(cookie_manager),
signin_error_controller_(signin_error_controller),
cookie_settings_(cookie_settings), cookie_settings_(cookie_settings),
host_content_settings_map_(host_content_settings_map) { host_content_settings_map_(host_content_settings_map) {
signin_error_controller_->AddObserver(this);
} }
IOSWebViewSigninClient::~IOSWebViewSigninClient() { IOSWebViewSigninClient::~IOSWebViewSigninClient() {
signin_error_controller_->RemoveObserver(this);
} }
void IOSWebViewSigninClient::Shutdown() { void IOSWebViewSigninClient::Shutdown() {
...@@ -104,10 +100,6 @@ std::unique_ptr<GaiaAuthFetcher> IOSWebViewSigninClient::CreateGaiaAuthFetcher( ...@@ -104,10 +100,6 @@ std::unique_ptr<GaiaAuthFetcher> IOSWebViewSigninClient::CreateGaiaAuthFetcher(
url_loader_factory); url_loader_factory);
} }
void IOSWebViewSigninClient::OnErrorChanged() {
[sync_controller_ didUpdateAuthError:signin_error_controller_->auth_error()];
}
void IOSWebViewSigninClient::SetSyncController( void IOSWebViewSigninClient::SetSyncController(
CWVSyncController* sync_controller) { CWVSyncController* sync_controller) {
sync_controller_ = sync_controller; sync_controller_ = sync_controller;
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "ios/web_view/internal/content_settings/web_view_cookie_settings_factory.h" #include "ios/web_view/internal/content_settings/web_view_cookie_settings_factory.h"
#include "ios/web_view/internal/content_settings/web_view_host_content_settings_map_factory.h" #include "ios/web_view/internal/content_settings/web_view_host_content_settings_map_factory.h"
#include "ios/web_view/internal/signin/ios_web_view_signin_client.h" #include "ios/web_view/internal/signin/ios_web_view_signin_client.h"
#include "ios/web_view/internal/signin/web_view_signin_error_controller_factory.h"
#include "ios/web_view/internal/web_view_browser_state.h" #include "ios/web_view/internal/web_view_browser_state.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
...@@ -36,7 +35,6 @@ WebViewSigninClientFactory::WebViewSigninClientFactory() ...@@ -36,7 +35,6 @@ WebViewSigninClientFactory::WebViewSigninClientFactory()
: BrowserStateKeyedServiceFactory( : BrowserStateKeyedServiceFactory(
"SigninClient", "SigninClient",
BrowserStateDependencyManager::GetInstance()) { BrowserStateDependencyManager::GetInstance()) {
DependsOn(WebViewSigninErrorControllerFactory::GetInstance());
DependsOn(WebViewCookieSettingsFactory::GetInstance()); DependsOn(WebViewCookieSettingsFactory::GetInstance());
DependsOn(WebViewHostContentSettingsMapFactory::GetInstance()); DependsOn(WebViewHostContentSettingsMapFactory::GetInstance());
} }
...@@ -49,7 +47,6 @@ WebViewSigninClientFactory::BuildServiceInstanceFor( ...@@ -49,7 +47,6 @@ WebViewSigninClientFactory::BuildServiceInstanceFor(
return std::make_unique<IOSWebViewSigninClient>( return std::make_unique<IOSWebViewSigninClient>(
browser_state->GetPrefs(), browser_state->GetSharedURLLoaderFactory(), browser_state->GetPrefs(), browser_state->GetSharedURLLoaderFactory(),
browser_state->GetCookieManager(), browser_state->GetCookieManager(),
WebViewSigninErrorControllerFactory::GetForBrowserState(browser_state),
WebViewCookieSettingsFactory::GetForBrowserState(browser_state), WebViewCookieSettingsFactory::GetForBrowserState(browser_state),
WebViewHostContentSettingsMapFactory::GetForBrowserState(browser_state)); WebViewHostContentSettingsMapFactory::GetForBrowserState(browser_state));
} }
......
...@@ -61,10 +61,13 @@ CWVSyncError CWVConvertGoogleServiceAuthErrorStateToCWVSyncError( ...@@ -61,10 +61,13 @@ CWVSyncError CWVConvertGoogleServiceAuthErrorStateToCWVSyncError(
@interface CWVSyncController () @interface CWVSyncController ()
// Called by WebViewSyncServiceObserverBridge's |OnSyncConfigurationCompleted|. // Called by WebViewSyncControllerObserverBridge's
// |OnSyncConfigurationCompleted|.
- (void)didCompleteSyncConfiguration; - (void)didCompleteSyncConfiguration;
// Called by WebViewSyncServiceObserverBridge's |OnSyncShutdown|. // Called by WebViewSyncControllerObserverBridge's |OnSyncShutdown|.
- (void)didShutdownSync; - (void)didShutdownSync;
// Called by WebViewSyncControllerObserverBridge's |OnErrorChanged|.
- (void)didUpdateAuthError;
// Call to refresh access tokens for |currentIdentity|. // Call to refresh access tokens for |currentIdentity|.
- (void)reloadCredentials; - (void)reloadCredentials;
...@@ -75,18 +78,15 @@ namespace ios_web_view { ...@@ -75,18 +78,15 @@ namespace ios_web_view {
// Bridge that observes browser_sync::ProfileSyncService and calls analagous // Bridge that observes browser_sync::ProfileSyncService and calls analagous
// methods on CWVSyncController. // methods on CWVSyncController.
class WebViewSyncServiceObserverBridge : public syncer::SyncServiceObserver { class WebViewSyncControllerObserverBridge
: public syncer::SyncServiceObserver,
public SigninErrorController::Observer {
public: public:
explicit WebViewSyncServiceObserverBridge(CWVSyncController* sync_controller) explicit WebViewSyncControllerObserverBridge(
CWVSyncController* sync_controller)
: sync_controller_(sync_controller) {} : sync_controller_(sync_controller) {}
void OnStateChanged(syncer::SyncService* sync) override {
// No op.
}
void OnSyncCycleCompleted(syncer::SyncService* sync) override {
// No op.
}
// syncer::SyncServiceObserver:
void OnSyncConfigurationCompleted(syncer::SyncService* sync) override { void OnSyncConfigurationCompleted(syncer::SyncService* sync) override {
[sync_controller_ didCompleteSyncConfiguration]; [sync_controller_ didCompleteSyncConfiguration];
} }
...@@ -95,6 +95,9 @@ class WebViewSyncServiceObserverBridge : public syncer::SyncServiceObserver { ...@@ -95,6 +95,9 @@ class WebViewSyncServiceObserverBridge : public syncer::SyncServiceObserver {
[sync_controller_ didShutdownSync]; [sync_controller_ didShutdownSync];
} }
// SigninErrorController::Observer:
void OnErrorChanged() override { [sync_controller_ didUpdateAuthError]; }
private: private:
__weak CWVSyncController* sync_controller_; __weak CWVSyncController* sync_controller_;
}; };
...@@ -105,9 +108,9 @@ class WebViewSyncServiceObserverBridge : public syncer::SyncServiceObserver { ...@@ -105,9 +108,9 @@ class WebViewSyncServiceObserverBridge : public syncer::SyncServiceObserver {
browser_sync::ProfileSyncService* _profileSyncService; browser_sync::ProfileSyncService* _profileSyncService;
AccountTrackerService* _accountTrackerService; AccountTrackerService* _accountTrackerService;
SigninManager* _signinManager; SigninManager* _signinManager;
IOSWebViewSigninClient* _signinClient;
ProfileOAuth2TokenService* _tokenService; ProfileOAuth2TokenService* _tokenService;
std::unique_ptr<ios_web_view::WebViewSyncServiceObserverBridge> _observer; SigninErrorController* _signinErrorController;
std::unique_ptr<ios_web_view::WebViewSyncControllerObserverBridge> _observer;
// Data source that can provide access tokens. // Data source that can provide access tokens.
__weak id<CWVSyncControllerDataSource> _dataSource; __weak id<CWVSyncControllerDataSource> _dataSource;
...@@ -116,19 +119,24 @@ class WebViewSyncServiceObserverBridge : public syncer::SyncServiceObserver { ...@@ -116,19 +119,24 @@ class WebViewSyncServiceObserverBridge : public syncer::SyncServiceObserver {
@synthesize delegate = _delegate; @synthesize delegate = _delegate;
- (instancetype) - (instancetype)
initWithProfileSyncService:(browser_sync::ProfileSyncService*)profileSyncService initWithProfileSyncService:
(browser_sync::ProfileSyncService*)profileSyncService
accountTrackerService:(AccountTrackerService*)accountTrackerService accountTrackerService:(AccountTrackerService*)accountTrackerService
signinManager:(SigninManager*)signinManager signinManager:(SigninManager*)signinManager
tokenService:(ProfileOAuth2TokenService*)tokenService { tokenService:(ProfileOAuth2TokenService*)tokenService
signinErrorController:(SigninErrorController*)signinErrorController {
self = [super init]; self = [super init];
if (self) { if (self) {
_profileSyncService = profileSyncService; _profileSyncService = profileSyncService;
_accountTrackerService = accountTrackerService; _accountTrackerService = accountTrackerService;
_signinManager = signinManager; _signinManager = signinManager;
_tokenService = tokenService; _tokenService = tokenService;
_signinErrorController = signinErrorController;
_observer = _observer =
std::make_unique<ios_web_view::WebViewSyncServiceObserverBridge>(self); std::make_unique<ios_web_view::WebViewSyncControllerObserverBridge>(
self);
_profileSyncService->AddObserver(_observer.get()); _profileSyncService->AddObserver(_observer.get());
_signinErrorController->AddObserver(_observer.get());
// Refresh access tokens on foreground to extend expiration dates. // Refresh access tokens on foreground to extend expiration dates.
[[NSNotificationCenter defaultCenter] [[NSNotificationCenter defaultCenter]
...@@ -142,6 +150,7 @@ initWithProfileSyncService:(browser_sync::ProfileSyncService*)profileSyncService ...@@ -142,6 +150,7 @@ initWithProfileSyncService:(browser_sync::ProfileSyncService*)profileSyncService
- (void)dealloc { - (void)dealloc {
_profileSyncService->RemoveObserver(_observer.get()); _profileSyncService->RemoveObserver(_observer.get());
_signinErrorController->RemoveObserver(_observer.get());
} }
#pragma mark - Public Methods #pragma mark - Public Methods
...@@ -204,6 +213,7 @@ initWithProfileSyncService:(browser_sync::ProfileSyncService*)profileSyncService ...@@ -204,6 +213,7 @@ initWithProfileSyncService:(browser_sync::ProfileSyncService*)profileSyncService
- (void)didShutdownSync { - (void)didShutdownSync {
_profileSyncService->RemoveObserver(_observer.get()); _profileSyncService->RemoveObserver(_observer.get());
_signinErrorController->RemoveObserver(_observer.get());
} }
- (void)reloadCredentials { - (void)reloadCredentials {
...@@ -254,7 +264,8 @@ initWithProfileSyncService:(browser_sync::ProfileSyncService*)profileSyncService ...@@ -254,7 +264,8 @@ initWithProfileSyncService:(browser_sync::ProfileSyncService*)profileSyncService
[_delegate syncController:self didStopSyncWithReason:reason]; [_delegate syncController:self didStopSyncWithReason:reason];
} }
- (void)didUpdateAuthError:(const GoogleServiceAuthError&)authError { - (void)didUpdateAuthError {
GoogleServiceAuthError authError = _signinErrorController->auth_error();
CWVSyncError code = CWVSyncError code =
CWVConvertGoogleServiceAuthErrorStateToCWVSyncError(authError.state()); CWVConvertGoogleServiceAuthErrorStateToCWVSyncError(authError.state());
if (code != CWVSyncErrorNone) { if (code != CWVSyncErrorNone) {
......
...@@ -21,15 +21,18 @@ class ProfileSyncService; ...@@ -21,15 +21,18 @@ class ProfileSyncService;
class AccountTrackerService; class AccountTrackerService;
class SigninManager; class SigninManager;
class ProfileOAuth2TokenService; class ProfileOAuth2TokenService;
class SigninErrorController;
@interface CWVSyncController () @interface CWVSyncController ()
// All dependencies must out live this class. // All dependencies must out live this class.
- (instancetype) - (instancetype)
initWithProfileSyncService:(browser_sync::ProfileSyncService*)profileSyncService initWithProfileSyncService:
(browser_sync::ProfileSyncService*)profileSyncService
accountTrackerService:(AccountTrackerService*)accountTrackerService accountTrackerService:(AccountTrackerService*)accountTrackerService
signinManager:(SigninManager*)signinManager signinManager:(SigninManager*)signinManager
tokenService:(ProfileOAuth2TokenService*)tokenService tokenService:(ProfileOAuth2TokenService*)tokenService
signinErrorController:(SigninErrorController*)SigninErrorController
NS_DESIGNATED_INITIALIZER; NS_DESIGNATED_INITIALIZER;
// Called by WebViewProfileOAuth2TokenServiceIOSProviderImpl to obtain // Called by WebViewProfileOAuth2TokenServiceIOSProviderImpl to obtain
...@@ -41,9 +44,6 @@ initWithProfileSyncService:(browser_sync::ProfileSyncService*)profileSyncService ...@@ -41,9 +44,6 @@ initWithProfileSyncService:(browser_sync::ProfileSyncService*)profileSyncService
// Called by IOSWebViewSigninClient when signing out. // Called by IOSWebViewSigninClient when signing out.
- (void)didSignoutWithSourceMetric:(signin_metrics::ProfileSignout)metric; - (void)didSignoutWithSourceMetric:(signin_metrics::ProfileSignout)metric;
// Called by IOSWebViewSigninClient when auth error changes.
- (void)didUpdateAuthError:(const GoogleServiceAuthError&)authError;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
......
...@@ -50,17 +50,17 @@ class CWVSyncControllerTest : public PlatformTest { ...@@ -50,17 +50,17 @@ class CWVSyncControllerTest : public PlatformTest {
CWVSyncControllerTest() CWVSyncControllerTest()
: browser_state_(/*off_the_record=*/false), : browser_state_(/*off_the_record=*/false),
signin_client_(browser_state_.GetPrefs()), signin_client_(browser_state_.GetPrefs()),
sigin_error_controller_( signin_error_controller_(
SigninErrorController::AccountMode::ANY_ACCOUNT), SigninErrorController::AccountMode::ANY_ACCOUNT),
token_service_( token_service_delegate_(new ProfileOAuth2TokenServiceIOSDelegate(
browser_state_.GetPrefs(),
std::make_unique<ProfileOAuth2TokenServiceIOSDelegate>(
&signin_client_, &signin_client_,
std::make_unique<FakeProfileOAuth2TokenServiceIOSProvider>(), std::make_unique<FakeProfileOAuth2TokenServiceIOSProvider>(),
&account_tracker_service_, &account_tracker_service_,
&sigin_error_controller_)), &signin_error_controller_)),
gaia_cookie_manager_service_(&token_service_, token_service_(browser_state_.GetPrefs(),
&signin_client_), std::unique_ptr<ProfileOAuth2TokenServiceIOSDelegate>(
token_service_delegate_)),
gaia_cookie_manager_service_(&token_service_, &signin_client_),
signin_manager_(&signin_client_, signin_manager_(&signin_client_,
&token_service_, &token_service_,
&account_tracker_service_, &account_tracker_service_,
...@@ -87,7 +87,8 @@ class CWVSyncControllerTest : public PlatformTest { ...@@ -87,7 +87,8 @@ class CWVSyncControllerTest : public PlatformTest {
initWithProfileSyncService:profile_sync_service_.get() initWithProfileSyncService:profile_sync_service_.get()
accountTrackerService:&account_tracker_service_ accountTrackerService:&account_tracker_service_
signinManager:&signin_manager_ signinManager:&signin_manager_
tokenService:&token_service_]; tokenService:&token_service_
signinErrorController:&signin_error_controller_];
}; };
~CWVSyncControllerTest() override { ~CWVSyncControllerTest() override {
...@@ -109,7 +110,11 @@ class CWVSyncControllerTest : public PlatformTest { ...@@ -109,7 +110,11 @@ class CWVSyncControllerTest : public PlatformTest {
std::unique_ptr<browser_sync::ProfileSyncServiceMock> profile_sync_service_; std::unique_ptr<browser_sync::ProfileSyncServiceMock> profile_sync_service_;
AccountTrackerService account_tracker_service_; AccountTrackerService account_tracker_service_;
TestSigninClient signin_client_; TestSigninClient signin_client_;
SigninErrorController sigin_error_controller_; SigninErrorController signin_error_controller_;
// Weak, owned by the token service.
ProfileOAuth2TokenServiceIOSDelegate* token_service_delegate_;
FakeProfileOAuth2TokenService token_service_; FakeProfileOAuth2TokenService token_service_;
FakeGaiaCookieManagerService gaia_cookie_manager_service_; FakeGaiaCookieManagerService gaia_cookie_manager_service_;
FakeSigninManager signin_manager_; FakeSigninManager signin_manager_;
...@@ -164,22 +169,25 @@ TEST_F(CWVSyncControllerTest, DelegateCallbacks) { ...@@ -164,22 +169,25 @@ TEST_F(CWVSyncControllerTest, DelegateCallbacks) {
&CWVSyncControllerTest_DelegateCallbacks_Test::OnConfigureDone)); &CWVSyncControllerTest_DelegateCallbacks_Test::OnConfigureDone));
syncer::DataTypeManager::ConfigureResult result; syncer::DataTypeManager::ConfigureResult result;
profile_sync_service_->OnConfigureDone(result); profile_sync_service_->OnConfigureDone(result);
[[delegate expect] [[delegate expect]
syncController:sync_controller_ syncController:sync_controller_
didFailWithError:[OCMArg checkWithBlock:^BOOL(NSError* error) { didFailWithError:[OCMArg checkWithBlock:^BOOL(NSError* error) {
return error.code == CWVSyncErrorInvalidGAIACredentials; return error.code == CWVSyncErrorInvalidGAIACredentials;
}]]; }]];
// Create authentication error.
GoogleServiceAuthError auth_error( GoogleServiceAuthError auth_error(
GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS); GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS);
[sync_controller_ didUpdateAuthError:auth_error]; std::string account_id = account_tracker_service_.SeedAccountInfo(
"gaia_id", "email@example.com");
token_service_delegate_->AddOrUpdateAccount(account_id);
token_service_delegate_->UpdateAuthError(account_id, auth_error);
[[delegate expect] syncController:sync_controller_ [[delegate expect] syncController:sync_controller_
didStopSyncWithReason:CWVStopSyncReasonServer]; didStopSyncWithReason:CWVStopSyncReasonServer];
[sync_controller_ [sync_controller_
didSignoutWithSourceMetric:signin_metrics::ProfileSignout:: didSignoutWithSourceMetric:signin_metrics::ProfileSignout::
SERVER_FORCED_DISABLE]; SERVER_FORCED_DISABLE];
[delegate verify]; [delegate verify];
} }
} }
......
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