| 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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 suggestions.push_back(ConvertDownloadItem(*item)); | 263 suggestions.push_back(ConvertDownloadItem(*item)); |
| 264 } | 264 } |
| 265 } | 265 } |
| 266 | 266 |
| 267 callback.Run(std::move(suggestions)); | 267 callback.Run(std::move(suggestions)); |
| 268 } | 268 } |
| 269 | 269 |
| 270 void DownloadSuggestionsProvider::OfflinePageModelLoaded( | 270 void DownloadSuggestionsProvider::OfflinePageModelLoaded( |
| 271 offline_pages::OfflinePageModel* model) {} | 271 offline_pages::OfflinePageModel* model) {} |
| 272 | 272 |
| 273 void DownloadSuggestionsProvider::OfflinePageModelChanged( | 273 void DownloadSuggestionsProvider::OfflinePageAdded( |
| 274 offline_pages::OfflinePageModel* model) { | 274 offline_pages::OfflinePageModel* model, |
| 275 const offline_pages::OfflinePageItem& added_page) { |
| 276 // TODO(dewittj, vitaliii): Don't refetch everything when this is called. |
| 275 DCHECK_EQ(offline_page_model_, model); | 277 DCHECK_EQ(offline_page_model_, model); |
| 276 AsynchronouslyFetchOfflinePagesDownloads(/*notify=*/true); | 278 AsynchronouslyFetchOfflinePagesDownloads(/*notify=*/true); |
| 277 } | 279 } |
| 278 | 280 |
| 279 void DownloadSuggestionsProvider::OfflinePageDeleted( | 281 void DownloadSuggestionsProvider::OfflinePageDeleted( |
| 280 int64_t offline_id, | 282 int64_t offline_id, |
| 281 const offline_pages::ClientId& client_id) { | 283 const offline_pages::ClientId& client_id) { |
| 282 DCHECK(offline_page_model_); | 284 DCHECK(offline_page_model_); |
| 283 if (IsClientIdForOfflinePageDownload( | 285 if (IsClientIdForOfflinePageDownload( |
| 284 offline_page_model_->GetPolicyController(), client_id)) { | 286 offline_page_model_->GetPolicyController(), client_id)) { |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 | 666 |
| 665 void DownloadSuggestionsProvider::UnregisterDownloadItemObservers() { | 667 void DownloadSuggestionsProvider::UnregisterDownloadItemObservers() { |
| 666 DCHECK_NE(download_manager_, nullptr); | 668 DCHECK_NE(download_manager_, nullptr); |
| 667 | 669 |
| 668 std::vector<DownloadItem*> all_downloads; | 670 std::vector<DownloadItem*> all_downloads; |
| 669 download_manager_->GetAllDownloads(&all_downloads); | 671 download_manager_->GetAllDownloads(&all_downloads); |
| 670 | 672 |
| 671 for (DownloadItem* item : all_downloads) | 673 for (DownloadItem* item : all_downloads) |
| 672 item->RemoveObserver(this); | 674 item->RemoveObserver(this); |
| 673 } | 675 } |
| OLD | NEW |