Commit 76334159 authored by Lindsay Pasricha's avatar Lindsay Pasricha Committed by Commit Bot

Revert "Reland "[iOS] Remove unused ChromeIdentityInteractionManager APIs.""

This reverts commit 3293e946.

Reason for revert: AddAccountSigninManagerTests are failing again

Original change's description:
> Reland "[iOS] Remove unused ChromeIdentityInteractionManager APIs."
> 
> This reverts commit 11f8ce83.
> 
> Reason for revert: Landed the fix to SigninCoordinator EarlGrey tests
> in patch 2264057.
> 
> Original change's description:
> > Revert "[iOS] Remove unused ChromeIdentityInteractionManager APIs."
> >
> > This reverts commit 053f6124.
> >
> > Reason for revert:
> > AddAccountSigninManagerTest fail on iOS 12:
> > https://ci.chromium.org/p/chrome/builders/ci/iphone-device/9356
> 
> Bug: 1078815
> Change-Id: Iba786bb1caa7dbbb1b8aa3c4d2feeb5e24674922
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2270085
> Commit-Queue: Nohemi Fernandez <fernandex@chromium.org>
> Reviewed-by: Jérôme Lebel <jlebel@chromium.org>
> Reviewed-by: Nohemi Fernandez <fernandex@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#783001}

TBR=jlebel@chromium.org,fernandex@chromium.org

