Index: components/ntp_snippets/content_suggestions_service.cc |
diff --git a/components/ntp_snippets/content_suggestions_service.cc b/components/ntp_snippets/content_suggestions_service.cc |
index c1977e50c8767454c388edfb5c1b7d1a5de75e82..6f75814f565ff9c1e566d3d9816ddc0dc8acbeff 100644 |
--- a/components/ntp_snippets/content_suggestions_service.cc |
+++ b/components/ntp_snippets/content_suggestions_service.cc |
@@ -15,8 +15,14 @@ |
namespace ntp_snippets { |
-ContentSuggestionsService::ContentSuggestionsService(State state) |
- : state_(state) {} |
+ContentSuggestionsService::ContentSuggestionsService( |
+ State state, |
+ history::HistoryService* history_service) |
+ : state_(state), history_service_observer_(this) { |
+ // Can be null in tests. |
+ if (history_service) |
+ history_service_observer_.Add(history_service); |
+} |
ContentSuggestionsService::~ContentSuggestionsService() {} |
@@ -230,6 +236,30 @@ void ContentSuggestionsService::OnSuggestionInvalidated( |
OnSuggestionInvalidated(category, suggestion_id)); |
} |
+// 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) { |
+ if (expired) |
Marc Treib
2016/09/02 12:57:10
Add a comment, like we had in NTPSnippetsService?
vitaliii
2016/09/02 14:13:17
Done.
|
+ return; |
+ |
+ std::vector<GURL> deleted_urls; |
+ for (const history::URLRow& row : deleted_rows) { |
+ deleted_urls.emplace_back(row.url()); |
Marc Treib
2016/09/02 12:57:10
nit: push_back, since it has to make a copy anyway
vitaliii
2016/09/02 14:13:17
Acknowledged.
|
+ } |
+ for (const auto& provider : providers_) { |
+ provider->RemoveURLsFromHistory(all_history, deleted_urls); |
+ } |
+} |
+ |
+void ContentSuggestionsService::HistoryServiceBeingDeleted( |
+ history::HistoryService* history_service) { |
+ history_service_observer_.RemoveAll(); |
+} |
+ |
bool ContentSuggestionsService::RegisterCategoryIfRequired( |
ContentSuggestionsProvider* provider, |
Category category) { |