Commit 642461c7 authored by John Z Wu's avatar John Z Wu Committed by Commit Bot

Update API for removing suggestions.

Add a return value to indicate if suggestion was allowed. Also fix
associated test.

Bug: 898990
Change-Id: I22f00cef28dc5a82d431cc49191e956e47cd5e40
Reviewed-on: https://chromium-review.googlesource.com/c/1341148Reviewed-by: default avatarHiroshi Ichikawa <ichikawa@chromium.org>
Commit-Queue: John Wu <jzw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609175}
parent 87c17220
......@@ -302,7 +302,7 @@ fetchNonPasswordSuggestionsForFormWithName:(NSString*)formName
}
}
- (void)removeSuggestion:(CWVAutofillSuggestion*)suggestion {
- (BOOL)removeSuggestion:(CWVAutofillSuggestion*)suggestion {
// Identifier is greater than 0 for Autofill suggestions.
DCHECK_LT(0, suggestion.formSuggestion.identifier);
......@@ -310,9 +310,9 @@ fetchNonPasswordSuggestionsForFormWithName:(NSString*)formName
_webState, base::SysNSStringToUTF8(suggestion.frameID));
autofill::AutofillManager* manager = [self autofillManagerForFrame:frame];
if (!manager) {
return;
return NO;
}
manager->RemoveAutofillProfileOrCreditCard(
return manager->RemoveAutofillProfileOrCreditCard(
suggestion.formSuggestion.identifier);
}
......
......@@ -62,9 +62,10 @@ CWV_EXPORT
- (void)fillSuggestion:(CWVAutofillSuggestion*)suggestion
completionHandler:(nullable void (^)(void))completionHandler;
// Deletes a suggestion from the data store. This suggestion will not be fetched
// again.
- (void)removeSuggestion:(CWVAutofillSuggestion*)suggestion;
// Deletes a suggestion from the data store.
// Returns YES if suggestion exists and can be deleted.
// Note that it may take a short while before |suggestion| is no longer fetched.
- (BOOL)removeSuggestion:(CWVAutofillSuggestion*)suggestion;
// Changes focus to the previous sibling of the currently focused field.
// No-op if no field is currently focused or if previous field is not available.
......
......@@ -270,8 +270,7 @@ TEST_F(WebViewAutofillTest, TestSuggestionFetchFillClear) {
}
// Tests that CWVAutofillController can remove a suggestion.
TEST_F(WebViewAutofillTest, DISABLED_TestSuggestionFetchRemoveFetch) {
// TODO(crbug.com/898990): Needs to be reenabled.
TEST_F(WebViewAutofillTest, TestSuggestionFetchRemoveFetch) {
ASSERT_TRUE(test_server_->Start());
ASSERT_TRUE(LoadTestPage());
ASSERT_TRUE(SetFormFieldValue(kTestNameFieldID, kTestNameFieldValue));
......@@ -287,10 +286,11 @@ TEST_F(WebViewAutofillTest, DISABLED_TestSuggestionFetchRemoveFetch) {
CWVAutofillSuggestion* suggestion_to_remove =
fetched_suggestions_after_creating.firstObject;
[autofill_controller_ removeSuggestion:suggestion_to_remove];
EXPECT_TRUE([autofill_controller_ removeSuggestion:suggestion_to_remove]);
NSArray* fetched_suggestions_after_removing = FetchSuggestions();
ASSERT_EQ(0U, fetched_suggestions_after_removing.count);
EXPECT_TRUE(WaitUntilConditionOrTimeout(kWaitForActionTimeout, ^bool {
return FetchSuggestions().count == 0;
}));
}
} // namespace ios_web_view
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment