| 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/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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 54 |
| 55 //////////////////////////////////////////////////////////////////////////////// | 55 //////////////////////////////////////////////////////////////////////////////// |
| 56 // Private methods | 56 // Private methods |
| 57 | 57 |
| 58 std::vector<Category> BookmarkSuggestionsProvider::GetProvidedCategories() { | 58 std::vector<Category> BookmarkSuggestionsProvider::GetProvidedCategories() { |
| 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 DCHECK_EQ(category, provided_category_); | |
| 65 return category_status_; | 64 return category_status_; |
| 66 } | 65 } |
| 67 | 66 |
| 68 void BookmarkSuggestionsProvider::DismissSuggestion( | 67 void BookmarkSuggestionsProvider::DismissSuggestion( |
| 69 const std::string& suggestion_id) { | 68 const std::string& suggestion_id) { |
| 70 // TODO(jkrcal): Implement blacklisting bookmarks until they are next visited. | 69 // TODO(jkrcal): Implement blacklisting bookmarks until they are next visited. |
| 71 // Then also implement ClearDismissedSuggestionsForDebugging. | 70 // Then also implement ClearDismissedSuggestionsForDebugging. |
| 72 } | 71 } |
| 73 | 72 |
| 74 void BookmarkSuggestionsProvider::FetchSuggestionImage( | 73 void BookmarkSuggestionsProvider::FetchSuggestionImage( |
| 75 const std::string& suggestion_id, | 74 const std::string& suggestion_id, |
| 76 const ImageFetchedCallback& callback) { | 75 const ImageFetchedCallback& callback) { |
| 77 base::ThreadTaskRunnerHandle::Get()->PostTask( | 76 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 78 FROM_HERE, base::Bind(callback, suggestion_id, gfx::Image())); | 77 FROM_HERE, base::Bind(callback, suggestion_id, gfx::Image())); |
| 79 } | 78 } |
| 80 | 79 |
| 81 void BookmarkSuggestionsProvider::ClearCachedSuggestionsForDebugging( | 80 void BookmarkSuggestionsProvider::ClearCachedSuggestionsForDebugging() { |
| 82 Category category) { | |
| 83 DCHECK_EQ(category, provided_category_); | |
| 84 // Ignored. | 81 // Ignored. |
| 85 } | 82 } |
| 86 | 83 |
| 87 std::vector<ContentSuggestion> | 84 void BookmarkSuggestionsProvider::ClearDismissedSuggestionsForDebugging() { |
| 88 BookmarkSuggestionsProvider::GetDismissedSuggestionsForDebugging( | 85 // TODO(jkrcal): Implement when discarded suggestions are supported. |
| 89 Category category) { | |
| 90 DCHECK_EQ(category, provided_category_); | |
| 91 // TODO(pke): Implement when discarded suggestions are supported. | |
| 92 return std::vector<ContentSuggestion>(); | |
| 93 } | |
| 94 | |
| 95 void BookmarkSuggestionsProvider::ClearDismissedSuggestionsForDebugging( | |
| 96 Category category) { | |
| 97 DCHECK_EQ(category, provided_category_); | |
| 98 // TODO(pke): Implement when discarded suggestions are supported. | |
| 99 } | 86 } |
| 100 | 87 |
| 101 void BookmarkSuggestionsProvider::BookmarkModelLoaded( | 88 void BookmarkSuggestionsProvider::BookmarkModelLoaded( |
| 102 bookmarks::BookmarkModel* model, | 89 bookmarks::BookmarkModel* model, |
| 103 bool ids_reassigned) { | 90 bool ids_reassigned) { |
| 104 DCHECK_EQ(bookmark_model_, model); | 91 DCHECK_EQ(bookmark_model_, model); |
| 105 if (fetch_requested_) { | 92 if (fetch_requested_) { |
| 106 fetch_requested_ = false; | 93 fetch_requested_ = false; |
| 107 FetchBookmarksInternal(); | 94 FetchBookmarksInternal(); |
| 108 } | 95 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 | 154 |
| 168 void BookmarkSuggestionsProvider::NotifyStatusChanged( | 155 void BookmarkSuggestionsProvider::NotifyStatusChanged( |
| 169 CategoryStatus new_status) { | 156 CategoryStatus new_status) { |
| 170 if (category_status_ == new_status) | 157 if (category_status_ == new_status) |
| 171 return; | 158 return; |
| 172 category_status_ = new_status; | 159 category_status_ = new_status; |
| 173 observer()->OnCategoryStatusChanged(this, provided_category_, new_status); | 160 observer()->OnCategoryStatusChanged(this, provided_category_, new_status); |
| 174 } | 161 } |
| 175 | 162 |
| 176 } // namespace ntp_snippets | 163 } // namespace ntp_snippets |
| OLD | NEW |