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_CONTROLLER_H_
6 #define IOS_CHROME_BROWSER_AUTOFILL_FORM_SUGGESTION_CONTROLLER_H_
8 #import <UIKit/UIKit.h>
12 #import "components/autofill/ios/browser/js_suggestion_manager.h"
13 #import "ios/chrome/browser/autofill/form_suggestion_view.h"
14 #import "ios/chrome/browser/autofill/form_suggestion_view_client.h"
15 #import "ios/web/public/web_state/web_state_observer_bridge.h"
21 @protocol CRWWebViewProxy
;
22 @protocol FormInputAccessoryViewProvider
;
24 // Handles form focus events and presents input suggestions.
25 @interface FormSuggestionController
26 : NSObject
<CRWWebStateObserver
, FormSuggestionViewClient
>
28 // Initializes a new FormSuggestionController with the specified WebState and a
29 // list of FormSuggestionProviders.
30 // When suggestions are required for an input field, the |providers| will be
31 // asked (in order) if they can handle the field; the first provider to return
32 // YES from [FormSuggestionProvider canProviderSuggestionsForForm:field:] will
33 // be expected to provide those suggestions using [FormSuggestionProvider
34 // retrieveSuggestionsForForm:field:withCompletion:].
35 - (instancetype
)initWithWebState
:(web::WebState
*)webState
36 providers
:(NSArray
*)providers
;
38 // Instructs the controller to detach itself from the WebState.
39 - (void)detachFromWebState
;
41 // Provides an input accessory view for form suggestions.
42 @
property(nonatomic
, readonly
)
43 id
<FormInputAccessoryViewProvider
> accessoryViewProvider
;
47 @interface
FormSuggestionController (ForTesting
)
49 // Initializes a new controller in the same way as the public initializer, but
50 // supports specifying a JsSuggestionManager for testing.
51 - (instancetype
)initWithWebState
:(web::WebState
*)webState
52 providers
:(NSArray
*)providers
53 JsSuggestionManager
:(JsSuggestionManager
*)jsSuggestionManager
;
55 // Overrides the web view proxy.
56 - (void)setWebViewProxy
:(id
<CRWWebViewProxy
>)webViewProxy
;
60 #endif // IOS_CHROME_BROWSER_AUTOFILL_FORM_SUGGESTION_CONTROLLER_H_