OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_AUTOFILL_IOS_BROWSER_JS_AUTOFILL_MANAGER_H_ | 5 #ifndef COMPONENTS_AUTOFILL_IOS_BROWSER_JS_AUTOFILL_MANAGER_H_ |
6 #define COMPONENTS_AUTOFILL_IOS_BROWSER_JS_AUTOFILL_MANAGER_H_ | 6 #define COMPONENTS_AUTOFILL_IOS_BROWSER_JS_AUTOFILL_MANAGER_H_ |
7 | 7 |
8 #include "base/ios/block_types.h" | 8 #include "base/ios/block_types.h" |
9 #include "components/autofill/core/common/autofill_constants.h" | 9 #include "components/autofill/core/common/autofill_constants.h" |
10 #import "ios/web/public/web_state/js/crw_js_injection_manager.h" | 10 #import "ios/web/public/web_state/js/crw_js_injection_manager.h" |
11 | 11 |
12 @class CRWJSInjectionReceiver; | 12 @class CRWJSInjectionReceiver; |
13 | 13 |
14 // Loads the JavaScript file, autofill_controller.js, which contains form | 14 // Loads the JavaScript file, autofill_controller.js, which contains form |
15 // parsing and autofill functions. | 15 // parsing and autofill functions. |
16 @interface JsAutofillManager : CRWJSInjectionManager | 16 @interface JsAutofillManager : CRWJSInjectionManager |
17 | 17 |
18 // Extracts forms from a web page. Only forms with at least |requiredFields| | 18 // Extracts forms from a web page. Only forms with at least |requiredFields| |
19 // fields are extracted. | 19 // fields are extracted. |
20 // |completionHandler| is called with the JSON string of forms of a web page. | 20 // |completionHandler| is called with the JSON string of forms of a web page. |
21 // |completionHandler| cannot be nil. | 21 // |completionHandler| cannot be nil. |
22 - (void)fetchFormsWithMinimumRequiredFieldsCount:(NSUInteger)requiredFieldsCount | 22 - (void)fetchFormsWithMinimumRequiredFieldsCount:(NSUInteger)requiredFieldsCount |
23 completionHandler: | 23 completionHandler: |
24 (void (^)(NSString*))completionHandler; | 24 (void (^)(NSString*))completionHandler; |
25 | 25 |
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; | |
29 | |
30 // Clears the current active element. | |
31 - (void)clearActiveElement; | |
32 | |
33 // Fills the data in JSON string |dataString| into the active form field, then | 26 // Fills the data in JSON string |dataString| into the active form field, then |
34 // executes the |completionHandler|. The active form field is either | 27 // executes the |completionHandler|. |
35 // document.activeElement or the field stored by a call to storeActiveElement. | |
36 // non-null. | |
37 - (void)fillActiveFormField:(NSString*)dataString | 28 - (void)fillActiveFormField:(NSString*)dataString |
38 completionHandler:(ProceduralBlock)completionHandler; | 29 completionHandler:(ProceduralBlock)completionHandler; |
39 | 30 |
40 // Fills a number of fields in the same named form for full-form Autofill. | 31 // 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. | 32 // Applies Autofill CSS (i.e. yellow background) to filled elements. |
42 // Only empty fields will be filled, except that field named | 33 // Only empty fields will be filled, except that field named |
43 // |forceFillFieldName| will always be filled even if non-empty. | 34 // |forceFillFieldName| will always be filled even if non-empty. |
44 // |forceFillFieldName| may be null. | 35 // |forceFillFieldName| may be null. |
45 // |completionHandler| is called after the forms are filled. |completionHandler| | 36 // |completionHandler| is called after the forms are filled. |completionHandler| |
46 // cannot be nil. | 37 // cannot be nil. |
47 - (void)fillForm:(NSString*)dataString | 38 - (void)fillForm:(NSString*)dataString |
48 forceFillFieldName:(NSString*)forceFillFieldName | 39 forceFillFieldName:(NSString*)forceFillFieldName |
49 completionHandler:(ProceduralBlock)completionHandler; | 40 completionHandler:(ProceduralBlock)completionHandler; |
50 | 41 |
51 // Clear autofilled fields of the specified form. Fields that are not currently | 42 // Clear autofilled fields of the specified form. Fields that are not currently |
52 // autofilled are not modified. Field contents are cleared, and Autofill flag | 43 // autofilled are not modified. Field contents are cleared, and Autofill flag |
53 // and styling are removed. 'change' events are sent for fields whose contents | 44 // and styling are removed. 'change' events are sent for fields whose contents |
54 // changed. | 45 // changed. |
55 // |completionHandler| is called after the forms are filled. |completionHandler| | 46 // |completionHandler| is called after the forms are filled. |completionHandler| |
56 // cannot be nil. | 47 // cannot be nil. |
57 - (void)clearAutofilledFieldsForFormNamed:(NSString*)formName | 48 - (void)clearAutofilledFieldsForFormNamed:(NSString*)formName |
58 completionHandler:(ProceduralBlock)completionHandler; | 49 completionHandler:(ProceduralBlock)completionHandler; |
59 | 50 |
60 // Marks up the form with autofill field prediction data (diagnostic tool). | 51 // Marks up the form with autofill field prediction data (diagnostic tool). |
61 - (void)fillPredictionData:(NSString*)dataString; | 52 - (void)fillPredictionData:(NSString*)dataString; |
62 | 53 |
63 @end | 54 @end |
64 | 55 |
65 #endif // COMPONENTS_AUTOFILL_IOS_BROWSER_JS_AUTOFILL_MANAGER_H_ | 56 #endif // COMPONENTS_AUTOFILL_IOS_BROWSER_JS_AUTOFILL_MANAGER_H_ |
OLD | NEW |