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 #import "components/autofill/ios/browser/js_autofill_manager.h" | 5 #import "components/autofill/ios/browser/js_autofill_manager.h" |
6 | 6 |
7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
8 #include "base/json/string_escape.h" | 8 #include "base/json/string_escape.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 #pragma mark ProtectedMethods | 27 #pragma mark ProtectedMethods |
28 | 28 |
29 - (NSString*)scriptPath { | 29 - (NSString*)scriptPath { |
30 return @"autofill_controller"; | 30 return @"autofill_controller"; |
31 } | 31 } |
32 | 32 |
33 - (NSString*)presenceBeacon { | 33 - (NSString*)presenceBeacon { |
34 return @"__gCrWeb.autofill"; | 34 return @"__gCrWeb.autofill"; |
35 } | 35 } |
36 | 36 |
37 - (void)storeActiveElement { | |
38 NSString* js = @"__gCrWeb.autofill.storeActiveElement()"; | |
39 [self evaluate:js stringResultHandler:nil]; | |
40 } | |
41 | |
42 - (void)clearActiveElement { | |
43 NSString* js = @"__gCrWeb.autofill.clearActiveElement()"; | |
44 [self evaluate:js stringResultHandler:nil]; | |
45 } | |
46 | |
47 - (void)fillActiveFormField:(NSString*)dataString | 37 - (void)fillActiveFormField:(NSString*)dataString |
48 completionHandler:(ProceduralBlock)completionHandler { | 38 completionHandler:(ProceduralBlock)completionHandler { |
49 web::JavaScriptCompletion resultHandler = ^void(NSString*, NSError*) { | 39 web::JavaScriptCompletion resultHandler = ^void(NSString*, NSError*) { |
50 completionHandler(); | 40 completionHandler(); |
51 }; | 41 }; |
52 | 42 |
53 NSString* js = | 43 NSString* js = |
54 [NSString stringWithFormat:@"__gCrWeb.autofill.fillActiveFormField(%@);", | 44 [NSString stringWithFormat:@"__gCrWeb.autofill.fillActiveFormField(%@);", |
55 dataString]; | 45 dataString]; |
56 [self evaluate:js stringResultHandler:resultHandler]; | 46 [self evaluate:js stringResultHandler:resultHandler]; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 } | 78 } |
89 | 79 |
90 - (void)fillPredictionData:(NSString*)dataString { | 80 - (void)fillPredictionData:(NSString*)dataString { |
91 [self deferredEvaluate: | 81 [self deferredEvaluate: |
92 [NSString | 82 [NSString |
93 stringWithFormat:@"__gCrWeb.autofill.fillPredictionData(%@);", | 83 stringWithFormat:@"__gCrWeb.autofill.fillPredictionData(%@);", |
94 dataString]]; | 84 dataString]]; |
95 } | 85 } |
96 | 86 |
97 @end | 87 @end |
OLD | NEW |