OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef IOS_CHROME_BROWSER_UI_AUTHENTICATION_AUTHENTICATION_FLOW_H_ |
| 6 #define IOS_CHROME_BROWSER_UI_AUTHENTICATION_AUTHENTICATION_FLOW_H_ |
| 7 |
| 8 #import <Foundation/Foundation.h> |
| 9 |
| 10 #import "ios/chrome/browser/signin/constants.h" |
| 11 #import "ios/chrome/browser/ui/authentication/authentication_flow_performer_dele
gate.h" |
| 12 |
| 13 @class AuthenticationFlowPerformer; |
| 14 @class ChromeIdentity; |
| 15 @class UIViewController; |
| 16 |
| 17 namespace ios { |
| 18 class ChromeBrowserState; |
| 19 } // namespace ios |
| 20 |
| 21 // |AuthenticationFlow| manages the authentication flow for a given identity. |
| 22 // |
| 23 // A new instance of |AuthenticationFlow| should be used each time an identity |
| 24 // needs to be signed in. |
| 25 @interface AuthenticationFlow : NSObject<AuthenticationFlowPerformerDelegate> |
| 26 |
| 27 // Designated initializer. |
| 28 // * |browserState| is the current browser state |
| 29 // * |shouldClearData| indicates how to handle existing data when the signed in |
| 30 // account is being switched. Possible values: |
| 31 // * User choice: present an alert view asking the user whether the data |
| 32 // should be cleared or merged. |
| 33 // * Clear data: data is removed before signing in with |identity|. |
| 34 // * Merge data: data is not removed before signing in with |identity|. |
| 35 // * |postSignInAction| represents the action to be taken once |identity| is |
| 36 // signed in. |
| 37 // * |presentingViewController| is the top presented view controller. |
| 38 - (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState |
| 39 identity:(ChromeIdentity*)identity |
| 40 shouldClearData:(ShouldClearData)shouldClearData |
| 41 postSignInAction:(PostSignInAction)postSignInAction |
| 42 presentingViewController:(UIViewController*)presentingViewController |
| 43 NS_DESIGNATED_INITIALIZER; |
| 44 |
| 45 - (instancetype)init NS_UNAVAILABLE; |
| 46 |
| 47 // Starts the sign in flow for the identity given in the constructor. Displays |
| 48 // the signed inconfirmation dialog allowing the user to sign out or configure |
| 49 // sync. |
| 50 // It is safe to destroy this authentication flow when |completion| is called. |
| 51 // |completion| must not be nil. |
| 52 - (void)startSignInWithCompletion:(signin_ui::CompletionCallback)completion; |
| 53 |
| 54 // Cancels the current sign-in operation (if any) and dismiss any UI presented |
| 55 // by this authentication flow. Calls the completion callback with the sign-in |
| 56 // flag set to NO. |
| 57 // Does nothing if the sign in flow is already done. |
| 58 - (void)cancelAndDismiss; |
| 59 |
| 60 @end |
| 61 |
| 62 // Private methods in AuthenticationFlow to test. |
| 63 @interface AuthenticationFlow (TestingAdditions) |
| 64 - (void)setPerformerForTesting:(AuthenticationFlowPerformer*)performer; |
| 65 @end |
| 66 |
| 67 #endif // IOS_CHROME_BROWSER_UI_AUTHENTICATION_AUTHENTICATION_FLOW_H_ |
OLD | NEW |