Commit 34464892 authored by Christian Dullweber's avatar Christian Dullweber Committed by Commit Bot

Migrate HistoryServiceObserver::OnUrlsDeleted

Change HistoryServiceObservers to use the new OnUrlsDeleted method.

Bug: 839798
Change-Id: Ibc62d194a7905e2fe357c098e77dd5db486e89ff
Reviewed-on: https://chromium-review.googlesource.com/1059250Reviewed-by: default avatarJan Krcal <jkrcal@chromium.org>
Reviewed-by: default avatarKaran Bhatia <karandeepb@chromium.org>
Reviewed-by: default avatarSteven Holte <holte@chromium.org>
Reviewed-by: default avatarVarun Khaneja <vakh@chromium.org>
Commit-Queue: Christian Dullweber <dullweber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#559009}
parent e4deae52
......@@ -149,16 +149,14 @@ void HistoryEventRouter::OnURLVisited(history::HistoryService* history_service,
api::history::OnVisited::kEventName, std::move(args));
}
void HistoryEventRouter::OnURLsDeleted(history::HistoryService* history_service,
bool all_history,
bool expired,
const history::URLRows& deleted_rows,
const std::set<GURL>& favicon_urls) {
void HistoryEventRouter::OnURLsDeleted(
history::HistoryService* history_service,
const history::DeletionInfo& deletion_info) {
OnVisitRemoved::Removed removed;
removed.all_history = all_history;
removed.all_history = deletion_info.IsAllHistory();
std::vector<std::string>* urls = new std::vector<std::string>();
for (const auto& row : deleted_rows)
for (const auto& row : deletion_info.deleted_rows())
urls->push_back(row.url().spec());
removed.urls.reset(urls);
......
......@@ -46,10 +46,7 @@ class HistoryEventRouter : public history::HistoryServiceObserver {
const history::RedirectList& redirects,
base::Time visit_time) override;
void OnURLsDeleted(history::HistoryService* history_service,
bool all_history,
bool expired,
const history::URLRows& deleted_rows,
const std::set<GURL>& favicon_urls) override;
const history::DeletionInfo& deletion_info) override;
void DispatchEvent(Profile* profile,
events::HistogramValue histogram_value,
......
......@@ -534,16 +534,13 @@ void ContentSuggestionsService::OnPrimaryAccountCleared(
// history::HistoryServiceObserver implementation.
void ContentSuggestionsService::OnURLsDeleted(
history::HistoryService* history_service,
bool all_history,
bool expired,
const history::URLRows& deleted_rows,
const std::set<GURL>& favicon_urls) {
const history::DeletionInfo& deletion_info) {
// We don't care about expired entries.
if (expired) {
if (deletion_info.is_from_expiration()) {
return;
}
if (all_history) {
if (deletion_info.IsAllHistory()) {
base::Callback<bool(const GURL& url)> filter =
base::Bind([](const GURL& url) { return true; });
ClearHistory(base::Time(), base::Time::Max(), filter);
......@@ -554,11 +551,11 @@ void ContentSuggestionsService::OnURLsDeleted(
// basis. However this depends on the provider's details and thus cannot be
// done here. Introduce a OnURLsDeleted() method on the providers to move
// this decision further down.
if (deleted_rows.size() < 2) {
if (deletion_info.deleted_rows().size() < 2) {
return;
}
std::set<GURL> deleted_urls;
for (const history::URLRow& row : deleted_rows) {
for (const history::URLRow& row : deletion_info.deleted_rows()) {
deleted_urls.insert(row.url());
}
base::Callback<bool(const GURL& url)> filter =
......
......@@ -294,10 +294,7 @@ class ContentSuggestionsService : public KeyedService,
// history::HistoryServiceObserver implementation.
void OnURLsDeleted(history::HistoryService* history_service,
bool all_history,
bool expired,
const history::URLRows& deleted_rows,
const std::set<GURL>& favicon_urls) override;
const history::DeletionInfo& deletion_info) override;
void HistoryServiceBeingDeleted(
history::HistoryService* history_service) override;
......
......@@ -576,8 +576,7 @@ TEST_F(ContentSuggestionsServiceTest, ShouldForwardDeleteAllHistoryURLs) {
MakeRegisteredMockProvider(category);
EXPECT_CALL(*provider, ClearHistory(base::Time(), base::Time::Max(), _));
static_cast<history::HistoryServiceObserver*>(service())->OnURLsDeleted(
/*history_service=*/nullptr, /*all_history=*/true, /*expired=*/false,
history::URLRows(), /*favicon_urls=*/std::set<GURL>());
/*history_service=*/nullptr, history::DeletionInfo::ForAllHistory());
service()->RemoveObserver(&observer);
}
......@@ -590,15 +589,19 @@ TEST_F(ContentSuggestionsServiceTest, ShouldIgnoreExpiredURLDeletions) {
service()->AddObserver(&observer);
static_cast<history::HistoryServiceObserver*>(service())->OnURLsDeleted(
/*history_service=*/nullptr, /*all_history=*/true,
/*expired=*/true, history::URLRows(),
/*favicon_urls=*/std::set<GURL>());
/*history_service=*/nullptr,
history::DeletionInfo(history::DeletionTimeRange::AllTime(),
/*expired=*/true, history::URLRows(),
/*favicon_urls=*/std::set<GURL>(),
/*restrict_urls=*/base::nullopt));
static_cast<history::HistoryServiceObserver*>(service())->OnURLsDeleted(
/*history_service=*/nullptr, /*all_history=*/false,
/*expired=*/true,
history::URLRows({history::URLRow(GURL("http://google.com")),
history::URLRow(GURL("http://maps.google.com"))}),
/*favicon_urls=*/std::set<GURL>());
/*history_service=*/nullptr,
history::DeletionInfo(history::DeletionTimeRange::Invalid(),
/*expired=*/true,
{history::URLRow(GURL("http://google.com")),
history::URLRow(GURL("http://maps.google.com"))},
/*favicon_urls=*/std::set<GURL>(),
/*restrict_urls=*/base::nullopt));
service()->RemoveObserver(&observer);
}
......@@ -607,9 +610,7 @@ TEST_F(ContentSuggestionsServiceTest, ShouldIgnoreEmptyURLDeletions) {
Category category = Category::FromKnownCategory(KnownCategories::DOWNLOADS);
MakeRegisteredMockProvider(category);
static_cast<history::HistoryServiceObserver*>(service())->OnURLsDeleted(
/*history_service=*/nullptr, /*all_history=*/false,
/*expired=*/false, history::URLRows(),
/*favicon_urls=*/std::set<GURL>());
/*history_service=*/nullptr, history::DeletionInfo::ForUrls({}, {}));
}
TEST_F(ContentSuggestionsServiceTest,
......@@ -618,10 +619,10 @@ TEST_F(ContentSuggestionsServiceTest,
MakeRegisteredMockProvider(category);
// Single URLs should not trigger
static_cast<history::HistoryServiceObserver*>(service())->OnURLsDeleted(
/*history_service=*/nullptr, /*all_history=*/false,
/*expired=*/false,
history::URLRows({history::URLRow(GURL("http://google.com"))}),
/*favicon_urls=*/std::set<GURL>());
/*history_service=*/nullptr,
history::DeletionInfo::ForUrls(
{history::URLRow(GURL("http://google.com"))},
/*favicon_urls=*/std::set<GURL>()));
}
TEST_F(ContentSuggestionsServiceTest,
......@@ -636,11 +637,11 @@ TEST_F(ContentSuggestionsServiceTest,
EXPECT_CALL(*provider, ClearHistory(base::Time(), base::Time::Max(), _));
static_cast<history::HistoryServiceObserver*>(service())->OnURLsDeleted(
/*history_service=*/nullptr, /*all_history=*/false,
/*expired=*/false,
history::URLRows({history::URLRow(GURL("http://google.com")),
history::URLRow(GURL("http://youtube.com"))}),
/*favicon_urls=*/std::set<GURL>());
/*history_service=*/nullptr,
history::DeletionInfo::ForUrls(
{history::URLRow(GURL("http://google.com")),
history::URLRow(GURL("http://youtube.com"))},
/*favicon_urls=*/std::set<GURL>()));
service()->RemoveObserver(&observer);
}
......
......@@ -559,19 +559,18 @@ void PasswordProtectionService::FillUserPopulation(
void PasswordProtectionService::OnURLsDeleted(
history::HistoryService* history_service,
bool all_history,
bool expired,
const history::URLRows& deleted_rows,
const std::set<GURL>& favicon_urls) {
const history::DeletionInfo& deletion_info) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&PasswordProtectionService::RemoveContentSettingsOnURLsDeleted,
GetWeakPtr(), all_history, deleted_rows));
GetWeakPtr(), deletion_info.IsAllHistory(),
deletion_info.deleted_rows()));
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&PasswordProtectionService::
RemoveUnhandledSyncPasswordReuseOnURLsDeleted,
GetWeakPtr(), all_history, deleted_rows));
GetWeakPtr(), deletion_info.IsAllHistory(),
deletion_info.deleted_rows()));
}
void PasswordProtectionService::HistoryServiceBeingDeleted(
......
......@@ -362,10 +362,7 @@ class PasswordProtectionService : public history::HistoryServiceObserver {
// Overridden from history::HistoryServiceObserver.
void OnURLsDeleted(history::HistoryService* history_service,
bool all_history,
bool expired,
const history::URLRows& deleted_rows,
const std::set<GURL>& favicon_urls) override;
const history::DeletionInfo& deletion_info) override;
void HistoryServiceBeingDeleted(
history::HistoryService* history_service) override;
......
......@@ -21,11 +21,8 @@ void HistoryDeleteObserver::ObserveServiceForDeletions(
void HistoryDeleteObserver::OnURLsDeleted(
history::HistoryService* history_service,
bool all_history,
bool expired,
const history::URLRows& deleted_rows,
const std::set<GURL>& favicon_urls) {
if (!expired)
const history::DeletionInfo& deletion_info) {
if (!deletion_info.is_from_expiration())
OnHistoryDeleted();
}
......
......@@ -24,10 +24,7 @@ class HistoryDeleteObserver : public history::HistoryServiceObserver {
// history::HistoryServiceObserver
void OnURLsDeleted(history::HistoryService* history_service,
bool all_history,
bool expired,
const history::URLRows& deleted_rows,
const std::set<GURL>& favicon_urls) override;
const history::DeletionInfo& deletion_info) override;
void HistoryServiceBeingDeleted(
history::HistoryService* history_service) override;
......
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