Chromium Code Reviews| 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 7090d1281a185e1bfc740092db81d18213b1f331..04395e5c570d511e5f7abd467f852a0437dedffc 100644 |
| --- a/components/ntp_snippets/bookmarks/bookmark_suggestions_provider.cc |
| +++ b/components/ntp_snippets/bookmarks/bookmark_suggestions_provider.cc |
| @@ -28,9 +28,11 @@ using bookmarks::BookmarkNode; |
| namespace { |
| const int kMaxBookmarks = 10; |
| +const int kMinBookmarks = 3; |
| const int kMaxBookmarkAgeInDays = 42; |
| const char* kMaxBookmarksParamName = "max_count"; |
| +const char* kMinBookmarksParamName = "min_count"; |
| const char* kMaxBookmarkAgeInDaysParamName = "max_age_in_days"; |
|
Marc Treib
2016/08/18 09:31:44
Unrelated to this CL, but: AFAIK these param names
Philipp Keck
2016/08/19 11:20:54
Done.
|
| base::Time GetThresholdTime() { |
| @@ -45,7 +47,7 @@ base::Time GetThresholdTime() { |
| int GetMaxCount() { |
| std::string max_count_string = variations::GetVariationParamValueByFeature( |
| - ntp_snippets::kBookmarkSuggestionsFeature, kMaxBookmarksParamName); |
| + ntp_snippets::kBookmarkSuggestionsFeature, kMaxBookmarksParamName); |
| int max_count = 0; |
| if (base::StringToInt(max_count_string, &max_count)) |
| return max_count; |
| @@ -53,6 +55,16 @@ int GetMaxCount() { |
| return kMaxBookmarks; |
| } |
| +int GetMinCount() { |
| + std::string min_count_string = variations::GetVariationParamValueByFeature( |
| + ntp_snippets::kBookmarkSuggestionsFeature, kMinBookmarksParamName); |
| + int min_count = 0; |
| + if (base::StringToInt(min_count_string, &min_count)) |
|
Marc Treib
2016/08/18 09:31:44
nit: If the string is non-empty but fails to parse
Philipp Keck
2016/08/19 11:20:54
Done.
|
| + return min_count; |
| + |
| + return kMinBookmarks; |
| +} |
| + |
| } // namespace |
| namespace ntp_snippets { |
| @@ -201,7 +213,8 @@ void BookmarkSuggestionsProvider::FetchBookmarksInternal() { |
| base::Time threshold_time = GetThresholdTime(); |
| std::vector<const BookmarkNode*> bookmarks = GetRecentlyVisitedBookmarks( |
| - bookmark_model_, GetMaxCount(), threshold_time); |
| + bookmark_model_, GetMinCount(), GetMaxCount(), |
| + threshold_time); |
| std::vector<ContentSuggestion> suggestions; |
| for (const BookmarkNode* bookmark : bookmarks) |