Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "chrome/browser/ntp_snippets/download_suggestions_provider.h" | 5 #include "chrome/browser/ntp_snippets/download_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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 226 // Ignored. The internal caches are not stored on disk and they are just | 226 // Ignored. The internal caches are not stored on disk and they are just |
| 227 // partial copies of the data stored at OfflinePage model and DownloadManager. | 227 // partial copies of the data stored at OfflinePage model and DownloadManager. |
| 228 // If it is cleared there, it will be cleared in these caches as well. | 228 // If it is cleared there, it will be cleared in these caches as well. |
| 229 } | 229 } |
| 230 | 230 |
| 231 void DownloadSuggestionsProvider::GetDismissedSuggestionsForDebugging( | 231 void DownloadSuggestionsProvider::GetDismissedSuggestionsForDebugging( |
| 232 Category category, | 232 Category category, |
| 233 const ntp_snippets::DismissedSuggestionsCallback& callback) { | 233 const ntp_snippets::DismissedSuggestionsCallback& callback) { |
| 234 DCHECK_EQ(provided_category_, category); | 234 DCHECK_EQ(provided_category_, category); |
| 235 | 235 |
| 236 // TODO(vitaliii): Query all pages instead by using an empty query. | |
| 237 if (offline_page_model_) { | 236 if (offline_page_model_) { |
| 237 // Even not related to downloads offline pages are queried here, so that | |
|
Marc Treib
2016/11/21 12:27:53
Offline pages which are not related to downloads a
vitaliii
2016/11/21 14:56:46
Done.
| |
| 238 // they can be returned in case there are problems with dismissing. | |
|
Marc Treib
2016/11/21 12:27:53
I don't quite understand this. You're saying, this
vitaliii
2016/11/21 14:56:46
Yes, while testing, I would say.
My arguments:
1)
Marc Treib
2016/11/21 15:38:10
Well, it's a method on the Provider, so I'd say it
vitaliii
2016/11/21 15:49:55
Hm, it seems like we misunderstood each other.
I
Marc Treib
2016/11/21 15:56:57
Ah, I think I see your point now. No objections th
vitaliii
2016/11/22 06:32:46
Done.
| |
| 239 OfflinePageModelQueryBuilder query_builder; | |
| 238 offline_page_model_->GetPagesMatchingQuery( | 240 offline_page_model_->GetPagesMatchingQuery( |
| 239 BuildOfflinePageDownloadsQuery(offline_page_model_), | 241 query_builder.Build(offline_page_model_->GetPolicyController()), |
| 240 base::Bind(&DownloadSuggestionsProvider:: | 242 base::Bind(&DownloadSuggestionsProvider:: |
| 241 GetPagesMatchingQueryCallbackForGetDismissedSuggestions, | 243 GetPagesMatchingQueryCallbackForGetDismissedSuggestions, |
| 242 weak_ptr_factory_.GetWeakPtr(), callback)); | 244 weak_ptr_factory_.GetWeakPtr(), callback)); |
| 243 } else { | 245 } else { |
| 244 GetPagesMatchingQueryCallbackForGetDismissedSuggestions( | 246 GetPagesMatchingQueryCallbackForGetDismissedSuggestions( |
| 245 callback, std::vector<OfflinePageItem>()); | 247 callback, std::vector<OfflinePageItem>()); |
| 246 } | 248 } |
| 247 } | 249 } |
| 248 | 250 |
| 249 void DownloadSuggestionsProvider::ClearDismissedSuggestionsForDebugging( | 251 void DownloadSuggestionsProvider::ClearDismissedSuggestionsForDebugging( |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 715 | 717 |
| 716 void DownloadSuggestionsProvider::UnregisterDownloadItemObservers() { | 718 void DownloadSuggestionsProvider::UnregisterDownloadItemObservers() { |
| 717 DCHECK_NE(download_manager_, nullptr); | 719 DCHECK_NE(download_manager_, nullptr); |
| 718 | 720 |
| 719 std::vector<DownloadItem*> all_downloads; | 721 std::vector<DownloadItem*> all_downloads; |
| 720 download_manager_->GetAllDownloads(&all_downloads); | 722 download_manager_->GetAllDownloads(&all_downloads); |
| 721 | 723 |
| 722 for (DownloadItem* item : all_downloads) | 724 for (DownloadItem* item : all_downloads) |
| 723 item->RemoveObserver(this); | 725 item->RemoveObserver(this); |
| 724 } | 726 } |
| OLD | NEW |