1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_PASSWORDS_JS_PASSWORD_MANAGER_H_
#define IOS_CHROME_BROWSER_PASSWORDS_JS_PASSWORD_MANAGER_H_
#include "base/ios/block_types.h"
#import "ios/web/public/web_state/js/crw_js_injection_manager.h"
@class CRWJSInjectionReceiver;
// Loads the JavaScript file, password_controller.js, which contains password
// form parsing and autofill functions. It will be evaluated on a page that
// is known to have at least one password form (see hasPasswordForms in
// core.js.) It returns contents of those password forms and also
// registers functions that are later used to autofill them.
@interface JsPasswordManager : CRWJSInjectionManager
// Finds any password forms on the web page.
// |completionHandler| is then called with the JSON string result (which can
// be a zero-length string if there was an error). |completionHandler| cannot be
// nil.
// For example the JSON string for a form with a single password field is:
// [{"action":null,"method":null,"usernameElement":"","usernameValue":"","
// passwords":[{"element":"","value":"asd"}]}]
- (void)findPasswordFormsWithCompletionHandler:
(void (^)(NSString*))completionHandler;
// Extracts the password form with the given name from a web page.
// |completionHandler| is called with the JSON string containing the info about
// submitted password forms from a web page (it can be zero-length if there was
// an error). |completionHandler| cannot be nil.
// For example. the JSON string for a form with a single password field is:
// {"action":null,"method":null,"usernameElement":"","usernameValue":"",
// "passwords":[{"element":"","value":"asd"}]}
- (void)extractForm:(NSString*)formName
completionHandler:(void (^)(NSString*))completionHandler;
// Fills in the password form specified by |JSONString| with the given
// |username| and |password|. Assumes JavaScript has been injected previously
// by calling |findPasswordFormsWithCompletionHandle| or
// |extractSubmittedFormWithCompletionHandler|. Calls |completionHandler| with
// YES if the filling of the password was successful, NO otherwise.
// |completionHandler| cannot be nil.
- (void)fillPasswordForm:(NSString*)JSONString
withUsername:(NSString*)username
password:(NSString*)password
completionHandler:(void (^)(BOOL))completionHandler;
// Clears autofilled credentials in the specified form. Invokes
// |completionHandler| with YES if successful and NO otherwise.
- (void)clearAutofilledPasswordsInForm:(NSString*)formName
completionHandler:(void (^)(BOOL))completionHandler;
// Fills all password fields in the form identified by |formName| with
// |password| and invokes |completionHandler| with true if any fields were
// filled.
- (void)fillPasswordForm:(NSString*)formName
withGeneratedPassword:(NSString*)password
completionHandler:(void (^)(BOOL))completionHandler;
@end
#endif // IOS_CHROME_BROWSER_PASSWORDS_JS_PASSWORD_MANAGER_H_
|