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.
5 #ifndef IOS_CHROME_BROWSER_AUTOFILL_FORM_SUGGESTION_PROVIDER_H_
6 #define IOS_CHROME_BROWSER_AUTOFILL_FORM_SUGGESTION_PROVIDER_H_
8 #import "components/autofill/ios/browser/form_suggestion.h"
10 @protocol FormSuggestionProvider
;
16 typedef void (^SuggestionsAvailableCompletion
)(BOOL suggestionsAvailable
);
17 typedef void (^SuggestionsReadyCompletion
)(NSArray
* suggestions
,
18 id
<FormSuggestionProvider
> delegate
);
19 typedef void (^SuggestionHandledCompletion
)(void);
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
>
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
31 typedValue
:(NSString
*)typedValue
32 webState
:(web::WebState
*)webState
34 (SuggestionsAvailableCompletion
)completion
;
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
42 typedValue
:(NSString
*)typedValue
43 webState
:(web::WebState
*)webState
44 completionHandler
:(SuggestionsReadyCompletion
)completion
;
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
;
55 #endif // IOS_CHROME_BROWSER_AUTOFILL_FORM_SUGGESTION_PROVIDER_H_