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" |
| 11 #include "base/location.h" |
10 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/threading/thread_task_runner_handle.h" |
11 #include "components/bookmarks/browser/bookmark_model.h" | 14 #include "components/bookmarks/browser/bookmark_model.h" |
12 #include "components/ntp_snippets/bookmarks/bookmark_last_visit_utils.h" | 15 #include "components/ntp_snippets/bookmarks/bookmark_last_visit_utils.h" |
13 #include "components/ntp_snippets/category_factory.h" | 16 #include "components/ntp_snippets/category_factory.h" |
14 #include "components/ntp_snippets/content_suggestion.h" | 17 #include "components/ntp_snippets/content_suggestion.h" |
| 18 #include "ui/gfx/image/image.h" |
15 | 19 |
16 using bookmarks::BookmarkModel; | 20 using bookmarks::BookmarkModel; |
17 using bookmarks::BookmarkNode; | 21 using bookmarks::BookmarkNode; |
18 | 22 |
19 namespace { | 23 namespace { |
20 | 24 |
21 const int kMaxBookmarks = 10; | 25 const int kMaxBookmarks = 10; |
22 const int kMaxBookmarkAgeInDays = 42; | 26 const int kMaxBookmarkAgeInDays = 42; |
23 | 27 |
24 base::Time GetThresholdTime() { | 28 base::Time GetThresholdTime() { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 66 |
63 void BookmarkSuggestionsProvider::DismissSuggestion( | 67 void BookmarkSuggestionsProvider::DismissSuggestion( |
64 const std::string& suggestion_id) { | 68 const std::string& suggestion_id) { |
65 // TODO(jkrcal): Implement blacklisting bookmarks until they are next visited. | 69 // TODO(jkrcal): Implement blacklisting bookmarks until they are next visited. |
66 // Then also implement ClearDismissedSuggestionsForDebugging. | 70 // Then also implement ClearDismissedSuggestionsForDebugging. |
67 } | 71 } |
68 | 72 |
69 void BookmarkSuggestionsProvider::FetchSuggestionImage( | 73 void BookmarkSuggestionsProvider::FetchSuggestionImage( |
70 const std::string& suggestion_id, | 74 const std::string& suggestion_id, |
71 const ImageFetchedCallback& callback) { | 75 const ImageFetchedCallback& callback) { |
72 callback.Run(suggestion_id, gfx::Image()); | 76 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 77 FROM_HERE, base::Bind(callback, suggestion_id, gfx::Image())); |
73 } | 78 } |
74 | 79 |
75 void BookmarkSuggestionsProvider::ClearCachedSuggestionsForDebugging() { | 80 void BookmarkSuggestionsProvider::ClearCachedSuggestionsForDebugging() { |
76 // Ignored. | 81 // Ignored. |
77 } | 82 } |
78 | 83 |
79 void BookmarkSuggestionsProvider::ClearDismissedSuggestionsForDebugging() { | 84 void BookmarkSuggestionsProvider::ClearDismissedSuggestionsForDebugging() { |
80 // TODO(jkrcal): Implement when discarded suggestions are supported. | 85 // TODO(jkrcal): Implement when discarded suggestions are supported. |
81 } | 86 } |
82 | 87 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 | 154 |
150 void BookmarkSuggestionsProvider::NotifyStatusChanged( | 155 void BookmarkSuggestionsProvider::NotifyStatusChanged( |
151 CategoryStatus new_status) { | 156 CategoryStatus new_status) { |
152 if (category_status_ == new_status) | 157 if (category_status_ == new_status) |
153 return; | 158 return; |
154 category_status_ = new_status; | 159 category_status_ = new_status; |
155 observer()->OnCategoryStatusChanged(this, provided_category_, new_status); | 160 observer()->OnCategoryStatusChanged(this, provided_category_, new_status); |
156 } | 161 } |
157 | 162 |
158 } // namespace ntp_snippets | 163 } // namespace ntp_snippets |
OLD | NEW |