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_AUTOFILL_FORM_INPUT_ACCESSORY_VIEW_CONTROLLER_H_ |
| 6 #define IOS_CHROME_BROWSER_AUTOFILL_FORM_INPUT_ACCESSORY_VIEW_CONTROLLER_H_ |
| 7 |
| 8 #import <UIKit/UIKit.h> |
| 9 |
| 10 #import "ios/chrome/browser/autofill/form_input_accessory_view_delegate.h" |
| 11 #import "ios/web/public/web_state/web_state_observer_bridge.h" |
| 12 |
| 13 @protocol CRWWebViewProxy; |
| 14 |
| 15 namespace ios_internal { |
| 16 namespace autofill { |
| 17 extern NSString* const kFormSuggestionAssistButtonPreviousElement; |
| 18 extern NSString* const kFormSuggestionAssistButtonNextElement; |
| 19 extern NSString* const kFormSuggestionAssistButtonDone; |
| 20 } // namespace autofill |
| 21 } // namespace ios_internal |
| 22 |
| 23 @protocol FormInputAccessoryViewProvider; |
| 24 @class FormInputAccessoryViewController; |
| 25 |
| 26 // Block type to indicate that a FormInputAccessoryViewProvider has an accessory |
| 27 // view to provide. |
| 28 typedef void (^AccessoryViewAvailableCompletion)( |
| 29 BOOL inputAccessoryViewAvailable); |
| 30 |
| 31 // Block type to provide an accessory view asynchronously. |
| 32 typedef void (^AccessoryViewReadyCompletion)( |
| 33 UIView* view, |
| 34 id<FormInputAccessoryViewProvider> provider); |
| 35 |
| 36 // Represents an object that can provide a custom keyboard input accessory view. |
| 37 @protocol FormInputAccessoryViewProvider<NSObject> |
| 38 |
| 39 // A delegate for form navigation. |
| 40 @property(nonatomic, assign) |
| 41 id<FormInputAccessoryViewDelegate> accessoryViewDelegate; |
| 42 |
| 43 // Determines asynchronously if this provider has a view available for the |
| 44 // specified form/field and invokes |completionHandler| with the answer. |
| 45 - (void)checkIfAccessoryViewAvailableForFormNamed:(const std::string&)formName |
| 46 fieldName:(const std::string&)fieldName |
| 47 webState:(web::WebState*)webState |
| 48 completionHandler: |
| 49 (AccessoryViewAvailableCompletion) |
| 50 completionHandler; |
| 51 |
| 52 // Asynchronously retrieves an accessory view from this provider for the |
| 53 // specified form/field and returns it via |completionHandler|. |
| 54 - (void)retrieveAccessoryViewForFormNamed:(const std::string&)formName |
| 55 fieldName:(const std::string&)fieldName |
| 56 value:(const std::string&)value |
| 57 type:(const std::string&)type |
| 58 webState:(web::WebState*)webState |
| 59 completionHandler: |
| 60 (AccessoryViewReadyCompletion)completionHandler; |
| 61 |
| 62 // Notifies this provider that the accessory view is going away. |
| 63 - (void)inputAccessoryViewControllerDidReset: |
| 64 (FormInputAccessoryViewController*)controller; |
| 65 |
| 66 // Notifies this provider that the accessory view frame is changing. If the |
| 67 // view provided by this provider needs to change, the updated view should be |
| 68 // returned using the completion received in |
| 69 // |retrieveAccessoryViewForForm:field:value:type:webState:completionHandler:|. |
| 70 - (void)resizeAccessoryView; |
| 71 |
| 72 @end |
| 73 |
| 74 // Creates and manages a custom input accessory view while the user is |
| 75 // interacting with a form. Also handles hiding and showing the default |
| 76 // accessory view elements. |
| 77 @interface FormInputAccessoryViewController |
| 78 : NSObject<CRWWebStateObserver, FormInputAccessoryViewDelegate> |
| 79 |
| 80 // Initializes a new controller with the specified |providers| of input |
| 81 // accessory views. |
| 82 - (instancetype)initWithWebState:(web::WebState*)webState |
| 83 providers:(NSArray*)providers; |
| 84 |
| 85 // Hides the default input accessory view and replaces it with one that shows |
| 86 // |customView| and form navigation controls. |
| 87 - (void)showCustomInputAccessoryView:(UIView*)customView; |
| 88 |
| 89 // Restores the default input accessory view, removing (if necessary) any |
| 90 // previously-added custom view. |
| 91 - (void)restoreDefaultInputAccessoryView; |
| 92 |
| 93 @end |
| 94 |
| 95 #endif // IOS_CHROME_BROWSER_AUTOFILL_FORM_INPUT_ACCESSORY_VIEW_CONTROLLER_H_ |
OLD | NEW |