| 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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 | 299 |
| 300 callback.Run(std::move(suggestions)); | 300 callback.Run(std::move(suggestions)); |
| 301 } | 301 } |
| 302 | 302 |
| 303 void DownloadSuggestionsProvider::OfflinePageModelLoaded( | 303 void DownloadSuggestionsProvider::OfflinePageModelLoaded( |
| 304 offline_pages::OfflinePageModel* model) { | 304 offline_pages::OfflinePageModel* model) { |
| 305 DCHECK_EQ(offline_page_model_, model); | 305 DCHECK_EQ(offline_page_model_, model); |
| 306 AsynchronouslyFetchOfflinePagesDownloads(/*notify=*/true); | 306 AsynchronouslyFetchOfflinePagesDownloads(/*notify=*/true); |
| 307 } | 307 } |
| 308 | 308 |
| 309 void DownloadSuggestionsProvider::OfflinePageModelChanged( | 309 void DownloadSuggestionsProvider::OfflinePageAdded( |
| 310 offline_pages::OfflinePageModel* model) { | 310 offline_pages::OfflinePageModel* model, |
| 311 const offline_pages::OfflinePageItem& added_page) { |
| 312 // TODO(dewittj, vitaliii): Don't refetch everything when this is called. |
| 311 DCHECK_EQ(offline_page_model_, model); | 313 DCHECK_EQ(offline_page_model_, model); |
| 312 AsynchronouslyFetchOfflinePagesDownloads(/*notify=*/true); | 314 AsynchronouslyFetchOfflinePagesDownloads(/*notify=*/true); |
| 313 } | 315 } |
| 314 | 316 |
| 315 void DownloadSuggestionsProvider::OfflinePageDeleted( | 317 void DownloadSuggestionsProvider::OfflinePageDeleted( |
| 316 int64_t offline_id, | 318 int64_t offline_id, |
| 317 const offline_pages::ClientId& client_id) { | 319 const offline_pages::ClientId& client_id) { |
| 318 DCHECK(offline_page_model_); | 320 DCHECK(offline_page_model_); |
| 319 if (IsClientIdForOfflinePageDownload( | 321 if (IsClientIdForOfflinePageDownload( |
| 320 offline_page_model_->GetPolicyController(), client_id)) { | 322 offline_page_model_->GetPolicyController(), client_id)) { |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 void DownloadSuggestionsProvider::UnregisterDownloadItemObservers() { | 747 void DownloadSuggestionsProvider::UnregisterDownloadItemObservers() { |
| 746 DCHECK_NE(download_manager_, nullptr); | 748 DCHECK_NE(download_manager_, nullptr); |
| 747 | 749 |
| 748 std::vector<DownloadItem*> all_downloads; | 750 std::vector<DownloadItem*> all_downloads; |
| 749 download_manager_->GetAllDownloads(&all_downloads); | 751 download_manager_->GetAllDownloads(&all_downloads); |
| 750 | 752 |
| 751 for (DownloadItem* item : all_downloads) { | 753 for (DownloadItem* item : all_downloads) { |
| 752 item->RemoveObserver(this); | 754 item->RemoveObserver(this); |
| 753 } | 755 } |
| 754 } | 756 } |
| OLD | NEW |