| 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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 } | 312 } |
| 313 } | 313 } |
| 314 } | 314 } |
| 315 | 315 |
| 316 callback.Run(std::move(suggestions)); | 316 callback.Run(std::move(suggestions)); |
| 317 } | 317 } |
| 318 | 318 |
| 319 void DownloadSuggestionsProvider::OfflinePageModelLoaded( | 319 void DownloadSuggestionsProvider::OfflinePageModelLoaded( |
| 320 offline_pages::OfflinePageModel* model) { | 320 offline_pages::OfflinePageModel* model) { |
| 321 DCHECK_EQ(offline_page_model_, model); | 321 DCHECK_EQ(offline_page_model_, model); |
| 322 AsynchronouslyFetchOfflinePagesDownloads(/*notify=*/true); | 322 // Ignored. We issue a fetch in the constructor (or when Downloads Manager is |
| 323 // loaded) and Offline Page model answers asynchronously once it has been |
| 324 // loaded. |
| 323 } | 325 } |
| 324 | 326 |
| 325 void DownloadSuggestionsProvider::OfflinePageAdded( | 327 void DownloadSuggestionsProvider::OfflinePageAdded( |
| 326 offline_pages::OfflinePageModel* model, | 328 offline_pages::OfflinePageModel* model, |
| 327 const offline_pages::OfflinePageItem& added_page) { | 329 const offline_pages::OfflinePageItem& added_page) { |
| 328 DCHECK_EQ(offline_page_model_, model); | 330 DCHECK_EQ(offline_page_model_, model); |
| 329 if (!IsClientIdForOfflinePageDownload(model->GetPolicyController(), | 331 if (!IsClientIdForOfflinePageDownload(model->GetPolicyController(), |
| 330 added_page.client_id)) { | 332 added_page.client_id)) { |
| 331 return; | 333 return; |
| 332 } | 334 } |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 void DownloadSuggestionsProvider::UnregisterDownloadItemObservers() { | 811 void DownloadSuggestionsProvider::UnregisterDownloadItemObservers() { |
| 810 DCHECK_NE(download_manager_, nullptr); | 812 DCHECK_NE(download_manager_, nullptr); |
| 811 | 813 |
| 812 std::vector<DownloadItem*> all_downloads; | 814 std::vector<DownloadItem*> all_downloads; |
| 813 download_manager_->GetAllDownloads(&all_downloads); | 815 download_manager_->GetAllDownloads(&all_downloads); |
| 814 | 816 |
| 815 for (DownloadItem* item : all_downloads) { | 817 for (DownloadItem* item : all_downloads) { |
| 816 item->RemoveObserver(this); | 818 item->RemoveObserver(this); |
| 817 } | 819 } |
| 818 } | 820 } |
| OLD | NEW |