Change-Id: Ic3884c804f6ce91240a3d15e4c8134ae255fc498
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1078815
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2270617Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Commit-Queue: Lindsay Pasricha <lindsayw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#783019}
parent 6d2e67da
...@@ -130,6 +130,7 @@ enum AuthenticationState { ...@@ -130,6 +130,7 @@ enum AuthenticationState {
} // namespace } // namespace
@interface ChromeSigninViewController () < @interface ChromeSigninViewController () <
ChromeIdentityInteractionManagerDelegate,
ChromeIdentityServiceObserver, ChromeIdentityServiceObserver,
MDCActivityIndicatorDelegate, MDCActivityIndicatorDelegate,
UIAdaptivePresentationControllerDelegate, UIAdaptivePresentationControllerDelegate,
...@@ -568,7 +569,7 @@ enum AuthenticationState { ...@@ -568,7 +569,7 @@ enum AuthenticationState {
_interactionManager = _interactionManager =
ios::GetChromeBrowserProvider() ios::GetChromeBrowserProvider()
->GetChromeIdentityService() ->GetChromeIdentityService()
->CreateChromeIdentityInteractionManager(self.browserState); ->CreateChromeIdentityInteractionManager(self.browserState, self);
__weak ChromeSigninViewController* weakSelf = self; __weak ChromeSigninViewController* weakSelf = self;
SigninCompletionCallback completion = SigninCompletionCallback completion =
^(ChromeIdentity* identity, NSError* error) { ^(ChromeIdentity* identity, NSError* error) {
......
...@@ -23,7 +23,9 @@ ...@@ -23,7 +23,9 @@
using signin_metrics::AccessPoint; using signin_metrics::AccessPoint;
using signin_metrics::PromoAction; using signin_metrics::PromoAction;
@interface AddAccountSigninCoordinator () <AddAccountSigninManagerDelegate> @interface AddAccountSigninCoordinator () <
AddAccountSigninManagerDelegate,
ChromeIdentityInteractionManagerDelegate>
// Coordinator to display modal alerts to the user. // Coordinator to display modal alerts to the user.
@property(nonatomic, strong) AlertCoordinator* alertCoordinator; @property(nonatomic, strong) AlertCoordinator* alertCoordinator;
...@@ -110,7 +112,7 @@ using signin_metrics::PromoAction; ...@@ -110,7 +112,7 @@ using signin_metrics::PromoAction;
ios::GetChromeBrowserProvider() ios::GetChromeBrowserProvider()
->GetChromeIdentityService() ->GetChromeIdentityService()
->CreateChromeIdentityInteractionManager( ->CreateChromeIdentityInteractionManager(
self.browser->GetBrowserState()); self.browser->GetBrowserState(), self);
signin::IdentityManager* identityManager = signin::IdentityManager* identityManager =
IdentityManagerFactory::GetForBrowserState( IdentityManagerFactory::GetForBrowserState(
...@@ -134,6 +136,25 @@ using signin_metrics::PromoAction; ...@@ -134,6 +136,25 @@ using signin_metrics::PromoAction;
DCHECK(!self.userSigninCoordinator); DCHECK(!self.userSigninCoordinator);
} }
#pragma mark - ChromeIdentityInteractionManagerDelegate
- (void)interactionManager:(ChromeIdentityInteractionManager*)interactionManager
dismissViewControllerAnimated:(BOOL)animated
completion:(ProceduralBlock)completion {
[self.baseViewController.presentedViewController
dismissViewControllerAnimated:animated
completion:completion];
}
- (void)interactionManager:(ChromeIdentityInteractionManager*)interactionManager
presentViewController:(UIViewController*)viewController
animated:(BOOL)animated
completion:(ProceduralBlock)completion {
[self.baseViewController presentViewController:viewController
animated:animated
completion:completion];
}
#pragma mark - AddAccountSigninManagerDelegate #pragma mark - AddAccountSigninManagerDelegate
- (void)addAccountSigninManagerFailedWithError:(NSError*)error { - (void)addAccountSigninManagerFailedWithError:(NSError*)error {
......
...@@ -29,6 +29,31 @@ const char kTestGaiaID[] = "fooID"; ...@@ -29,6 +29,31 @@ const char kTestGaiaID[] = "fooID";
const char kTestEmail[] = "foo@gmail.com"; const char kTestEmail[] = "foo@gmail.com";
} // namespace } // namespace
// Fake implementation of ChromeIdentityInteractionManagerDelegate that calls
// completion callback.
@interface FakeChromeIdentityInteractionManagerDelegate
: NSObject <ChromeIdentityInteractionManagerDelegate>
@end
@implementation FakeChromeIdentityInteractionManagerDelegate
- (void)interactionManager:(ChromeIdentityInteractionManager*)interactionManager
presentViewController:(UIViewController*)viewController
animated:(BOOL)animated
completion:(ProceduralBlock)completion {
if (completion) {
completion();
}
}
- (void)interactionManager:(ChromeIdentityInteractionManager*)interactionManager
dismissViewControllerAnimated:(BOOL)animated
completion:(ProceduralBlock)completion {
if (completion) {
completion();
}
}
@end
class AddAccountSigninManagerTest : public PlatformTest { class AddAccountSigninManagerTest : public PlatformTest {
public: public:
AddAccountSigninManagerTest() AddAccountSigninManagerTest()
...@@ -36,13 +61,16 @@ class AddAccountSigninManagerTest : public PlatformTest { ...@@ -36,13 +61,16 @@ class AddAccountSigninManagerTest : public PlatformTest {
base_view_controller_([[UIViewController alloc] init]), base_view_controller_([[UIViewController alloc] init]),
identity_service_( identity_service_(
ios::FakeChromeIdentityService::GetInstanceFromChromeProvider()) { ios::FakeChromeIdentityService::GetInstanceFromChromeProvider()) {
identity_interaction_manager_delegate_ =
[[FakeChromeIdentityInteractionManagerDelegate alloc] init];
identity_interaction_manager_ = GetIdentityInteractionManager(); identity_interaction_manager_ = GetIdentityInteractionManager();
} }
FakeChromeIdentityInteractionManager* GetIdentityInteractionManager() { FakeChromeIdentityInteractionManager* GetIdentityInteractionManager() {
FakeChromeIdentityInteractionManager* identity_interaction_manager = FakeChromeIdentityInteractionManager* identity_interaction_manager =
ios::FakeChromeIdentityService::GetInstanceFromChromeProvider() ios::FakeChromeIdentityService::GetInstanceFromChromeProvider()
->CreateFakeChromeIdentityInteractionManager(browser_state_.get()); ->CreateFakeChromeIdentityInteractionManager(
browser_state_.get(), identity_interaction_manager_delegate_);
fake_identity_ = [FakeChromeIdentity fake_identity_ = [FakeChromeIdentity
identityWithEmail:[NSString stringWithUTF8String:kTestEmail] identityWithEmail:[NSString stringWithUTF8String:kTestEmail]
gaiaID:[NSString stringWithUTF8String:kTestGaiaID] gaiaID:[NSString stringWithUTF8String:kTestGaiaID]
...@@ -94,6 +122,8 @@ class AddAccountSigninManagerTest : public PlatformTest { ...@@ -94,6 +122,8 @@ class AddAccountSigninManagerTest : public PlatformTest {
ios::FakeChromeIdentityService* identity_service_ = nullptr; ios::FakeChromeIdentityService* identity_service_ = nullptr;
FakeChromeIdentityInteractionManager* identity_interaction_manager_ = nil; FakeChromeIdentityInteractionManager* identity_interaction_manager_ = nil;
id<ChromeIdentityInteractionManagerDelegate>
identity_interaction_manager_delegate_ = nil;
FakeChromeIdentity* fake_identity_ = nil; FakeChromeIdentity* fake_identity_ = nil;
}; };
......
...@@ -33,6 +33,24 @@ typedef void (^SigninCompletionCallback)(ChromeIdentity* identity, ...@@ -33,6 +33,24 @@ typedef void (^SigninCompletionCallback)(ChromeIdentity* identity,
@property(nonatomic, weak) id<ChromeIdentityInteractionManagerDelegate> @property(nonatomic, weak) id<ChromeIdentityInteractionManagerDelegate>
delegate; delegate;
// Whether the manager is currently being canceled. Delegates may inquire if the
// dismissal is due to sign-in being canceled.
@property(nonatomic, readonly) BOOL isCanceling;
// Deprecated.
// Use |addAccountWithPresentingViewController:completion|.
- (void)addAccountWithCompletion:(SigninCompletionCallback)completion;
// Deprecated.
// Use |addAccountWithPresentingViewController:userEmail:completion|.
- (void)reauthenticateUserWithID:(NSString*)userID
email:(NSString*)userEmail
completion:(SigninCompletionCallback)completion;
// Deprecated.
// Use |cancelAddAccountWithAnimation:completion|.
- (void)cancelAndDismissAnimated:(BOOL)animated;
// Starts the add account operation for a user. Presents user with the screen to // Starts the add account operation for a user. Presents user with the screen to
// enter credentials. // enter credentials.
// Note: Calling this method will fail and the completion will be called with a // Note: Calling this method will fail and the completion will be called with a
...@@ -91,6 +109,7 @@ typedef void (^SigninCompletionCallback)(ChromeIdentity* identity, ...@@ -91,6 +109,7 @@ typedef void (^SigninCompletionCallback)(ChromeIdentity* identity,
- (void)interactionManager:(ChromeIdentityInteractionManager*)interactionManager - (void)interactionManager:(ChromeIdentityInteractionManager*)interactionManager
dismissViewControllerAnimated:(BOOL)animated dismissViewControllerAnimated:(BOOL)animated
completion:(ProceduralBlock)completion; completion:(ProceduralBlock)completion;
@end @end
#endif // IOS_PUBLIC_PROVIDER_CHROME_BROWSER_SIGNIN_CHROME_IDENTITY_INTERACTION_MANAGER_H_ #endif // IOS_PUBLIC_PROVIDER_CHROME_BROWSER_SIGNIN_CHROME_IDENTITY_INTERACTION_MANAGER_H_
...@@ -15,6 +15,24 @@ ...@@ -15,6 +15,24 @@
@implementation ChromeIdentityInteractionManager @implementation ChromeIdentityInteractionManager
@synthesize delegate = _delegate; @synthesize delegate = _delegate;
- (BOOL)isCanceling {
return NO;
}
- (void)addAccountWithCompletion:(SigninCompletionCallback)completion {
NOTREACHED() << "Subclasses must override this";
}
- (void)reauthenticateUserWithID:(NSString*)userID
email:(NSString*)userEmail
completion:(SigninCompletionCallback)completion {
NOTREACHED() << "Subclasses must override this";
}
- (void)cancelAndDismissAnimated:(BOOL)animated {
NOTREACHED() << "Subclasses must override this";
}
- (void)addAccountWithPresentingViewController:(UIViewController*)viewController - (void)addAccountWithPresentingViewController:(UIViewController*)viewController
completion: completion:
(SigninCompletionCallback)completion { (SigninCompletionCallback)completion {
......
...@@ -132,19 +132,13 @@ class ChromeIdentityService { ...@@ -132,19 +132,13 @@ class ChromeIdentityService {
UIViewController* view_controller, UIViewController* view_controller,
BOOL animated); BOOL animated);
// Deprecated. Please use: // Returns a new ChromeIdentityInteractionManager with |delegate| as its
// CreateChromeIdentityInteractionManager(ChromeBrowserState*). Returns a new // delegate.
// ChromeIdentityInteractionManager with |delegate| as its delegate.
virtual ChromeIdentityInteractionManager* virtual ChromeIdentityInteractionManager*
CreateChromeIdentityInteractionManager( CreateChromeIdentityInteractionManager(
ChromeBrowserState* browser_state, ChromeBrowserState* browser_state,
id<ChromeIdentityInteractionManagerDelegate> delegate) const; id<ChromeIdentityInteractionManagerDelegate> delegate) const;
// Returns a new ChromeIdentityInteractionManager.
virtual ChromeIdentityInteractionManager*
CreateChromeIdentityInteractionManager(
ChromeBrowserState* browser_state) const;
// Returns YES if |identity| is valid and if the service has it in its list of // Returns YES if |identity| is valid and if the service has it in its list of
// identitites. // identitites.
virtual bool IsValidIdentity(ChromeIdentity* identity) const; virtual bool IsValidIdentity(ChromeIdentity* identity) const;
......
...@@ -53,12 +53,6 @@ ChromeIdentityService::CreateChromeIdentityInteractionManager( ...@@ -53,12 +53,6 @@ ChromeIdentityService::CreateChromeIdentityInteractionManager(
return nil; return nil;
} }
ChromeIdentityInteractionManager*
ChromeIdentityService::CreateChromeIdentityInteractionManager(
ChromeBrowserState* browser_state) const {
return CreateChromeIdentityInteractionManager(browser_state, nil);
}
bool ChromeIdentityService::IsValidIdentity(ChromeIdentity* identity) const { bool ChromeIdentityService::IsValidIdentity(ChromeIdentity* identity) const {
return false; return false;
} }
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
@interface FakeChromeIdentityInteractionManager () { @interface FakeChromeIdentityInteractionManager () {
SigninCompletionCallback _completionCallback; SigninCompletionCallback _completionCallback;
UIViewController* _viewController; UIViewController* _viewController;
BOOL _isCanceling;
} }
@end @end
...@@ -97,6 +98,33 @@ ...@@ -97,6 +98,33 @@
@synthesize fakeIdentity = _fakeIdentity; @synthesize fakeIdentity = _fakeIdentity;
- (BOOL)isCanceling {
return _isCanceling;
}
- (void)addAccountWithCompletion:(SigninCompletionCallback)completion {
_completionCallback = completion;
_viewController =
[[FakeAddAccountViewController alloc] initWithInteractionManager:self];
[self.delegate interactionManager:self
presentViewController:_viewController
animated:YES
completion:nil];
}
- (void)reauthenticateUserWithID:(NSString*)userID
email:(NSString*)userEmail
completion:(SigninCompletionCallback)completion {
[self addAccountWithCompletion:completion];
}
- (void)cancelAndDismissAnimated:(BOOL)animated {
_isCanceling = YES;
[self dismissAndRunCompletionCallbackWithError:[self canceledError]
animated:animated];
_isCanceling = NO;
}
- (void)addAccountWithPresentingViewController:(UIViewController*)viewController - (void)addAccountWithPresentingViewController:(UIViewController*)viewController
completion: completion:
(SigninCompletionCallback)completion { (SigninCompletionCallback)completion {
......
...@@ -32,10 +32,12 @@ class FakeChromeIdentityService : public ChromeIdentityService { ...@@ -32,10 +32,12 @@ class FakeChromeIdentityService : public ChromeIdentityService {
UIViewController* viewController, UIViewController* viewController,
BOOL animated) override; BOOL animated) override;
ChromeIdentityInteractionManager* CreateChromeIdentityInteractionManager( ChromeIdentityInteractionManager* CreateChromeIdentityInteractionManager(
ChromeBrowserState* browser_state) const override; ChromeBrowserState* browser_state,
id<ChromeIdentityInteractionManagerDelegate> delegate) const override;
FakeChromeIdentityInteractionManager* FakeChromeIdentityInteractionManager*
CreateFakeChromeIdentityInteractionManager( CreateFakeChromeIdentityInteractionManager(
ChromeBrowserState* browser_state) const; ChromeBrowserState* browser_state,
id<ChromeIdentityInteractionManagerDelegate> delegate) const;
bool IsValidIdentity(ChromeIdentity* identity) const override; bool IsValidIdentity(ChromeIdentity* identity) const override;
ChromeIdentity* GetIdentityWithGaiaID( ChromeIdentity* GetIdentityWithGaiaID(
......
...@@ -156,14 +156,19 @@ FakeChromeIdentityService::PresentAccountDetailsController( ...@@ -156,14 +156,19 @@ FakeChromeIdentityService::PresentAccountDetailsController(
ChromeIdentityInteractionManager* ChromeIdentityInteractionManager*
FakeChromeIdentityService::CreateChromeIdentityInteractionManager( FakeChromeIdentityService::CreateChromeIdentityInteractionManager(
ChromeBrowserState* browser_state) const { ChromeBrowserState* browser_state,
return CreateFakeChromeIdentityInteractionManager(browser_state); id<ChromeIdentityInteractionManagerDelegate> delegate) const {
return CreateFakeChromeIdentityInteractionManager(browser_state, delegate);
} }
FakeChromeIdentityInteractionManager* FakeChromeIdentityInteractionManager*
FakeChromeIdentityService::CreateFakeChromeIdentityInteractionManager( FakeChromeIdentityService::CreateFakeChromeIdentityInteractionManager(
ChromeBrowserState* browser_state) const { ChromeBrowserState* browser_state,
return [[FakeChromeIdentityInteractionManager alloc] init]; id<ChromeIdentityInteractionManagerDelegate> delegate) const {
FakeChromeIdentityInteractionManager* manager =
[[FakeChromeIdentityInteractionManager alloc] init];
manager.delegate = delegate;
return manager;
} }
bool FakeChromeIdentityService::IsValidIdentity( bool FakeChromeIdentityService::IsValidIdentity(
......
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