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

Unified Diff: chrome/browser/history/history_tab_helper.cc

Issue 2338133006: [NTP] Fix article suggestion clicks contributing to Most Visited tiles (Closed)
Patch Set: Updated trivial occurrence in unit test. 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: chrome/browser/history/history_tab_helper.cc
diff --git a/chrome/browser/history/history_tab_helper.cc b/chrome/browser/history/history_tab_helper.cc
index c633e3c9ad1b05c83343a5e8428ec84a4122faf0..9e192185247f34fc2cad8d2c859ed3447dece17c 100644
--- a/chrome/browser/history/history_tab_helper.cc
+++ b/chrome/browser/history/history_tab_helper.cc
@@ -30,6 +30,14 @@ using content::WebContents;
DEFINE_WEB_CONTENTS_USER_DATA_KEY(HistoryTabHelper);
+namespace {
+
+// Referrer used for clicks on article suggestions on the NTP.
+const char kChromeContentSuggestionsReferrer[] =
+ "https://www.googleapis.com/auth/chrome-content-suggestions";
+
+} // namespace
+
HistoryTabHelper::HistoryTabHelper(WebContents* web_contents)
: content::WebContentsObserver(web_contents),
received_page_title_(false) {
@@ -58,10 +66,16 @@ HistoryTabHelper::CreateHistoryAddPageArgs(
bool did_replace_entry,
int nav_entry_id,
const content::FrameNavigateParams& params) {
+ // Clicks on content suggestions on the NTP should not contribute to the
+ // Most Visited tiles in the NTP.
+ const bool consider_for_ntp_most_visited =
+ params.referrer.url != GURL(kChromeContentSuggestionsReferrer);
+
history::HistoryAddPageArgs add_page_args(
params.url, timestamp, history::ContextIDForWebContents(web_contents()),
nav_entry_id, params.referrer.url, params.redirects, params.transition,
- history::SOURCE_BROWSED, did_replace_entry);
+ history::SOURCE_BROWSED, did_replace_entry,
+ consider_for_ntp_most_visited);
if (ui::PageTransitionIsMainFrame(params.transition) &&
virtual_url != params.url) {
// Hack on the "virtual" URL so that it will appear in history. For some

Powered by Google App Engine
This is Rietveld 408576698