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