Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(455)

Side by Side Diff: components/ntp_snippets/offline_pages/offline_page_suggestions_provider.cc

Issue 2249903003: 📰 Empty state handling for the Bookmarks section (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tests Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 NOTREACHED() << "Unknown category " << category.id(); 102 NOTREACHED() << "Unknown category " << category.id();
103 return CategoryStatus::NOT_PROVIDED; 103 return CategoryStatus::NOT_PROVIDED;
104 } 104 }
105 105
106 CategoryInfo OfflinePageSuggestionsProvider::GetCategoryInfo( 106 CategoryInfo OfflinePageSuggestionsProvider::GetCategoryInfo(
107 Category category) { 107 Category category) {
108 if (category == recent_tabs_category_) { 108 if (category == recent_tabs_category_) {
109 return CategoryInfo(l10n_util::GetStringUTF16( 109 return CategoryInfo(l10n_util::GetStringUTF16(
110 IDS_NTP_RECENT_TAB_SUGGESTIONS_SECTION_HEADER), 110 IDS_NTP_RECENT_TAB_SUGGESTIONS_SECTION_HEADER),
111 ContentSuggestionsCardLayout::MINIMAL_CARD, 111 ContentSuggestionsCardLayout::MINIMAL_CARD,
112 /* has_more_button */ false); 112 /* has_more_button */ false,
113 /* show_if_empty */ false);
113 } 114 }
114 if (category == downloads_category_) { 115 if (category == downloads_category_) {
115 return CategoryInfo( 116 return CategoryInfo(
116 l10n_util::GetStringUTF16(IDS_NTP_DOWNLOAD_SUGGESTIONS_SECTION_HEADER), 117 l10n_util::GetStringUTF16(IDS_NTP_DOWNLOAD_SUGGESTIONS_SECTION_HEADER),
117 ContentSuggestionsCardLayout::MINIMAL_CARD, 118 ContentSuggestionsCardLayout::MINIMAL_CARD,
118 /* has_more_button */ download_manager_ui_enabled_); 119 /* has_more_button */ download_manager_ui_enabled_,
120 /* show_if_empty */ false);
119 } 121 }
120 NOTREACHED() << "Unknown category " << category.id(); 122 NOTREACHED() << "Unknown category " << category.id();
121 return CategoryInfo(base::string16(), 123 return CategoryInfo(base::string16(),
122 ContentSuggestionsCardLayout::MINIMAL_CARD, 124 ContentSuggestionsCardLayout::MINIMAL_CARD,
123 /* has_more_button */ false); 125 /* has_more_button */ false,
126 /* show_if_empty */ false);
124 } 127 }
125 128
126 void OfflinePageSuggestionsProvider::DismissSuggestion( 129 void OfflinePageSuggestionsProvider::DismissSuggestion(
127 const std::string& suggestion_id) { 130 const std::string& suggestion_id) {
128 Category category = GetCategoryFromUniqueID(suggestion_id); 131 Category category = GetCategoryFromUniqueID(suggestion_id);
129 std::string offline_page_id = GetWithinCategoryIDFromUniqueID(suggestion_id); 132 std::string offline_page_id = GetWithinCategoryIDFromUniqueID(suggestion_id);
130 if (category == recent_tabs_category_) { 133 if (category == recent_tabs_category_) {
131 DCHECK_NE(CategoryStatus::NOT_PROVIDED, recent_tabs_status_); 134 DCHECK_NE(CategoryStatus::NOT_PROVIDED, recent_tabs_status_);
132 dismissed_recent_tab_ids_.insert(offline_page_id); 135 dismissed_recent_tab_ids_.insert(offline_page_id);
133 StoreDismissedIDsToPrefs(prefs::kDismissedRecentOfflineTabSuggestions, 136 StoreDismissedIDsToPrefs(prefs::kDismissedRecentOfflineTabSuggestions,
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 void OfflinePageSuggestionsProvider::StoreDismissedIDsToPrefs( 346 void OfflinePageSuggestionsProvider::StoreDismissedIDsToPrefs(
344 const std::string& pref_name, 347 const std::string& pref_name,
345 const std::set<std::string>& dismissed_ids) { 348 const std::set<std::string>& dismissed_ids) {
346 base::ListValue list; 349 base::ListValue list;
347 for (const std::string& dismissed_id : dismissed_ids) 350 for (const std::string& dismissed_id : dismissed_ids)
348 list.AppendString(dismissed_id); 351 list.AppendString(dismissed_id);
349 pref_service_->Set(pref_name, list); 352 pref_service_->Set(pref_name, list);
350 } 353 }
351 354
352 } // namespace ntp_snippets 355 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698