Revert "Fix broken channel icon in chrome://help on CrOS" and try again
[chromium-blink-merge.git] / ios / chrome / browser / autofill / form_input_accessory_view_controller.h
blob03a474e0a5f314389ce3b8101c9db6339dd1de8a
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_INPUT_ACCESSORY_VIEW_CONTROLLER_H_
6 #define IOS_CHROME_BROWSER_AUTOFILL_FORM_INPUT_ACCESSORY_VIEW_CONTROLLER_H_
8 #import <UIKit/UIKit.h>
10 #import "ios/chrome/browser/autofill/form_input_accessory_view_delegate.h"
11 #import "ios/web/public/web_state/web_state_observer_bridge.h"
13 @protocol CRWWebViewProxy;
15 namespace autofill {
16 extern NSString* const kFormSuggestionAssistButtonPreviousElement;
17 extern NSString* const kFormSuggestionAssistButtonNextElement;
18 extern NSString* const kFormSuggestionAssistButtonDone;
19 extern CGFloat const kInputAccessoryHeight;
20 } // namespace autofill
22 @protocol FormInputAccessoryViewProvider;
23 @class FormInputAccessoryViewController;
25 // Block type to indicate that a FormInputAccessoryViewProvider has an accessory
26 // view to provide.
27 typedef void (^AccessoryViewAvailableCompletion)(
28 BOOL inputAccessoryViewAvailable);
30 // Block type to provide an accessory view asynchronously.
31 typedef void (^AccessoryViewReadyCompletion)(
32 UIView* view,
33 id<FormInputAccessoryViewProvider> provider);
35 // Represents an object that can provide a custom keyboard input accessory view.
36 @protocol FormInputAccessoryViewProvider<NSObject>
38 // A delegate for form navigation.
39 @property(nonatomic, assign)
40 id<FormInputAccessoryViewDelegate> accessoryViewDelegate;
42 // Determines asynchronously if this provider has a view available for the
43 // specified form/field and invokes |completionHandler| with the answer.
44 - (void)
45 checkIfAccessoryViewIsAvailableForFormNamed:(const std::string&)formName
46 fieldName:(const std::string&)fieldName
47 webState:(web::WebState*)webState
48 completionHandler:
49 (AccessoryViewAvailableCompletion)
50 completionHandler;
52 // Asynchronously retrieves an accessory view from this provider for the
53 // specified form/field and returns it via |accessoryViewUpdateBlock|.
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 accessoryViewUpdateBlock:
60 (AccessoryViewReadyCompletion)accessoryViewUpdateBlock;
62 // Notifies this provider that the accessory view is going away.
63 - (void)inputAccessoryViewControllerDidReset:
64 (FormInputAccessoryViewController*)controller;
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 // set using |accessoryViewUpdateBlock|.
69 - (void)resizeAccessoryView;
71 @end
73 // Creates and manages a custom input accessory view while the user is
74 // interacting with a form. Also handles hiding and showing the default
75 // accessory view elements.
76 @interface FormInputAccessoryViewController
77 : NSObject<CRWWebStateObserver, FormInputAccessoryViewDelegate>
79 // Initializes a new controller with the specified |providers| of input
80 // accessory views.
81 - (instancetype)initWithWebState:(web::WebState*)webState
82 providers:(NSArray*)providers;
84 // Notifies the controller that the owning tab was shown.
85 - (void)wasShown;
87 // Notifies the controller that the owning tab was hidden.
88 - (void)wasHidden;
90 // Hides the default input accessory view and replaces it with one that shows
91 // |customView| and form navigation controls.
92 - (void)showCustomInputAccessoryView:(UIView*)customView;
94 // Restores the default input accessory view, removing (if necessary) any
95 // previously-added custom view.
96 - (void)restoreDefaultInputAccessoryView;
98 @end
100 #endif // IOS_CHROME_BROWSER_AUTOFILL_FORM_INPUT_ACCESSORY_VIEW_CONTROLLER_H_