OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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_CHROME_SIGNIN_VIEW_CONTROLLER_H_ |
| 6 #define IOS_CHROME_BROWSER_UI_AUTHENTICATION_CHROME_SIGNIN_VIEW_CONTROLLER_H_ |
| 7 |
| 8 #import <UIKit/UIKit.h> |
| 9 |
| 10 #include "components/signin/core/browser/signin_metrics.h" |
| 11 #import "ios/chrome/browser/signin/constants.h" |
| 12 |
| 13 @class ChromeSigninViewController; |
| 14 @class GenericChromeCommand; |
| 15 @class ChromeIdentity; |
| 16 |
| 17 namespace ios { |
| 18 class ChromeBrowserState; |
| 19 } // namespace ios |
| 20 |
| 21 @protocol ChromeSigninViewControllerDelegate<NSObject> |
| 22 |
| 23 // Informs the delegate that a sign-in operation will start in |controller|. |
| 24 - (void)willStartSignIn:(ChromeSigninViewController*)controller; |
| 25 |
| 26 // Informs the delegate that an add account operation will start in |
| 27 // |controller|. |
| 28 - (void)willStartAddAccount:(ChromeSigninViewController*)controller; |
| 29 |
| 30 // Informs the delegate that the user skipped sign-in in |controller|. |
| 31 - (void)didSkipSignIn:(ChromeSigninViewController*)controller; |
| 32 |
| 33 // Informs the delegate that the sign-in failed in |controller|. |
| 34 - (void)didFailSignIn:(ChromeSigninViewController*)controller; |
| 35 |
| 36 // Informs the delegate that the user was signed in in |controller|. |
| 37 // |
| 38 // Note that the sign-in flow did not actually finish when this method is |
| 39 // called. The delegate will be called with [-didAcceptSignIn:] or |
| 40 // [-didUndoSignIn:identity:] once the user decides to accept or to undo the |
| 41 // sign-in operation. |
| 42 - (void)didSignIn:(ChromeSigninViewController*)controller; |
| 43 |
| 44 // Informs the delegate that the sign-in of |identity| was undone in |
| 45 // |controller|. |
| 46 // |identity| will be automatically forgotten if it was added during this |
| 47 // sign-in flow. |
| 48 - (void)didUndoSignIn:(ChromeSigninViewController*)controller |
| 49 identity:(ChromeIdentity*)identity; |
| 50 |
| 51 // Informs the delegate that the user has accepted the sign-in in |controller|. |
| 52 // If |command| is not nil, the delegate is expected to execute it. |
| 53 // This marks the end of the sign-in flow. |
| 54 - (void)didAcceptSignIn:(ChromeSigninViewController*)controller |
| 55 executeCommand:(GenericChromeCommand*)command; |
| 56 |
| 57 @end |
| 58 |
| 59 // ChromeSigninViewController is a view controller that handles all the |
| 60 // sign-in UI flow. |
| 61 @interface ChromeSigninViewController : UIViewController |
| 62 |
| 63 @property(nonatomic, assign) id<ChromeSigninViewControllerDelegate> delegate; |
| 64 |
| 65 // Data clearing policy to use during the authentication. |
| 66 // It is valid to set this in the |willStartSignIn:| method of the delegate. |
| 67 @property(nonatomic, assign) ShouldClearData shouldClearData; |
| 68 |
| 69 // Designated initializer. |
| 70 // * |browserState| is the current browser state. |
| 71 // * |isPresentedOnSettings| indicates whether the settings view controller is |
| 72 // part of the presented view controllers stack. |
| 73 // * |accessPoint| represents the access point that initiated the sign-in. |
| 74 // * |identity| will be signed in without requiring user input if not nil. |
| 75 - (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState |
| 76 isPresentedOnSettings:(BOOL)isPresentedOnSettings |
| 77 signInAccessPoint:(signin_metrics::AccessPoint)accessPoint |
| 78 signInIdentity:(ChromeIdentity*)identity; |
| 79 |
| 80 // Cancels the on-going authentication operation (if any). |delegate| will be |
| 81 // called with |didFailSignIn|. |
| 82 - (void)cancel; |
| 83 |
| 84 @end |
| 85 |
| 86 @interface ChromeSigninViewController (Subclassing) |
| 87 |
| 88 @property(nonatomic, readonly) ios::ChromeBrowserState* browserState; |
| 89 |
| 90 @property(nonatomic, readonly) UIColor* backgroundColor; |
| 91 |
| 92 // Vertical padding used underneath buttons. Default value is 18. |
| 93 @property(nonatomic, assign) CGFloat buttonVerticalPadding; |
| 94 |
| 95 // Primary button title used to accept the sign-in. |
| 96 @property(nonatomic, readonly) NSString* acceptSigninButtonTitle; |
| 97 |
| 98 // Secondary button title used to skip the sign-in. |
| 99 @property(nonatomic, readonly) NSString* skipSigninButtonTitle; |
| 100 |
| 101 @property(nonatomic, readonly) UIButton* primaryButton; |
| 102 @property(nonatomic, readonly) UIButton* secondaryButton; |
| 103 |
| 104 @end |
| 105 |
| 106 #endif // IOS_CHROME_BROWSER_UI_AUTHENTICATION_CHROME_SIGNIN_VIEW_CONTROLLER_H_ |
OLD | NEW |