Chromium Code Reviews| 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 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 481 // TODO(vitaliii): Remove this fallback once the OfflinePageModel provides | 481 // TODO(vitaliii): Remove this fallback once the OfflinePageModel provides |
| 482 // titles for all (relevant) OfflinePageItems. | 482 // titles for all (relevant) OfflinePageItems. |
| 483 suggestion.set_title(base::UTF8ToUTF16(offline_page.url.spec())); | 483 suggestion.set_title(base::UTF8ToUTF16(offline_page.url.spec())); |
| 484 } else { | 484 } else { |
| 485 suggestion.set_title(offline_page.title); | 485 suggestion.set_title(offline_page.title); |
| 486 } | 486 } |
| 487 suggestion.set_publish_date(offline_page.creation_time); | 487 suggestion.set_publish_date(offline_page.creation_time); |
| 488 suggestion.set_publisher_name(base::UTF8ToUTF16(offline_page.url.host())); | 488 suggestion.set_publisher_name(base::UTF8ToUTF16(offline_page.url.host())); |
| 489 auto extra = base::MakeUnique<ntp_snippets::DownloadSuggestionExtra>(); | 489 auto extra = base::MakeUnique<ntp_snippets::DownloadSuggestionExtra>(); |
| 490 extra->is_download_asset = false; | 490 extra->is_download_asset = false; |
| 491 extra->offline_page_id = base::Int64ToString(offline_page.offline_id); | |
|
Marc Treib
2016/11/16 15:22:58
Er, any reason why we pass this as a string? Seems
vitaliii
2016/11/16 15:45:08
As we discussed it is not clear how to match int64
Marc Treib
2016/11/16 15:55:56
There's a jlong analogous to jint, I'm pretty sure
vitaliii
2016/11/16 15:59:23
Acknowledged.
| |
| 491 suggestion.set_download_suggestion_extra(std::move(extra)); | 492 suggestion.set_download_suggestion_extra(std::move(extra)); |
| 492 return suggestion; | 493 return suggestion; |
| 493 } | 494 } |
| 494 | 495 |
| 495 ContentSuggestion DownloadSuggestionsProvider::ConvertDownloadItem( | 496 ContentSuggestion DownloadSuggestionsProvider::ConvertDownloadItem( |
| 496 const DownloadItem& download_item) const { | 497 const DownloadItem& download_item) const { |
| 497 ContentSuggestion suggestion( | 498 ContentSuggestion suggestion( |
| 498 ContentSuggestion::ID(provided_category_, GetAssetDownloadPerCategoryID( | 499 ContentSuggestion::ID(provided_category_, GetAssetDownloadPerCategoryID( |
| 499 download_item.GetId())), | 500 download_item.GetId())), |
| 500 download_item.GetOriginalUrl()); | 501 download_item.GetOriginalUrl()); |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 714 | 715 |
| 715 void DownloadSuggestionsProvider::UnregisterDownloadItemObservers() { | 716 void DownloadSuggestionsProvider::UnregisterDownloadItemObservers() { |
| 716 DCHECK_NE(download_manager_, nullptr); | 717 DCHECK_NE(download_manager_, nullptr); |
| 717 | 718 |
| 718 std::vector<DownloadItem*> all_downloads; | 719 std::vector<DownloadItem*> all_downloads; |
| 719 download_manager_->GetAllDownloads(&all_downloads); | 720 download_manager_->GetAllDownloads(&all_downloads); |
| 720 | 721 |
| 721 for (DownloadItem* item : all_downloads) | 722 for (DownloadItem* item : all_downloads) |
| 722 item->RemoveObserver(this); | 723 item->RemoveObserver(this); |
| 723 } | 724 } |
| OLD | NEW |