| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 completionHandler(); | 71 completionHandler(); |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 NSString* js = | 74 NSString* js = |
| 75 [NSString stringWithFormat:@"__gCrWeb.autofill.fillActiveFormField(%@);", | 75 [NSString stringWithFormat:@"__gCrWeb.autofill.fillActiveFormField(%@);", |
| 76 dataString]; | 76 dataString]; |
| 77 [self evaluate:js stringResultHandler:resultHandler]; | 77 [self evaluate:js stringResultHandler:resultHandler]; |
| 78 } | 78 } |
| 79 | 79 |
| 80 - (void)fillForm:(NSString*)dataString | 80 - (void)fillForm:(NSString*)dataString |
| 81 styleElements:(BOOL)styleElements | 81 onlyFillEmpty:(BOOL)onlyFillEmpty |
| 82 completionHandler:(ProceduralBlock)completionHandler { | 82 forceFillFieldName:(NSString*)forceFillFieldName |
| 83 styleElements:(BOOL)styleElements |
| 84 completionHandler:(ProceduralBlock)completionHandler { |
| 83 DCHECK(completionHandler); | 85 DCHECK(completionHandler); |
| 84 NSString* fillFormJS = | 86 std::string fieldName = |
| 85 [NSString stringWithFormat:@"__gCrWeb.autofill.fillForm(%@, %s);", | 87 forceFillFieldName |
| 86 dataString, styleElements ? "true" : "false"]; | 88 ? base::GetQuotedJSONString([forceFillFieldName UTF8String]) |
| 89 : "null"; |
| 90 NSString* fillFormJS = [NSString |
| 91 stringWithFormat:@"__gCrWeb.autofill.fillForm(%@, %s, %s, %s);", |
| 92 dataString, onlyFillEmpty ? "true" : "false", |
| 93 fieldName.c_str(), styleElements ? "true" : "false"]; |
| 87 id stringResultHandler = ^(NSString*, NSError*) { | 94 id stringResultHandler = ^(NSString*, NSError*) { |
| 88 completionHandler(); | 95 completionHandler(); |
| 89 }; | 96 }; |
| 90 return [self evaluate:fillFormJS stringResultHandler:stringResultHandler]; | 97 return [self evaluate:fillFormJS stringResultHandler:stringResultHandler]; |
| 91 } | 98 } |
| 92 | 99 |
| 93 - (void)dispatchAutocompleteEvent:(NSString*)formName { | 100 - (void)dispatchAutocompleteEvent:(NSString*)formName { |
| 94 NSString* dispatchAutocompleteEventJS = [NSString | 101 NSString* dispatchAutocompleteEventJS = [NSString |
| 95 stringWithFormat:@"__gCrWeb.autofill.dispatchAutocompleteEvent(%s);", | 102 stringWithFormat:@"__gCrWeb.autofill.dispatchAutocompleteEvent(%s);", |
| 96 base::GetQuotedJSONString([formName UTF8String]) | 103 base::GetQuotedJSONString([formName UTF8String]) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 109 } | 116 } |
| 110 | 117 |
| 111 - (void)fillPredictionData:(NSString*)dataString { | 118 - (void)fillPredictionData:(NSString*)dataString { |
| 112 [self deferredEvaluate: | 119 [self deferredEvaluate: |
| 113 [NSString | 120 [NSString |
| 114 stringWithFormat:@"__gCrWeb.autofill.fillPredictionData(%@);", | 121 stringWithFormat:@"__gCrWeb.autofill.fillPredictionData(%@);", |
| 115 dataString]]; | 122 dataString]]; |
| 116 } | 123 } |
| 117 | 124 |
| 118 @end | 125 @end |
| OLD | NEW |