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

Unified Diff: components/ntp_snippets/bookmarks/bookmark_suggestions_provider.cc

Issue 2222933002: Make bookmark suggestions dismissable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/ntp_snippets/bookmarks/bookmark_suggestions_provider.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ntp_snippets/bookmarks/bookmark_suggestions_provider.cc
diff --git a/components/ntp_snippets/bookmarks/bookmark_suggestions_provider.cc b/components/ntp_snippets/bookmarks/bookmark_suggestions_provider.cc
index 0e27a87cc351150617c2ada15c767a544498bb1d..65e914090d422c0c2b6fb5b567e9b0988c6c332d 100644
--- a/components/ntp_snippets/bookmarks/bookmark_suggestions_provider.cc
+++ b/components/ntp_snippets/bookmarks/bookmark_suggestions_provider.cc
@@ -89,8 +89,9 @@ CategoryStatus BookmarkSuggestionsProvider::GetCategoryStatus(
void BookmarkSuggestionsProvider::DismissSuggestion(
const std::string& suggestion_id) {
- // TODO(jkrcal): Implement blacklisting bookmarks until they are next visited.
- // Then also implement ClearDismissedSuggestionsForDebugging.
+ DCHECK(bookmark_model_->loaded());
+ GURL url(GetWithinCategoryIDFromUniqueID(suggestion_id));
+ MarkBookmarksDismissed(bookmark_model_, url);
}
void BookmarkSuggestionsProvider::FetchSuggestionImage(
@@ -110,14 +111,21 @@ std::vector<ContentSuggestion>
BookmarkSuggestionsProvider::GetDismissedSuggestionsForDebugging(
Category category) {
DCHECK_EQ(category, provided_category_);
- // TODO(pke): Implement when discarded suggestions are supported.
- return std::vector<ContentSuggestion>();
+ std::vector<const BookmarkNode*> bookmarks =
+ GetDismissedBookmarksForDebugging(bookmark_model_);
+
+ std::vector<ContentSuggestion> suggestions;
+ for (const BookmarkNode* bookmark : bookmarks)
+ suggestions.emplace_back(ConvertBookmark(bookmark));
+ return suggestions;
}
void BookmarkSuggestionsProvider::ClearDismissedSuggestionsForDebugging(
Category category) {
DCHECK_EQ(category, provided_category_);
- // TODO(pke): Implement when discarded suggestions are supported.
+ if (!bookmark_model_->loaded())
+ return;
+ MarkAllBookmarksUndismissed(bookmark_model_);
}
void BookmarkSuggestionsProvider::BookmarkModelLoaded(
@@ -150,6 +158,19 @@ void BookmarkSuggestionsProvider::BookmarkMetaInfoChanged(
FetchBookmarks();
}
+ContentSuggestion BookmarkSuggestionsProvider::ConvertBookmark(
+ const BookmarkNode* bookmark) {
+ ContentSuggestion suggestion(
+ MakeUniqueID(provided_category_, bookmark->url().spec()),
+ bookmark->url());
+
+ suggestion.set_title(bookmark->GetTitle());
+ suggestion.set_snippet_text(base::string16());
+ suggestion.set_publish_date(GetLastVisitDateForBookmark(bookmark));
+ suggestion.set_publisher_name(base::UTF8ToUTF16(bookmark->url().host()));
+ return suggestion;
+}
+
void BookmarkSuggestionsProvider::FetchBookmarksInternal() {
DCHECK(bookmark_model_->loaded());
@@ -160,17 +181,8 @@ void BookmarkSuggestionsProvider::FetchBookmarksInternal() {
bookmark_model_, GetMaxCount(), threshold_time);
std::vector<ContentSuggestion> suggestions;
- for (const BookmarkNode* bookmark : bookmarks) {
- ContentSuggestion suggestion(
- MakeUniqueID(provided_category_, bookmark->url().spec()),
- bookmark->url());
-
- suggestion.set_title(bookmark->GetTitle());
- suggestion.set_snippet_text(base::string16());
- suggestion.set_publish_date(GetLastVisitDateForBookmark(bookmark));
- suggestion.set_publisher_name(base::UTF8ToUTF16(bookmark->url().host()));
- suggestions.emplace_back(std::move(suggestion));
- }
+ for (const BookmarkNode* bookmark : bookmarks)
+ suggestions.emplace_back(ConvertBookmark(bookmark));
if (suggestions.empty())
end_of_list_last_visit_date_ = threshold_time;
« no previous file with comments | « components/ntp_snippets/bookmarks/bookmark_suggestions_provider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698