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

Unified Diff: ios/chrome/browser/ui/authentication/signin_interaction_controller.mm

Issue 2936583002: [ObjC ARC] Converts ios/chrome/browser/ui/authentication:authentication to ARC. (Closed)
Patch Set: Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/authentication/signin_interaction_controller.mm
diff --git a/ios/chrome/browser/ui/authentication/signin_interaction_controller.mm b/ios/chrome/browser/ui/authentication/signin_interaction_controller.mm
index 1f693f817abf71fb9e411a7811ed9a8ef4add697..c1fc64dcd3f2538f4f30b1e36d724e5d30de31ef 100644
--- a/ios/chrome/browser/ui/authentication/signin_interaction_controller.mm
+++ b/ios/chrome/browser/ui/authentication/signin_interaction_controller.mm
@@ -4,7 +4,6 @@
#import "ios/chrome/browser/ui/authentication/signin_interaction_controller.h"
-#include "base/ios/weak_nsobject.h"
#include "base/logging.h"
#include "base/mac/scoped_block.h"
#include "base/mac/scoped_nsobject.h"
@@ -27,6 +26,10 @@
#import "ios/public/provider/chrome/browser/signin/chrome_identity_interaction_manager.h"
#import "ios/public/provider/chrome/browser/signin/chrome_identity_service.h"
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
using signin_ui::CompletionCallback;
@interface SigninInteractionController ()<
@@ -35,17 +38,16 @@ using signin_ui::CompletionCallback;
ios::ChromeBrowserState* browserState_;
signin_metrics::AccessPoint accessPoint_;
signin_metrics::PromoAction promoAction_;
- base::scoped_nsobject<UIViewController> presentingViewController_;
+ UIViewController* presentingViewController_;
BOOL isPresentedOnSettings_;
BOOL isCancelling_;
BOOL isDismissing_;
BOOL interactionManagerDismissalIgnored_;
- base::scoped_nsobject<AlertCoordinator> alertCoordinator_;
- base::mac::ScopedBlock<CompletionCallback> completionCallback_;
- base::scoped_nsobject<ChromeSigninViewController> signinViewController_;
- base::scoped_nsobject<ChromeIdentityInteractionManager>
- identityInteractionManager_;
- base::scoped_nsobject<ChromeIdentity> signInIdentity_;
+ AlertCoordinator* alertCoordinator_;
+ CompletionCallback completionCallback_;
+ ChromeSigninViewController* signinViewController_;
+ ChromeIdentityInteractionManager* identityInteractionManager_;
+ ChromeIdentity* signInIdentity_;
BOOL identityAdded_;
}
@end
@@ -67,7 +69,7 @@ using signin_ui::CompletionCallback;
DCHECK(browserState);
DCHECK(presentingViewController);
browserState_ = browserState;
- presentingViewController_.reset([presentingViewController retain]);
+ presentingViewController_ = presentingViewController;
isPresentedOnSettings_ = isPresentedOnSettings;
accessPoint_ = accessPoint;
promoAction_ = promoAction;
@@ -79,7 +81,7 @@ using signin_ui::CompletionCallback;
// Cancelling and dismissing the |identityInteractionManager_| may call the
// |completionCallback_| which could lead to |self| being released before the
// end of this method. |self| is retained here to prevent this from happening.
- base::scoped_nsobject<SigninInteractionController> strongSelf([self retain]);
+ base::scoped_nsobject<SigninInteractionController> strongSelf(self);
msarda 2017/06/12 12:49:13 Is this correct? I t there should not be any usage
marq (ping after 24h) 2017/06/12 14:20:40 I had kept it there because I didn't know what the
isCancelling_ = YES;
[alertCoordinator_ executeCancelHandler];
[alertCoordinator_ stop];
@@ -98,7 +100,7 @@ using signin_ui::CompletionCallback;
identity:(ChromeIdentity*)identity
completion:(signin_ui::CompletionCallback)completion {
signin_metrics::LogSigninAccessPointStarted(accessPoint_, promoAction_);
- completionCallback_.reset(completion, base::scoped_policy::RETAIN);
+ completionCallback_ = completion;
msarda 2017/06/12 12:49:13 Here and everywhere else we use ScopedBlock with R
marq (ping after 24h) 2017/06/12 14:20:40 Changed all simple assignments to [foo copy].
ios::ChromeIdentityService* identityService =
ios::GetChromeBrowserProvider()->GetChromeIdentityService();
if (identity) {
@@ -119,7 +121,7 @@ using signin_ui::CompletionCallback;
return;
}
- base::WeakNSObject<SigninInteractionController> weakSelf(self);
+ __weak SigninInteractionController* weakSelf = self;
[identityInteractionManager_
addAccountWithCompletion:^(ChromeIdentity* identity, NSError* error) {
[weakSelf handleIdentityAdded:identity
@@ -133,7 +135,7 @@ using signin_ui::CompletionCallback;
- (void)reAuthenticateWithCompletion:(CompletionCallback)completion
viewController:(UIViewController*)viewController {
signin_metrics::LogSigninAccessPointStarted(accessPoint_, promoAction_);
- completionCallback_.reset(completion, base::scoped_policy::RETAIN);
+ completionCallback_ = completion;
AccountInfo accountInfo =
ios::SigninManagerFactory::GetForBrowserState(browserState_)
->GetAuthenticatedAccountInfo();
@@ -158,7 +160,7 @@ using signin_ui::CompletionCallback;
ios::GetChromeBrowserProvider()
->GetChromeIdentityService()
->NewChromeIdentityInteractionManager(browserState_, self);
- base::WeakNSObject<SigninInteractionController> weakSelf(self);
+ __weak SigninInteractionController* weakSelf = self;
[identityInteractionManager_
reauthenticateUserWithID:base::SysUTF8ToNSString(idToReauthenticate)
email:base::SysUTF8ToNSString(emailToReauthenticate)
@@ -172,12 +174,12 @@ using signin_ui::CompletionCallback;
- (void)addAccountWithCompletion:(CompletionCallback)completion
viewController:(UIViewController*)viewController {
- completionCallback_.reset(completion, base::scoped_policy::RETAIN);
+ completionCallback_ = completion;
identityInteractionManager_ =
ios::GetChromeBrowserProvider()
->GetChromeIdentityService()
->NewChromeIdentityInteractionManager(browserState_, self);
- base::WeakNSObject<SigninInteractionController> weakSelf(self);
+ __weak SigninInteractionController* weakSelf = self;
[identityInteractionManager_
addAccountWithCompletion:^(ChromeIdentity* identity, NSError* error) {
[weakSelf handleIdentityAdded:identity
@@ -203,15 +205,14 @@ using signin_ui::CompletionCallback;
return;
}
- base::WeakNSObject<SigninInteractionController> weakSelf(self);
+ __weak SigninInteractionController* weakSelf = self;
ProceduralBlock dismissAction = ^{
[weakSelf runCompletionCallbackWithSuccess:NO executeCommand:nil];
};
- alertCoordinator_.reset([ios_internal::ErrorCoordinator(
+ alertCoordinator_ = ios_internal::ErrorCoordinator(
error, dismissAction,
- top_view_controller::TopPresentedViewControllerFrom(viewController))
- retain]);
+ top_view_controller::TopPresentedViewControllerFrom(viewController));
[alertCoordinator_ start];
return;
}
@@ -266,18 +267,18 @@ using signin_ui::CompletionCallback;
- (void)showSigninViewControllerWithIdentity:(ChromeIdentity*)signInIdentity
identityAdded:(BOOL)identityAdded {
- signinViewController_.reset([[ChromeSigninViewController alloc]
+ signinViewController_ = [[ChromeSigninViewController alloc]
initWithBrowserState:browserState_
isPresentedOnSettings:isPresentedOnSettings_
accessPoint:accessPoint_
promoAction:promoAction_
- signInIdentity:signInIdentity]);
+ signInIdentity:signInIdentity];
[signinViewController_ setDelegate:self];
[signinViewController_
setModalPresentationStyle:UIModalPresentationFormSheet];
[signinViewController_
setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
- signInIdentity_.reset([signInIdentity retain]);
+ signInIdentity_ = signInIdentity;
identityAdded_ = identityAdded;
UIViewController* presentingViewController = presentingViewController_;
@@ -315,27 +316,27 @@ using signin_ui::CompletionCallback;
#pragma mark - ChromeSigninViewControllerDelegate
- (void)willStartSignIn:(ChromeSigninViewController*)controller {
- DCHECK_EQ(controller, signinViewController_.get());
+ DCHECK_EQ(controller, signinViewController_);
}
- (void)willStartAddAccount:(ChromeSigninViewController*)controller {
- DCHECK_EQ(controller, signinViewController_.get());
+ DCHECK_EQ(controller, signinViewController_);
}
- (void)didSkipSignIn:(ChromeSigninViewController*)controller {
- DCHECK_EQ(controller, signinViewController_.get());
+ DCHECK_EQ(controller, signinViewController_);
[self dismissSigninViewControllerWithSignInSuccess:NO executeCommand:nil];
}
- (void)didSignIn:(ChromeSigninViewController*)controller {
- DCHECK_EQ(controller, signinViewController_.get());
+ DCHECK_EQ(controller, signinViewController_);
}
- (void)didUndoSignIn:(ChromeSigninViewController*)controller
identity:(ChromeIdentity*)identity {
- DCHECK_EQ(controller, signinViewController_.get());
- if ([signInIdentity_.get() isEqual:identity]) {
- signInIdentity_.reset();
+ DCHECK_EQ(controller, signinViewController_);
+ if ([signInIdentity_ isEqual:identity]) {
+ signInIdentity_ = nil;
if (identityAdded_) {
// This is best effort. If the operation fails, the account will be left
// on the device. The user will not be warned either as this call is
@@ -350,13 +351,13 @@ using signin_ui::CompletionCallback;
}
- (void)didFailSignIn:(ChromeSigninViewController*)controller {
- DCHECK_EQ(controller, signinViewController_.get());
+ DCHECK_EQ(controller, signinViewController_);
[self dismissSigninViewControllerWithSignInSuccess:NO executeCommand:nil];
}
- (void)didAcceptSignIn:(ChromeSigninViewController*)controller
executeCommand:(GenericChromeCommand*)command {
- DCHECK_EQ(controller, signinViewController_.get());
+ DCHECK_EQ(controller, signinViewController_);
[self dismissSigninViewControllerWithSignInSuccess:YES
executeCommand:command];
}
@@ -373,16 +374,16 @@ using signin_ui::CompletionCallback;
[self dismissPresentedViewControllersAnimated:YES completion:nil];
}
- identityInteractionManager_.reset();
- signinViewController_.reset();
+ identityInteractionManager_ = nil;
+ signinViewController_ = nil;
UIViewController* presentingViewController = presentingViewController_;
// Ensure self is not destroyed in the callbacks.
- base::scoped_nsobject<SigninInteractionController> strongSelf([self retain]);
+ SigninInteractionController* strongSelf = self;
if (completionCallback_) {
- completionCallback_.get()(success);
- completionCallback_.reset();
+ completionCallback_(success);
+ completionCallback_ = nil;
}
- strongSelf.reset();
+ strongSelf = nil;
if (command) {
[presentingViewController chromeExecuteCommand:command];
}

Powered by Google App Engine
This is Rietveld 408576698