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_SUGGESTION_PROVIDER_H_ |
| 6 #define IOS_CHROME_BROWSER_AUTOFILL_FORM_SUGGESTION_PROVIDER_H_ |
| 7 |
| 8 #import "components/autofill/ios/browser/form_suggestion.h" |
| 9 |
| 10 @protocol FormSuggestionProvider; |
| 11 |
| 12 namespace web { |
| 13 class WebState; |
| 14 } // namespace web |
| 15 |
| 16 typedef void (^SuggestionsAvailableCompletion)(BOOL suggestionsAvailable); |
| 17 typedef void (^SuggestionsReadyCompletion)(NSArray* suggestions, |
| 18 id<FormSuggestionProvider> delegate); |
| 19 typedef void (^SuggestionHandledCompletion)(void); |
| 20 |
| 21 // Provides user-selectable suggestions for an input field of a web form |
| 22 // and handles user interaction with those suggestions. |
| 23 @protocol FormSuggestionProvider<NSObject> |
| 24 |
| 25 // Determines whether the receiver can provide suggestions for the specified |
| 26 // |form| and |field|, returning the result using the provided |completion|. |
| 27 // |typedValue| contains the text that the user has typed into the field so far. |
| 28 - (void)checkIfSuggestionsAvailableForForm:(NSString*)formName |
| 29 field:(NSString*)fieldName |
| 30 type:(NSString*)type |
| 31 typedValue:(NSString*)typedValue |
| 32 webState:(web::WebState*)webState |
| 33 completionHandler: |
| 34 (SuggestionsAvailableCompletion)completion; |
| 35 |
| 36 // Retrieves suggestions for the specified |form| and |field| and returns them |
| 37 // using the provided |completion|. |typedValue| contains the text that the |
| 38 // user has typed into the field so far. |
| 39 - (void)retrieveSuggestionsForForm:(NSString*)formName |
| 40 field:(NSString*)fieldName |
| 41 type:(NSString*)type |
| 42 typedValue:(NSString*)typedValue |
| 43 webState:(web::WebState*)webState |
| 44 completionHandler:(SuggestionsReadyCompletion)completion; |
| 45 |
| 46 // Handles user selection of a suggestion for the specified form and |
| 47 // field, invoking |completion| when finished. |
| 48 - (void)didSelectSuggestion:(FormSuggestion*)suggestion |
| 49 forField:(NSString*)fieldName |
| 50 form:(NSString*)formName |
| 51 completionHandler:(SuggestionHandledCompletion)completion; |
| 52 |
| 53 @end |
| 54 |
| 55 #endif // IOS_CHROME_BROWSER_AUTOFILL_FORM_SUGGESTION_PROVIDER_H_ |
OLD | NEW |