Commit 49cdf9a2 authored by Anne Lim's avatar Anne Lim Committed by Commit Bot

[AF] ClearStrikes when ios browser data cleared

Clears all strikes in a profile's StrikeDatabase when Autofill
data is wiped out from Chrome Settings in iOS
(chrome://settings -> Clear Browsing Data -> Advanced ->
Autofill Form Data).

Bug: 884817
Change-Id: Ic5065176f58d3785b9636c32df150801f583bb7d
Reviewed-on: https://chromium-review.googlesource.com/c/1323795Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Reviewed-by: default avatarMartin Šrámek <msramek@chromium.org>
Reviewed-by: default avatarJared Saul <jsaul@google.com>
Commit-Queue: Anne Lim <annelim@google.com>
Cr-Commit-Position: refs/heads/master@{#607307}
parent ecdaaa93
......@@ -865,7 +865,8 @@ void ChromeBrowsingDataRemoverDelegate::RemoveEmbedderData(
autofill::StrikeDatabase* strike_database =
autofill::StrikeDatabaseFactory::GetForProfile(profile_);
if (strike_database)
strike_database->ClearAllStrikes(base::DoNothing());
strike_database->ClearAllStrikes(base::AdaptCallbackForRepeating(
IgnoreArgument<bool>(CreatePendingTaskCompletionClosure())));
// Ask for a call back when the above calls are finished.
web_data_service->GetDBTaskRunner()->PostTaskAndReply(
......
......@@ -23,6 +23,7 @@
#include "base/task/post_task.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "components/autofill/core/browser/personal_data_manager.h"
#include "components/autofill/core/browser/strike_database.h"
#include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
#include "components/history/core/browser/history_service.h"
#include "components/keyed_service/core/service_access_type.h"
......@@ -37,6 +38,7 @@
#include "components/signin/ios/browser/account_consistency_service.h"
#include "ios/chrome/browser/application_context.h"
#include "ios/chrome/browser/autofill/personal_data_manager_factory.h"
#include "ios/chrome/browser/autofill/strike_database_factory.h"
#include "ios/chrome/browser/bookmarks/bookmark_remover_helper.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/chrome/browser/browsing_data/browsing_data_remove_mask.h"
......@@ -84,6 +86,18 @@ enum CookieOrCacheDeletionChoice {
MAX_CHOICE_VALUE
};
template <typename T>
void IgnoreArgumentHelper(base::OnceClosure callback, T unused_argument) {
std::move(callback).Run();
}
// A convenience method to turn a callback without arguments into one that
// accepts (and ignores) a single argument.
template <typename T>
base::OnceCallback<void(T)> IgnoreArgument(base::OnceClosure callback) {
return base::BindOnce(&IgnoreArgumentHelper<T>, std::move(callback));
}
bool AllDomainsPredicate(const std::string& domain) {
return true;
}
......@@ -465,6 +479,13 @@ void BrowsingDataRemoverImpl::RemoveImpl(base::Time delete_begin,
web_data_service->RemoveAutofillDataModifiedBetween(delete_begin,
delete_end);
// Clear out the Autofill StrikeDatabase in its entirety.
autofill::StrikeDatabase* strike_database =
autofill::StrikeDatabaseFactory::GetForBrowserState(browser_state_);
if (strike_database)
strike_database->ClearAllStrikes(AdaptCallbackForRepeating(
IgnoreArgument<bool>(CreatePendingTaskCompletionClosure())));
// Ask for a call back when the above calls are finished.
web_data_service->GetDBTaskRunner()->PostTaskAndReply(
FROM_HERE, base::DoNothing(), CreatePendingTaskCompletionClosure());
......
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