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

Side by Side 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: Make bookmark suggestions dismissable 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/bookmarks/bookmark_suggestions_provider.h" 5 #include "components/ntp_snippets/bookmarks/bookmark_suggestions_provider.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 return std::vector<Category>({provided_category_}); 59 return std::vector<Category>({provided_category_});
60 } 60 }
61 61
62 CategoryStatus BookmarkSuggestionsProvider::GetCategoryStatus( 62 CategoryStatus BookmarkSuggestionsProvider::GetCategoryStatus(
63 Category category) { 63 Category category) {
64 return category_status_; 64 return category_status_;
65 } 65 }
66 66
67 void BookmarkSuggestionsProvider::DismissSuggestion( 67 void BookmarkSuggestionsProvider::DismissSuggestion(
68 const std::string& suggestion_id) { 68 const std::string& suggestion_id) {
69 // TODO(jkrcal): Implement blacklisting bookmarks until they are next visited. 69 DCHECK(bookmark_model_->loaded());
70 // Then also implement ClearDismissedSuggestionsForDebugging. 70 GURL url(GetWithinCategoryIDFromUniqueID(suggestion_id));
71 MarkBookmarksDismissed(bookmark_model_, url);
71 } 72 }
72 73
73 void BookmarkSuggestionsProvider::FetchSuggestionImage( 74 void BookmarkSuggestionsProvider::FetchSuggestionImage(
74 const std::string& suggestion_id, 75 const std::string& suggestion_id,
75 const ImageFetchedCallback& callback) { 76 const ImageFetchedCallback& callback) {
76 base::ThreadTaskRunnerHandle::Get()->PostTask( 77 base::ThreadTaskRunnerHandle::Get()->PostTask(
77 FROM_HERE, base::Bind(callback, suggestion_id, gfx::Image())); 78 FROM_HERE, base::Bind(callback, suggestion_id, gfx::Image()));
78 } 79 }
79 80
80 void BookmarkSuggestionsProvider::ClearCachedSuggestionsForDebugging() { 81 void BookmarkSuggestionsProvider::ClearCachedSuggestionsForDebugging() {
81 // Ignored. 82 // Ignored.
82 } 83 }
83 84
84 void BookmarkSuggestionsProvider::ClearDismissedSuggestionsForDebugging() { 85 void BookmarkSuggestionsProvider::ClearDismissedSuggestionsForDebugging() {
85 // TODO(jkrcal): Implement when discarded suggestions are supported. 86 if (!bookmark_model_->loaded())
87 return;
88 MarkAllBookmarksUndismissed(bookmark_model_);
86 } 89 }
87 90
88 void BookmarkSuggestionsProvider::BookmarkModelLoaded( 91 void BookmarkSuggestionsProvider::BookmarkModelLoaded(
89 bookmarks::BookmarkModel* model, 92 bookmarks::BookmarkModel* model,
90 bool ids_reassigned) { 93 bool ids_reassigned) {
91 DCHECK_EQ(bookmark_model_, model); 94 DCHECK_EQ(bookmark_model_, model);
92 if (fetch_requested_) { 95 if (fetch_requested_) {
93 fetch_requested_ = false; 96 fetch_requested_ = false;
94 FetchBookmarksInternal(); 97 FetchBookmarksInternal();
95 } 98 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 157
155 void BookmarkSuggestionsProvider::NotifyStatusChanged( 158 void BookmarkSuggestionsProvider::NotifyStatusChanged(
156 CategoryStatus new_status) { 159 CategoryStatus new_status) {
157 if (category_status_ == new_status) 160 if (category_status_ == new_status)
158 return; 161 return;
159 category_status_ = new_status; 162 category_status_ = new_status;
160 observer()->OnCategoryStatusChanged(this, provided_category_, new_status); 163 observer()->OnCategoryStatusChanged(this, provided_category_, new_status);
161 } 164 }
162 165
163 } // namespace ntp_snippets 166 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698