1 // Copyright 2013 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 COMPONENTS_AUTOFILL_IOS_BROWSER_JS_AUTOFILL_MANAGER_H_
6 #define COMPONENTS_AUTOFILL_IOS_BROWSER_JS_AUTOFILL_MANAGER_H_
8 #include "base/ios/block_types.h"
9 #include "components/autofill/core/common/autofill_constants.h"
10 #import "ios/web/public/web_state/js/crw_js_injection_manager.h"
12 @
class CRWJSInjectionReceiver
;
14 // Loads the JavaScript file, autofill_controller.js, which contains form
15 // parsing and autofill functions.
16 @interface JsAutofillManager
: CRWJSInjectionManager
18 // Extracts forms from a web page. Only forms with at least |requiredFields|
19 // fields are extracted.
20 // |completionHandler| is called with the JSON string of forms of a web page.
21 // |completionHandler| cannot be nil.
22 - (void)fetchFormsWithMinimumRequiredFieldsCount
:(NSUInteger
)requiredFieldsCount
24 (void (^)(NSString
*))completionHandler
;
26 // Stores the current active element. This is used to make the element active
27 // again in case the web view loses focus when a dialog is presented over it.
28 - (void)storeActiveElement
;
30 // Clears the current active element.
31 - (void)clearActiveElement
;
33 // Fills the data in JSON string |dataString| into the active form field, then
34 // executes the |completionHandler|. The active form field is either
35 // document.activeElement or the field stored by a call to storeActiveElement.
37 - (void)fillActiveFormField
:(NSString
*)dataString
38 completionHandler
:(ProceduralBlock
)completionHandler
;
40 // Fills a number of fields in the same named form for full-form Autofill.
41 // Applies Autofill CSS (i.e. yellow background) to filled elements.
42 // Only empty fields will be filled, except that field named
43 // |forceFillFieldName| will always be filled even if non-empty.
44 // |forceFillFieldName| may be null.
45 // |completionHandler| is called after the forms are filled. |completionHandler|
47 - (void)fillForm
:(NSString
*)dataString
48 forceFillFieldName
:(NSString
*)forceFillFieldName
49 completionHandler
:(ProceduralBlock
)completionHandler
;
51 // Clear autofilled fields of the specified form. Fields that are not currently
52 // autofilled are not modified. Field contents are cleared, and Autofill flag
53 // and styling are removed. 'change' events are sent for fields whose contents
55 // |completionHandler| is called after the forms are filled. |completionHandler|
57 - (void)clearAutofilledFieldsForFormNamed
:(NSString
*)formName
58 completionHandler
:(ProceduralBlock
)completionHandler
;
60 // Marks up the form with autofill field prediction data (diagnostic tool).
61 - (void)fillPredictionData
:(NSString
*)dataString
;
65 #endif // COMPONENTS_AUTOFILL_IOS_BROWSER_JS_AUTOFILL_MANAGER_H_