| 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 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 } | 122 } |
| 123 | 123 |
| 124 CategoryStatus DownloadSuggestionsProvider::GetCategoryStatus( | 124 CategoryStatus DownloadSuggestionsProvider::GetCategoryStatus( |
| 125 Category category) { | 125 Category category) { |
| 126 DCHECK_EQ(provided_category_, category); | 126 DCHECK_EQ(provided_category_, category); |
| 127 return category_status_; | 127 return category_status_; |
| 128 } | 128 } |
| 129 | 129 |
| 130 CategoryInfo DownloadSuggestionsProvider::GetCategoryInfo(Category category) { | 130 CategoryInfo DownloadSuggestionsProvider::GetCategoryInfo(Category category) { |
| 131 DCHECK_EQ(provided_category_, category); | 131 DCHECK_EQ(provided_category_, category); |
| 132 // TODO(vitaliii): Do not show "More" button when there is no downloads UI. | |
| 133 // See crbug.com/660030. | |
| 134 return CategoryInfo( | 132 return CategoryInfo( |
| 135 l10n_util::GetStringUTF16(IDS_NTP_DOWNLOAD_SUGGESTIONS_SECTION_HEADER), | 133 l10n_util::GetStringUTF16(IDS_NTP_DOWNLOAD_SUGGESTIONS_SECTION_HEADER), |
| 136 ntp_snippets::ContentSuggestionsCardLayout::MINIMAL_CARD, | 134 ntp_snippets::ContentSuggestionsCardLayout::MINIMAL_CARD, |
| 137 /*has_more_button=*/download_manager_ui_enabled_, | 135 /*has_more_action=*/false, |
| 136 /*has_reload_action=*/false, |
| 137 /*has_view_all_action=*/download_manager_ui_enabled_, |
| 138 /*show_if_empty=*/false, | 138 /*show_if_empty=*/false, |
| 139 l10n_util::GetStringUTF16(IDS_NTP_DOWNLOADS_SUGGESTIONS_SECTION_EMPTY)); | 139 l10n_util::GetStringUTF16(IDS_NTP_DOWNLOADS_SUGGESTIONS_SECTION_EMPTY)); |
| 140 } | 140 } |
| 141 | 141 |
| 142 void DownloadSuggestionsProvider::DismissSuggestion( | 142 void DownloadSuggestionsProvider::DismissSuggestion( |
| 143 const ContentSuggestion::ID& suggestion_id) { | 143 const ContentSuggestion::ID& suggestion_id) { |
| 144 DCHECK_EQ(provided_category_, suggestion_id.category()); | 144 DCHECK_EQ(provided_category_, suggestion_id.category()); |
| 145 std::set<std::string> dismissed_ids = | 145 std::set<std::string> dismissed_ids = |
| 146 ReadDismissedIDsFromPrefs(CorrespondsToOfflinePage(suggestion_id)); | 146 ReadDismissedIDsFromPrefs(CorrespondsToOfflinePage(suggestion_id)); |
| 147 dismissed_ids.insert(suggestion_id.id_within_category()); | 147 dismissed_ids.insert(suggestion_id.id_within_category()); |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 620 | 620 |
| 621 void DownloadSuggestionsProvider::UnregisterDownloadItemObservers() { | 621 void DownloadSuggestionsProvider::UnregisterDownloadItemObservers() { |
| 622 DCHECK_NE(download_manager_, nullptr); | 622 DCHECK_NE(download_manager_, nullptr); |
| 623 | 623 |
| 624 std::vector<DownloadItem*> all_downloads; | 624 std::vector<DownloadItem*> all_downloads; |
| 625 download_manager_->GetAllDownloads(&all_downloads); | 625 download_manager_->GetAllDownloads(&all_downloads); |
| 626 | 626 |
| 627 for (DownloadItem* item : all_downloads) | 627 for (DownloadItem* item : all_downloads) |
| 628 item->RemoveObserver(this); | 628 item->RemoveObserver(this); |
| 629 } | 629 } |
| OLD | NEW |