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 {
} // namespace
@interface ChromeSigninViewController () <
ChromeIdentityInteractionManagerDelegate,
ChromeIdentityServiceObserver,
MDCActivityIndicatorDelegate,
UIAdaptivePresentationControllerDelegate,
......@@ -568,7 +569,7 @@ enum AuthenticationState {
_interactionManager =
ios::GetChromeBrowserProvider()
->GetChromeIdentityService()
->CreateChromeIdentityInteractionManager(self.browserState);
->CreateChromeIdentityInteractionManager(self.browserState, self);
__weak ChromeSigninViewController* weakSelf = self;
SigninCompletionCallback completion =
^(ChromeIdentity* identity, NSError* error) {
......
......@@ -23,7 +23,9 @@
using signin_metrics::AccessPoint;
using signin_metrics::PromoAction;
@interface AddAccountSigninCoordinator () <AddAccountSigninManagerDelegate>
@interface AddAccountSigninCoordinator () <
AddAccountSigninManagerDelegate,
ChromeIdentityInteractionManagerDelegate>
// Coordinator to display modal alerts to the user.
@property(nonatomic, strong) AlertCoordinator* alertCoordinator;
......@@ -110,7 +112,7 @@ using signin_metrics::PromoAction;
ios::GetChromeBrowserProvider()
->GetChromeIdentityService()
->CreateChromeIdentityInteractionManager(
self.browser->GetBrowserState());
self.browser->GetBrowserState(), self);
signin::IdentityManager* identityManager =
IdentityManagerFactory::GetForBrowserState(
......@@ -134,6 +136,25 @@ using signin_metrics::PromoAction;
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
- (void)addAccountSigninManagerFailedWithError:(NSError*)error {
......
......@@ -29,6 +29,31 @@ const char kTestGaiaID[] = "fooID";
const char kTestEmail[] = "foo@gmail.com";
} // 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 {
public:
AddAccountSigninManagerTest()
......@@ -36,13 +61,16 @@ class AddAccountSigninManagerTest : public PlatformTest {
base_view_controller_([[UIViewController alloc] init]),
identity_service_(
ios::FakeChromeIdentityService::GetInstanceFromChromeProvider()) {
identity_interaction_manager_delegate_ =
[[FakeChromeIdentityInteractionManagerDelegate alloc] init];
identity_interaction_manager_ = GetIdentityInteractionManager();
}
FakeChromeIdentityInteractionManager* GetIdentityInteractionManager() {
FakeChromeIdentityInteractionManager* identity_interaction_manager =
ios::FakeChromeIdentityService::GetInstanceFromChromeProvider()
->CreateFakeChromeIdentityInteractionManager(browser_state_.get());
->CreateFakeChromeIdentityInteractionManager(
browser_state_.get(), identity_interaction_manager_delegate_);
fake_identity_ = [FakeChromeIdentity
identityWithEmail:[NSString stringWithUTF8String:kTestEmail]
gaiaID:[NSString stringWithUTF8String:kTestGaiaID]
......@@ -94,6 +122,8 @@ class AddAccountSigninManagerTest : public PlatformTest {
ios::FakeChromeIdentityService* identity_service_ = nullptr;
FakeChromeIdentityInteractionManager* identity_interaction_manager_ = nil;
id<ChromeIdentityInteractionManagerDelegate>
identity_interaction_manager_delegate_ = nil;
FakeChromeIdentity* fake_identity_ = nil;
};
......
......@@ -33,6 +33,24 @@ typedef void (^SigninCompletionCallback)(ChromeIdentity* identity,
@property(nonatomic, weak) id<ChromeIdentityInteractionManagerDelegate>
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
// enter credentials.
// Note: Calling this method will fail and the completion will be called with a
......@@ -91,6 +109,7 @@ typedef void (^SigninCompletionCallback)(ChromeIdentity* identity,
- (void)interactionManager:(ChromeIdentityInteractionManager*)interactionManager
dismissViewControllerAnimated:(BOOL)animated
completion:(ProceduralBlock)completion;
@end
#endif // IOS_PUBLIC_PROVIDER_CHROME_BROWSER_SIGNIN_CHROME_IDENTITY_INTERACTION_MANAGER_H_
......@@ -15,6 +15,24 @@
@implementation ChromeIdentityInteractionManager
@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
completion:
(SigninCompletionCallback)completion {
......
......@@ -132,19 +132,13 @@ class ChromeIdentityService {
UIViewController* view_controller,
BOOL animated);
// Deprecated. Please use:
// CreateChromeIdentityInteractionManager(ChromeBrowserState*). Returns a new
// ChromeIdentityInteractionManager with |delegate| as its delegate.
// Returns a new ChromeIdentityInteractionManager with |delegate| as its
// delegate.
virtual ChromeIdentityInteractionManager*
CreateChromeIdentityInteractionManager(
ChromeBrowserState* browser_state,
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
// identitites.
virtual bool IsValidIdentity(ChromeIdentity* identity) const;
......
......@@ -53,12 +53,6 @@ ChromeIdentityService::CreateChromeIdentityInteractionManager(
return nil;
}
ChromeIdentityInteractionManager*
ChromeIdentityService::CreateChromeIdentityInteractionManager(
ChromeBrowserState* browser_state) const {
return CreateChromeIdentityInteractionManager(browser_state, nil);
}
bool ChromeIdentityService::IsValidIdentity(ChromeIdentity* identity) const {
return false;
}
......
......@@ -24,6 +24,7 @@
@interface FakeChromeIdentityInteractionManager () {
SigninCompletionCallback _completionCallback;
UIViewController* _viewController;
BOOL _isCanceling;
}
@end
......@@ -97,6 +98,33 @@
@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
completion:
(SigninCompletionCallback)completion {
......
......@@ -32,10 +32,12 @@ class FakeChromeIdentityService : public ChromeIdentityService {
UIViewController* viewController,
BOOL animated) override;
ChromeIdentityInteractionManager* CreateChromeIdentityInteractionManager(
ChromeBrowserState* browser_state) const override;
ChromeBrowserState* browser_state,
id<ChromeIdentityInteractionManagerDelegate> delegate) const override;
FakeChromeIdentityInteractionManager*
CreateFakeChromeIdentityInteractionManager(
ChromeBrowserState* browser_state) const;
ChromeBrowserState* browser_state,
id<ChromeIdentityInteractionManagerDelegate> delegate) const;
bool IsValidIdentity(ChromeIdentity* identity) const override;
ChromeIdentity* GetIdentityWithGaiaID(
......
......@@ -156,14 +156,19 @@ FakeChromeIdentityService::PresentAccountDetailsController(
ChromeIdentityInteractionManager*
FakeChromeIdentityService::CreateChromeIdentityInteractionManager(
ChromeBrowserState* browser_state) const {
return CreateFakeChromeIdentityInteractionManager(browser_state);
ChromeBrowserState* browser_state,
id<ChromeIdentityInteractionManagerDelegate> delegate) const {
return CreateFakeChromeIdentityInteractionManager(browser_state, delegate);
}
FakeChromeIdentityInteractionManager*
FakeChromeIdentityService::CreateFakeChromeIdentityInteractionManager(
ChromeBrowserState* browser_state) const {
return [[FakeChromeIdentityInteractionManager alloc] init];
ChromeBrowserState* browser_state,
id<ChromeIdentityInteractionManagerDelegate> delegate) const {
FakeChromeIdentityInteractionManager* manager =
[[FakeChromeIdentityInteractionManager alloc] init];
manager.delegate = delegate;
return manager;
}
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