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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 CategoryStatus OfflinePageSuggestionsProvider::GetCategoryStatus( | 63 CategoryStatus OfflinePageSuggestionsProvider::GetCategoryStatus( |
64 Category category) { | 64 Category category) { |
65 DCHECK_EQ(category, provided_category_); | 65 DCHECK_EQ(category, provided_category_); |
66 return category_status_; | 66 return category_status_; |
67 } | 67 } |
68 | 68 |
69 CategoryInfo OfflinePageSuggestionsProvider::GetCategoryInfo( | 69 CategoryInfo OfflinePageSuggestionsProvider::GetCategoryInfo( |
70 Category category) { | 70 Category category) { |
71 // TODO(pke): Use the proper string once it's agreed on. | 71 // TODO(pke): Use the proper string once it's agreed on. |
72 return CategoryInfo(base::ASCIIToUTF16("Offline pages"), | 72 return CategoryInfo(base::ASCIIToUTF16("Offline pages"), |
73 ContentSuggestionsCardLayout::MINIMAL_CARD); | 73 ContentSuggestionsCardLayout::MINIMAL_CARD, |
| 74 /* has_more_button */ false); |
74 } | 75 } |
75 | 76 |
76 void OfflinePageSuggestionsProvider::DismissSuggestion( | 77 void OfflinePageSuggestionsProvider::DismissSuggestion( |
77 const std::string& suggestion_id) { | 78 const std::string& suggestion_id) { |
78 std::string offline_page_id = GetWithinCategoryIDFromUniqueID(suggestion_id); | 79 std::string offline_page_id = GetWithinCategoryIDFromUniqueID(suggestion_id); |
79 dismissed_ids_.insert(offline_page_id); | 80 dismissed_ids_.insert(offline_page_id); |
80 StoreDismissedIDsToPrefs(); | 81 StoreDismissedIDsToPrefs(); |
81 } | 82 } |
82 | 83 |
83 void OfflinePageSuggestionsProvider::FetchSuggestionImage( | 84 void OfflinePageSuggestionsProvider::FetchSuggestionImage( |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 } | 203 } |
203 | 204 |
204 void OfflinePageSuggestionsProvider::StoreDismissedIDsToPrefs() { | 205 void OfflinePageSuggestionsProvider::StoreDismissedIDsToPrefs() { |
205 base::ListValue list; | 206 base::ListValue list; |
206 for (const std::string& dismissed_id : dismissed_ids_) | 207 for (const std::string& dismissed_id : dismissed_ids_) |
207 list.AppendString(dismissed_id); | 208 list.AppendString(dismissed_id); |
208 pref_service_->Set(prefs::kDismissedOfflinePageSuggestions, list); | 209 pref_service_->Set(prefs::kDismissedOfflinePageSuggestions, list); |
209 } | 210 } |
210 | 211 |
211 } // namespace ntp_snippets | 212 } // namespace ntp_snippets |
OLD | NEW |