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 "components/ntp_snippets/offline_pages/offline_page_suggestions_provide
r.h" | 5 #include "components/ntp_snippets/offline_pages/offline_page_suggestions_provide
r.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/guid.h" | 10 #include "base/guid.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 NOTREACHED() << "Unknown category " << category.id(); | 98 NOTREACHED() << "Unknown category " << category.id(); |
99 return CategoryStatus::NOT_PROVIDED; | 99 return CategoryStatus::NOT_PROVIDED; |
100 } | 100 } |
101 | 101 |
102 CategoryInfo OfflinePageSuggestionsProvider::GetCategoryInfo( | 102 CategoryInfo OfflinePageSuggestionsProvider::GetCategoryInfo( |
103 Category category) { | 103 Category category) { |
104 if (category == recent_tabs_category_) { | 104 if (category == recent_tabs_category_) { |
105 return CategoryInfo(l10n_util::GetStringUTF16( | 105 return CategoryInfo(l10n_util::GetStringUTF16( |
106 IDS_NTP_RECENT_TAB_SUGGESTIONS_SECTION_HEADER), | 106 IDS_NTP_RECENT_TAB_SUGGESTIONS_SECTION_HEADER), |
107 ContentSuggestionsCardLayout::MINIMAL_CARD, | 107 ContentSuggestionsCardLayout::MINIMAL_CARD, |
108 /* has_more_button */ false); | 108 /* has_more_button */ false, |
| 109 /* show_if_empty */ false); |
109 } | 110 } |
110 if (category == downloads_category_) { | 111 if (category == downloads_category_) { |
111 return CategoryInfo( | 112 return CategoryInfo( |
112 l10n_util::GetStringUTF16(IDS_NTP_DOWNLOAD_SUGGESTIONS_SECTION_HEADER), | 113 l10n_util::GetStringUTF16(IDS_NTP_DOWNLOAD_SUGGESTIONS_SECTION_HEADER), |
113 ContentSuggestionsCardLayout::MINIMAL_CARD, | 114 ContentSuggestionsCardLayout::MINIMAL_CARD, |
114 /* has_more_button */ download_manager_ui_enabled_); | 115 /* has_more_button */ download_manager_ui_enabled_, |
| 116 /* show_if_empty */ false); |
115 } | 117 } |
116 NOTREACHED() << "Unknown category " << category.id(); | 118 NOTREACHED() << "Unknown category " << category.id(); |
117 return CategoryInfo(base::string16(), | 119 return CategoryInfo(base::string16(), |
118 ContentSuggestionsCardLayout::MINIMAL_CARD, | 120 ContentSuggestionsCardLayout::MINIMAL_CARD, |
119 /* has_more_button */ false); | 121 /* has_more_button */ false, |
| 122 /* show_if_empty */ false); |
120 } | 123 } |
121 | 124 |
122 void OfflinePageSuggestionsProvider::DismissSuggestion( | 125 void OfflinePageSuggestionsProvider::DismissSuggestion( |
123 const std::string& suggestion_id) { | 126 const std::string& suggestion_id) { |
124 Category category = GetCategoryFromUniqueID(suggestion_id); | 127 Category category = GetCategoryFromUniqueID(suggestion_id); |
125 std::string offline_page_id = GetWithinCategoryIDFromUniqueID(suggestion_id); | 128 std::string offline_page_id = GetWithinCategoryIDFromUniqueID(suggestion_id); |
126 std::set<std::string> dismissed_ids = ReadDismissedIDsFromPrefs(category); | 129 std::set<std::string> dismissed_ids = ReadDismissedIDsFromPrefs(category); |
127 dismissed_ids.insert(offline_page_id); | 130 dismissed_ids.insert(offline_page_id); |
128 StoreDismissedIDsToPrefs(category, dismissed_ids); | 131 StoreDismissedIDsToPrefs(category, dismissed_ids); |
129 } | 132 } |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 void OfflinePageSuggestionsProvider::StoreDismissedIDsToPrefs( | 364 void OfflinePageSuggestionsProvider::StoreDismissedIDsToPrefs( |
362 Category category, | 365 Category category, |
363 const std::set<std::string>& dismissed_ids) { | 366 const std::set<std::string>& dismissed_ids) { |
364 base::ListValue list; | 367 base::ListValue list; |
365 for (const std::string& dismissed_id : dismissed_ids) | 368 for (const std::string& dismissed_id : dismissed_ids) |
366 list.AppendString(dismissed_id); | 369 list.AppendString(dismissed_id); |
367 pref_service_->Set(GetDismissedPref(category), list); | 370 pref_service_->Set(GetDismissedPref(category), list); |
368 } | 371 } |
369 | 372 |
370 } // namespace ntp_snippets | 373 } // namespace ntp_snippets |
OLD | NEW |