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

Unified Diff: components/ntp_snippets/bookmarks/bookmark_suggestions_provider.cc

Issue 2275613002: Bookmark Suggestions: Make 'creation date fallback' time configurable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix_proguard
Patch Set: comment 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 d128b82ae212d95ddcc56359819c4458f8a62d02..7c9a26378dd246251fdddbb34ff9c9633b28c181 100644
--- a/components/ntp_snippets/bookmarks/bookmark_suggestions_provider.cc
+++ b/components/ntp_snippets/bookmarks/bookmark_suggestions_provider.cc
@@ -39,6 +39,8 @@ const int kUseCreationDateFallbackForDays = 42;
const char* kMaxBookmarksParamName = "bookmarks_max_count";
const char* kMinBookmarksParamName = "bookmarks_min_count";
const char* kMaxBookmarkAgeInDaysParamName = "bookmarks_max_age_in_days";
+const char* kUseCreationDateFallbackForDaysParamName =
+ "bookmarks_creation_date_fallback_days";
base::Time GetThresholdTime() {
std::string age_in_days_string = variations::GetVariationParamValueByFeature(
@@ -52,6 +54,19 @@ base::Time GetThresholdTime() {
return base::Time::Now() - base::TimeDelta::FromDays(age_in_days);
}
+int UseCreationDateFallbackForDays() {
+ std::string days_string = variations::GetVariationParamValueByFeature(
+ ntp_snippets::kBookmarkSuggestionsFeature,
+ kUseCreationDateFallbackForDaysParamName);
+ int days = 0;
+ if (!base::StringToInt(days_string, &days)) {
+ if (!days_string.empty())
+ LOG(WARNING) << "Failed to parse bookmark fallback days " << days_string;
+ days = kUseCreationDateFallbackForDays;
+ }
+ return days;
+}
+
int GetMaxCount() {
std::string max_count_string = variations::GetVariationParamValueByFeature(
ntp_snippets::kBookmarkSuggestionsFeature, kMaxBookmarksParamName);
@@ -104,8 +119,10 @@ BookmarkSuggestionsProvider::BookmarkSuggestionsProvider(
first_m54_start.ToInternalValue());
}
base::TimeDelta time_since_first_m54_start = now - first_m54_start;
+ // Note: Setting the fallback timeout to zero effectively turns off the
+ // fallback entirely.
creation_date_fallback_ =
- time_since_first_m54_start.InDays() < kUseCreationDateFallbackForDays;
+ time_since_first_m54_start.InDays() < UseCreationDateFallbackForDays();
bookmark_model_->AddObserver(this);
FetchBookmarks();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698