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" |
11 #include "base/location.h" | 11 #include "base/location.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "base/threading/thread_task_runner_handle.h" | 14 #include "base/threading/thread_task_runner_handle.h" |
15 #include "components/bookmarks/browser/bookmark_model.h" | 15 #include "components/bookmarks/browser/bookmark_model.h" |
16 #include "components/ntp_snippets/bookmarks/bookmark_last_visit_utils.h" | 16 #include "components/ntp_snippets/bookmarks/bookmark_last_visit_utils.h" |
17 #include "components/ntp_snippets/category_factory.h" | 17 #include "components/ntp_snippets/category_factory.h" |
18 #include "components/ntp_snippets/content_suggestion.h" | 18 #include "components/ntp_snippets/content_suggestion.h" |
19 #include "components/ntp_snippets/features.h" | 19 #include "components/ntp_snippets/features.h" |
20 #include "components/variations/variations_associated_data.h" | 20 #include "components/variations/variations_associated_data.h" |
| 21 #include "grit/components_strings.h" |
| 22 #include "ui/base/l10n/l10n_util.h" |
21 #include "ui/gfx/image/image.h" | 23 #include "ui/gfx/image/image.h" |
22 | 24 |
23 using bookmarks::BookmarkModel; | 25 using bookmarks::BookmarkModel; |
24 using bookmarks::BookmarkNode; | 26 using bookmarks::BookmarkNode; |
25 | 27 |
26 namespace { | 28 namespace { |
27 | 29 |
28 const int kMaxBookmarks = 10; | 30 const int kMaxBookmarks = 10; |
29 const int kMaxBookmarkAgeInDays = 42; | 31 const int kMaxBookmarkAgeInDays = 42; |
30 | 32 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 std::vector<Category> BookmarkSuggestionsProvider::GetProvidedCategories() { | 82 std::vector<Category> BookmarkSuggestionsProvider::GetProvidedCategories() { |
81 return std::vector<Category>({provided_category_}); | 83 return std::vector<Category>({provided_category_}); |
82 } | 84 } |
83 | 85 |
84 CategoryStatus BookmarkSuggestionsProvider::GetCategoryStatus( | 86 CategoryStatus BookmarkSuggestionsProvider::GetCategoryStatus( |
85 Category category) { | 87 Category category) { |
86 DCHECK_EQ(category, provided_category_); | 88 DCHECK_EQ(category, provided_category_); |
87 return category_status_; | 89 return category_status_; |
88 } | 90 } |
89 | 91 |
| 92 CategoryInfo BookmarkSuggestionsProvider::GetCategoryInfo(Category category) { |
| 93 return CategoryInfo( |
| 94 l10n_util::GetStringUTF16(IDS_NTP_BOOKMARK_SUGGESTIONS_SECTION_HEADER), |
| 95 ContentSuggestionsCardLayout::MINIMAL_CARD); |
| 96 } |
| 97 |
90 void BookmarkSuggestionsProvider::DismissSuggestion( | 98 void BookmarkSuggestionsProvider::DismissSuggestion( |
91 const std::string& suggestion_id) { | 99 const std::string& suggestion_id) { |
92 // TODO(jkrcal): Implement blacklisting bookmarks until they are next visited. | 100 // TODO(jkrcal): Implement blacklisting bookmarks until they are next visited. |
93 // Then also implement ClearDismissedSuggestionsForDebugging. | 101 // Then also implement ClearDismissedSuggestionsForDebugging. |
94 } | 102 } |
95 | 103 |
96 void BookmarkSuggestionsProvider::FetchSuggestionImage( | 104 void BookmarkSuggestionsProvider::FetchSuggestionImage( |
97 const std::string& suggestion_id, | 105 const std::string& suggestion_id, |
98 const ImageFetchedCallback& callback) { | 106 const ImageFetchedCallback& callback) { |
99 base::ThreadTaskRunnerHandle::Get()->PostTask( | 107 base::ThreadTaskRunnerHandle::Get()->PostTask( |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 | 198 |
191 void BookmarkSuggestionsProvider::NotifyStatusChanged( | 199 void BookmarkSuggestionsProvider::NotifyStatusChanged( |
192 CategoryStatus new_status) { | 200 CategoryStatus new_status) { |
193 if (category_status_ == new_status) | 201 if (category_status_ == new_status) |
194 return; | 202 return; |
195 category_status_ = new_status; | 203 category_status_ = new_status; |
196 observer()->OnCategoryStatusChanged(this, provided_category_, new_status); | 204 observer()->OnCategoryStatusChanged(this, provided_category_, new_status); |
197 } | 205 } |
198 | 206 |
199 } // namespace ntp_snippets | 207 } // namespace ntp_snippets |
OLD | NEW |