Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Unified Diff: components/autofill/ios/browser/js_suggestion_manager.mm

Issue 2247973002: [ios] Use new JS execution API for Autofill. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/autofill/ios/browser/js_autofill_manager.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/ios/browser/js_suggestion_manager.mm
diff --git a/components/autofill/ios/browser/js_suggestion_manager.mm b/components/autofill/ios/browser/js_suggestion_manager.mm
index fb29f044b8467d708791063b51eedccb96e39158..1d415ce1a49ee38ab063eb009643b809840093de 100644
--- a/components/autofill/ios/browser/js_suggestion_manager.mm
+++ b/components/autofill/ios/browser/js_suggestion_manager.mm
@@ -35,7 +35,7 @@ NSString* JSONEscape(NSString* str) {
NSString* selectNextElementJS = [NSString
stringWithFormat:@"__gCrWeb.suggestion.selectNextElement(%@, %@)",
JSONEscape(formName), JSONEscape(fieldName)];
- [self evaluate:selectNextElementJS stringResultHandler:nil];
+ [self executeJavaScript:selectNextElementJS completionHandler:nil];
}
- (void)selectPreviousElement {
@@ -46,7 +46,7 @@ NSString* JSONEscape(NSString* str) {
NSString* selectPreviousElementJS = [NSString
stringWithFormat:@"__gCrWeb.suggestion.selectPreviousElement(%@, %@)",
JSONEscape(formName), JSONEscape(fieldName)];
- [self evaluate:selectPreviousElementJS stringResultHandler:nil];
+ [self executeJavaScript:selectPreviousElementJS completionHandler:nil];
}
- (void)fetchPreviousAndNextElementsPresenceWithCompletionHandler:
@@ -62,7 +62,15 @@ NSString* JSONEscape(NSString* str) {
(void (^)(BOOL, BOOL))completionHandler {
DCHECK(completionHandler);
DCHECK([self hasBeenInjected]);
- id stringResultHandler = ^(NSString* result, NSError* error) {
+ NSString* escapedFormName = JSONEscape(formName);
+ NSString* escapedFieldName = JSONEscape(fieldName);
+ NSString* JS = [NSString
+ stringWithFormat:@"[__gCrWeb.suggestion.hasPreviousElement(%@, %@),"
+ @"__gCrWeb.suggestion.hasNextElement(%@, %@)]"
+ @".toString()",
+ escapedFormName, escapedFieldName, escapedFormName,
+ escapedFieldName];
+ [self executeJavaScript:JS completionHandler:^(id result, NSError* error) {
// The result maybe an empty string here due to 2 reasons:
// 1) When there is an exception running the JS
// 2) There is a race when the page is changing due to which
@@ -85,16 +93,7 @@ NSString* JSONEscape(NSString* str) {
[components[1] isEqualToString:@"false"]);
BOOL hasNextElement = [components[1] isEqualToString:@"true"];
completionHandler(hasPreviousElement, hasNextElement);
- };
- NSString* escapedFormName = JSONEscape(formName);
- NSString* escapedFieldName = JSONEscape(fieldName);
- NSString* js = [NSString
- stringWithFormat:@"[__gCrWeb.suggestion.hasPreviousElement(%@, %@),"
- @"__gCrWeb.suggestion.hasNextElement(%@, %@)]"
- @".toString()",
- escapedFormName, escapedFieldName, escapedFormName,
- escapedFieldName];
- [self evaluate:js stringResultHandler:stringResultHandler];
+ }];
}
- (void)closeKeyboard {
« no previous file with comments | « components/autofill/ios/browser/js_autofill_manager.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698