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

Side by Side Diff: components/ntp_snippets/offline_pages/recent_tab_suggestions_provider.cc

Issue 2513393002: [NTP] Cleanup: offline pages related tests. (Closed)
Patch Set: rebase + treib@ comment. Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/ntp_snippets/download_suggestions_provider_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/ntp_snippets/offline_pages/recent_tab_suggestions_provider. h" 5 #include "components/ntp_snippets/offline_pages/recent_tab_suggestions_provider. h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 136
137 void RecentTabSuggestionsProvider::ClearCachedSuggestions(Category category) { 137 void RecentTabSuggestionsProvider::ClearCachedSuggestions(Category category) {
138 // Ignored. 138 // Ignored.
139 } 139 }
140 140
141 void RecentTabSuggestionsProvider::GetDismissedSuggestionsForDebugging( 141 void RecentTabSuggestionsProvider::GetDismissedSuggestionsForDebugging(
142 Category category, 142 Category category,
143 const DismissedSuggestionsCallback& callback) { 143 const DismissedSuggestionsCallback& callback) {
144 DCHECK_EQ(provided_category_, category); 144 DCHECK_EQ(provided_category_, category);
145 145
146 // TODO(vitaliii): Query all pages instead by using an empty query. 146 // Offline pages which are not related to recent tabs are also queried here,
147 // so that they can be returned if they happen to be dismissed (e.g. due to a
148 // bug).
149 OfflinePageModelQueryBuilder query_builder;
147 offline_page_model_->GetPagesMatchingQuery( 150 offline_page_model_->GetPagesMatchingQuery(
148 BuildRecentTabsQuery(offline_page_model_), 151 query_builder.Build(offline_page_model_->GetPolicyController()),
149 base::Bind(&RecentTabSuggestionsProvider:: 152 base::Bind(&RecentTabSuggestionsProvider::
150 GetPagesMatchingQueryCallbackForGetDismissedSuggestions, 153 GetPagesMatchingQueryCallbackForGetDismissedSuggestions,
151 weak_ptr_factory_.GetWeakPtr(), callback)); 154 weak_ptr_factory_.GetWeakPtr(), callback));
152 } 155 }
153 156
154 void RecentTabSuggestionsProvider::ClearDismissedSuggestionsForDebugging( 157 void RecentTabSuggestionsProvider::ClearDismissedSuggestionsForDebugging(
155 Category category) { 158 Category category) {
156 DCHECK_EQ(provided_category_, category); 159 DCHECK_EQ(provided_category_, category);
157 StoreDismissedIDsToPrefs(std::set<std::string>()); 160 StoreDismissedIDsToPrefs(std::set<std::string>());
158 FetchRecentTabs(); 161 FetchRecentTabs();
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 } 306 }
304 307
305 void RecentTabSuggestionsProvider::StoreDismissedIDsToPrefs( 308 void RecentTabSuggestionsProvider::StoreDismissedIDsToPrefs(
306 const std::set<std::string>& dismissed_ids) { 309 const std::set<std::string>& dismissed_ids) {
307 prefs::StoreDismissedIDsToPrefs(pref_service_, 310 prefs::StoreDismissedIDsToPrefs(pref_service_,
308 prefs::kDismissedRecentOfflineTabSuggestions, 311 prefs::kDismissedRecentOfflineTabSuggestions,
309 dismissed_ids); 312 dismissed_ids);
310 } 313 }
311 314
312 } // namespace ntp_snippets 315 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « chrome/browser/ntp_snippets/download_suggestions_provider_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698