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

Unified Diff: chrome/browser/ui/webui/ntp/suggestions_source_top_sites.cc

Issue 10060003: Support for different weight-functions for time-slicing. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Added missing #include Created 8 years, 7 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 | « chrome/browser/ui/webui/ntp/suggestions_source_top_sites.h ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/ntp/suggestions_source_top_sites.cc
diff --git a/chrome/browser/ui/webui/ntp/suggestions_source_top_sites.cc b/chrome/browser/ui/webui/ntp/suggestions_source_top_sites.cc
index 9e6d32c723eeb781691f47fa9170dff36ae1cca2..8a8f5be38aed87af45a242d2a6ce76630003af39 100644
--- a/chrome/browser/ui/webui/ntp/suggestions_source_top_sites.cc
+++ b/chrome/browser/ui/webui/ntp/suggestions_source_top_sites.cc
@@ -6,13 +6,17 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
+#include "base/command_line.h"
#include "base/stl_util.h"
#include "base/values.h"
+#include "base/string_number_conversions.h"
#include "chrome/browser/history/top_sites.h"
#include "chrome/browser/history/visit_filter.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
#include "chrome/browser/ui/webui/ntp/suggestions_combiner.h"
+#include "chrome/common/chrome_switches.h"
+
namespace {
@@ -56,10 +60,10 @@ void SuggestionsSourceTopSites::FetchItems(Profile* profile) {
// |history| may be null during unit tests.
if (history) {
history::VisitFilter time_filter;
- base::TimeDelta half_an_hour =
- base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerHour / 2);
- base::Time now = base::Time::Now();
- time_filter.SetTimeInRangeFilter(now - half_an_hour, now + half_an_hour);
+ time_filter.SetFilterTime(base::Time::Now());
+ time_filter.SetFilterWidth(GetFilterWidth());
+ time_filter.set_sorting_order(GetSortingOrder());
+
history->QueryFilteredURLs(0, time_filter, &history_consumer_,
base::Bind(&SuggestionsSourceTopSites::OnSuggestionsURLsAvailable,
base::Unretained(this)));
@@ -90,3 +94,25 @@ void SuggestionsSourceTopSites::OnSuggestionsURLsAvailable(
combiner_->OnItemsReady();
}
+
+// static
+base::TimeDelta SuggestionsSourceTopSites::GetFilterWidth() {
+ const CommandLine* cli = CommandLine::ForCurrentProcess();
+ const std::string filter_width_switch =
+ cli->GetSwitchValueASCII(switches::kSuggestionNtpFilterWidth);
+ unsigned int filter_width;
+ if (base::StringToUint(filter_width_switch, &filter_width))
+ return base::TimeDelta::FromMinutes(filter_width);
+ return base::TimeDelta::FromHours(1);
+}
+
+// static
+history::VisitFilter::SortingOrder
+SuggestionsSourceTopSites::GetSortingOrder() {
+ const CommandLine* cli = CommandLine::ForCurrentProcess();
+ if (cli->HasSwitch(switches::kSuggestionNtpGaussianFilter))
+ return history::VisitFilter::ORDER_BY_TIME_GAUSSIAN;
+ if (cli->HasSwitch(switches::kSuggestionNtpLinearFilter))
+ return history::VisitFilter::ORDER_BY_TIME_LINEAR;
+ return history::VisitFilter::ORDER_BY_RECENCY;
+}
« no previous file with comments | « chrome/browser/ui/webui/ntp/suggestions_source_top_sites.h ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698