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 and the appropriate attribute requirements are extracted. | 19 // fields and the appropriate attribute requirements 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)fetchFormsWithRequirements:(autofill::RequirementsMask)requirements | 22 - (void)fetchFormsWithRequirements:(autofill::RequirementsMask)requirements |
23 minimumRequiredFieldsCount:(NSUInteger)requiredFieldsCount | 23 minimumRequiredFieldsCount:(NSUInteger)requiredFieldsCount |
24 completionHandler:(void (^)(NSString*))completionHandler; | 24 completionHandler:(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 |
26 // Fills the data in JSON string |dataString| into the active form field, then | 33 // Fills the data in JSON string |dataString| into the active form field, then |
27 // executes the |completionHandler|. | 34 // executes the |completionHandler|. The active form field is either |
| 35 // document.activeElement or the field stored by a call to storeActiveElement. |
| 36 // non-null. |
28 - (void)fillActiveFormField:(NSString*)dataString | 37 - (void)fillActiveFormField:(NSString*)dataString |
29 completionHandler:(ProceduralBlock)completionHandler; | 38 completionHandler:(ProceduralBlock)completionHandler; |
30 | 39 |
31 // Fills a number of fields in the same named form. | 40 // Fills a number of fields in the same named form. |
32 // |completionHandler| is called after the forms are filled. |completionHandler| | 41 // |completionHandler| is called after the forms are filled. |completionHandler| |
33 // cannot be nil. | 42 // cannot be nil. |
34 - (void)fillForm:(NSString*)dataString | 43 - (void)fillForm:(NSString*)dataString |
35 completionHandler:(ProceduralBlock)completionHandler; | 44 completionHandler:(ProceduralBlock)completionHandler; |
36 | 45 |
37 // Dispatches the autocomplete event to the form element with the given | 46 // Dispatches the autocomplete event to the form element with the given |
38 // |formName|. | 47 // |formName|. |
39 - (void)dispatchAutocompleteEvent:(NSString*)formName; | 48 - (void)dispatchAutocompleteEvent:(NSString*)formName; |
40 | 49 |
41 // Dispatches the autocomplete error event to the form element with the given | 50 // Dispatches the autocomplete error event to the form element with the given |
42 // |formName|, supplying the given reason. | 51 // |formName|, supplying the given reason. |
43 - (void)dispatchAutocompleteErrorEvent:(NSString*)formName | 52 - (void)dispatchAutocompleteErrorEvent:(NSString*)formName |
44 withReason:(NSString*)reason; | 53 withReason:(NSString*)reason; |
45 | 54 |
46 // Marks up the form with autofill field prediction data (diagnostic tool). | 55 // Marks up the form with autofill field prediction data (diagnostic tool). |
47 - (void)fillPredictionData:(NSString*)dataString; | 56 - (void)fillPredictionData:(NSString*)dataString; |
48 | 57 |
49 @end | 58 @end |
50 | 59 |
51 #endif // COMPONENTS_AUTOFILL_IOS_BROWSER_JS_AUTOFILL_MANAGER_H_ | 60 #endif // COMPONENTS_AUTOFILL_IOS_BROWSER_JS_AUTOFILL_MANAGER_H_ |
OLD | NEW |