| 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 Category category) { | 210 Category category) { |
| 211 DCHECK_EQ(provided_category_, category); | 211 DCHECK_EQ(provided_category_, category); |
| 212 return category_status_; | 212 return category_status_; |
| 213 } | 213 } |
| 214 | 214 |
| 215 CategoryInfo DownloadSuggestionsProvider::GetCategoryInfo(Category category) { | 215 CategoryInfo DownloadSuggestionsProvider::GetCategoryInfo(Category category) { |
| 216 DCHECK_EQ(provided_category_, category); | 216 DCHECK_EQ(provided_category_, category); |
| 217 return CategoryInfo( | 217 return CategoryInfo( |
| 218 l10n_util::GetStringUTF16(IDS_NTP_DOWNLOAD_SUGGESTIONS_SECTION_HEADER), | 218 l10n_util::GetStringUTF16(IDS_NTP_DOWNLOAD_SUGGESTIONS_SECTION_HEADER), |
| 219 ntp_snippets::ContentSuggestionsCardLayout::FULL_CARD, | 219 ntp_snippets::ContentSuggestionsCardLayout::FULL_CARD, |
| 220 /*has_fetch_action=*/false, | 220 ntp_snippets::ContentSuggestionsAdditionalAction::VIEW_ALL, |
| 221 /*has_view_all_action=*/true, | |
| 222 /*show_if_empty=*/false, | 221 /*show_if_empty=*/false, |
| 223 l10n_util::GetStringUTF16(IDS_NTP_DOWNLOADS_SUGGESTIONS_SECTION_EMPTY)); | 222 l10n_util::GetStringUTF16(IDS_NTP_DOWNLOADS_SUGGESTIONS_SECTION_EMPTY)); |
| 224 } | 223 } |
| 225 | 224 |
| 226 void DownloadSuggestionsProvider::DismissSuggestion( | 225 void DownloadSuggestionsProvider::DismissSuggestion( |
| 227 const ContentSuggestion::ID& suggestion_id) { | 226 const ContentSuggestion::ID& suggestion_id) { |
| 228 DCHECK_EQ(provided_category_, suggestion_id.category()); | 227 DCHECK_EQ(provided_category_, suggestion_id.category()); |
| 229 std::set<std::string> dismissed_ids = | 228 std::set<std::string> dismissed_ids = |
| 230 ReadDismissedIDsFromPrefs(CorrespondsToOfflinePage(suggestion_id)); | 229 ReadDismissedIDsFromPrefs(CorrespondsToOfflinePage(suggestion_id)); |
| 231 dismissed_ids.insert(suggestion_id.id_within_category()); | 230 dismissed_ids.insert(suggestion_id.id_within_category()); |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 void DownloadSuggestionsProvider::UnregisterDownloadItemObservers() { | 851 void DownloadSuggestionsProvider::UnregisterDownloadItemObservers() { |
| 853 DCHECK_NE(download_manager_, nullptr); | 852 DCHECK_NE(download_manager_, nullptr); |
| 854 | 853 |
| 855 std::vector<DownloadItem*> all_downloads; | 854 std::vector<DownloadItem*> all_downloads; |
| 856 download_manager_->GetAllDownloads(&all_downloads); | 855 download_manager_->GetAllDownloads(&all_downloads); |
| 857 | 856 |
| 858 for (DownloadItem* item : all_downloads) { | 857 for (DownloadItem* item : all_downloads) { |
| 859 item->RemoveObserver(this); | 858 item->RemoveObserver(this); |
| 860 } | 859 } |
| 861 } | 860 } |
| OLD | NEW |