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

Unified Diff: components/history/core/browser/history_backend.cc

Issue 2338133006: [NTP] Fix article suggestion clicks contributing to Most Visited tiles (Closed)
Patch Set: Moved URL to constant. Created 4 years, 3 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
Index: components/history/core/browser/history_backend.cc
diff --git a/components/history/core/browser/history_backend.cc b/components/history/core/browser/history_backend.cc
index d92049f71f0fd19e42b304c6586d0cde80fb4702..47add3cb6699b91e9d74ff440eddfc2afc5c1906 100644
--- a/components/history/core/browser/history_backend.cc
+++ b/components/history/core/browser/history_backend.cc
@@ -71,6 +71,10 @@ namespace history {
namespace {
+// Referrer used for clicks on article suggestions on the NTP.
+const char kChromeContentSuggestionsReferrer[] =
+ "https://www.googleapis.com/auth/chrome-content-suggestions";
sky 2016/09/15 17:46:26 I like this approach much better, but I don't want
mastiz 2016/09/15 18:12:07 Would you be fine if we instead verify the referre
+
void RunUnlessCanceled(
const base::Closure& closure,
const base::CancelableTaskTracker::IsCanceledCallback& is_canceled) {
@@ -315,6 +319,7 @@ SegmentID HistoryBackend::GetLastSegmentID(VisitID from_visit) {
}
SegmentID HistoryBackend::UpdateSegments(const GURL& url,
+ const GURL& referrer,
VisitID from_visit,
VisitID visit_id,
ui::PageTransition transition_type,
@@ -343,8 +348,9 @@ SegmentID HistoryBackend::UpdateSegments(const GURL& url,
// http://crbug.com/96860 is fixed.
if ((ui::PageTransitionCoreTypeIs(transition_type,
ui::PAGE_TRANSITION_TYPED) ||
- ui::PageTransitionCoreTypeIs(transition_type,
- ui::PAGE_TRANSITION_AUTO_BOOKMARK)) &&
+ (ui::PageTransitionCoreTypeIs(transition_type,
+ ui::PAGE_TRANSITION_AUTO_BOOKMARK) &&
+ referrer != GURL(kChromeContentSuggestionsReferrer))) &&
(transition_type & ui::PAGE_TRANSITION_FORWARD_BACK) == 0) {
// If so, create or get the segment.
std::string segment_name = db_->ComputeSegmentName(url);
@@ -523,8 +529,8 @@ void HistoryBackend::AddPage(const HistoryAddPageArgs& request) {
// result in changing most visited, so we don't update segments (most
// visited db).
if (!is_keyword_generated) {
- UpdateSegments(request.url, from_visit_id, last_ids.second, t,
- request.time);
+ UpdateSegments(request.url, request.referrer, from_visit_id,
+ last_ids.second, t, request.time);
// Update the referrer's duration.
UpdateVisitDuration(from_visit_id, request.time);
@@ -593,8 +599,8 @@ void HistoryBackend::AddPage(const HistoryAddPageArgs& request) {
last_ids.second, t, request.visit_source);
if (t & ui::PAGE_TRANSITION_CHAIN_START) {
// Update the segment for this visit.
- UpdateSegments(redirects[redirect_index], from_visit_id,
- last_ids.second, t, request.time);
+ UpdateSegments(redirects[redirect_index], request.referrer,
+ from_visit_id, last_ids.second, t, request.time);
// Update the visit_details for this visit.
UpdateVisitDuration(from_visit_id, request.time);
« no previous file with comments | « components/history/core/browser/history_backend.h ('k') | components/history/core/browser/history_backend_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698