| 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 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 ContentSuggestion suggestion( | 610 ContentSuggestion suggestion( |
| 611 ContentSuggestion::ID(provided_category_, GetAssetDownloadPerCategoryID( | 611 ContentSuggestion::ID(provided_category_, GetAssetDownloadPerCategoryID( |
| 612 download_item.GetId())), | 612 download_item.GetId())), |
| 613 download_item.GetOriginalUrl()); | 613 download_item.GetOriginalUrl()); |
| 614 suggestion.set_title( | 614 suggestion.set_title( |
| 615 download_item.GetTargetFilePath().BaseName().LossyDisplayName()); | 615 download_item.GetTargetFilePath().BaseName().LossyDisplayName()); |
| 616 suggestion.set_publish_date(GetAssetDownloadPublishedTime(download_item)); | 616 suggestion.set_publish_date(GetAssetDownloadPublishedTime(download_item)); |
| 617 suggestion.set_publisher_name( | 617 suggestion.set_publisher_name( |
| 618 base::UTF8ToUTF16(download_item.GetURL().host())); | 618 base::UTF8ToUTF16(download_item.GetURL().host())); |
| 619 auto extra = base::MakeUnique<ntp_snippets::DownloadSuggestionExtra>(); | 619 auto extra = base::MakeUnique<ntp_snippets::DownloadSuggestionExtra>(); |
| 620 extra->download_guid = download_item.GetGuid(); |
| 620 extra->target_file_path = download_item.GetTargetFilePath(); | 621 extra->target_file_path = download_item.GetTargetFilePath(); |
| 621 extra->mime_type = download_item.GetMimeType(); | 622 extra->mime_type = download_item.GetMimeType(); |
| 622 extra->is_download_asset = true; | 623 extra->is_download_asset = true; |
| 623 suggestion.set_download_suggestion_extra(std::move(extra)); | 624 suggestion.set_download_suggestion_extra(std::move(extra)); |
| 624 return suggestion; | 625 return suggestion; |
| 625 } | 626 } |
| 626 | 627 |
| 627 bool DownloadSuggestionsProvider::IsDownloadOutdated( | 628 bool DownloadSuggestionsProvider::IsDownloadOutdated( |
| 628 const base::Time& published_time, | 629 const base::Time& published_time, |
| 629 const base::Time& last_visited_time) { | 630 const base::Time& last_visited_time) { |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 void DownloadSuggestionsProvider::UnregisterDownloadItemObservers() { | 852 void DownloadSuggestionsProvider::UnregisterDownloadItemObservers() { |
| 852 DCHECK_NE(download_manager_, nullptr); | 853 DCHECK_NE(download_manager_, nullptr); |
| 853 | 854 |
| 854 std::vector<DownloadItem*> all_downloads; | 855 std::vector<DownloadItem*> all_downloads; |
| 855 download_manager_->GetAllDownloads(&all_downloads); | 856 download_manager_->GetAllDownloads(&all_downloads); |
| 856 | 857 |
| 857 for (DownloadItem* item : all_downloads) { | 858 for (DownloadItem* item : all_downloads) { |
| 858 item->RemoveObserver(this); | 859 item->RemoveObserver(this); |
| 859 } | 860 } |
| 860 } | 861 } |
| OLD | NEW |