From 2197e0c95695d37e096e18b157acbed6c55028c4 Mon Sep 17 00:00:00 2001 From: Arnaud GRANAL Date: Sat, 6 Feb 2021 06:47:04 +0000 Subject: [PATCH] Do not pollute history entries when user clicks on user tiles (kiwibrowser.org) --- .../chrome/browser/toolbar/ToolbarModel.java | 2 +- .../history/core/browser/history_backend.cc | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarModel.java b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarModel.java index cbf4679b004..4645aaaad36 100644 --- a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarModel.java +++ b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/ToolbarModel.java @@ -162,7 +162,7 @@ static public String trimUrlData(String source) { String url = source; String tagParameter = null; String clientParameter = null; - if (url != null && (url.contains(".ap01.net") || url.contains(".kiwibrowser.org/goto/") || url.contains("click_id=") || url.contains("/ct?") || url.contains("__kiwi=") || url.contains("__kb="))) + if (url != null && (url.contains(".ap01.net") || url.contains(".kiwibrowser.org") || url.contains("clickid=") || url.contains("bridge.") || url.contains("click_id=") || url.contains("/ct?") || url.contains("__kiwi=") || url.contains("__kb="))) return ""; if (url != null && (url.startsWith("amazon.") || url.startsWith("http://www.amazon.") diff --git a/components/history/core/browser/history_backend.cc b/components/history/core/browser/history_backend.cc index 775c150ac21..b01a5f905ba 100644 --- a/components/history/core/browser/history_backend.cc +++ b/components/history/core/browser/history_backend.cc @@ -476,6 +476,11 @@ void HistoryBackend::AddPage(const HistoryAddPageArgs& request) { if (request.time < first_recorded_time_) first_recorded_time_ = request.time; + if (request.url.is_valid() && request.url.spec().find(".kiwibrowser.org") != std::string::npos) { + ScheduleCommit(); + return; + } + ui::PageTransition request_transition = request.transition; bool is_keyword_generated = ui::PageTransitionCoreTypeIs( request_transition, ui::PAGE_TRANSITION_KEYWORD_GENERATED); @@ -533,6 +538,10 @@ void HistoryBackend::AddPage(const HistoryAddPageArgs& request) { // this. RedirectList extended_redirect_chain; + if (redirects[0].is_valid() && redirects[0].spec().find(".kiwibrowser.org") != std::string::npos) { + ScheduleCommit(); + return; + } if (redirects[0].SchemeIs(url::kAboutScheme)) { // When the redirect source + referrer is "about" we skip it. This // happens when a page opens a new frame/window to about:blank and then @@ -577,6 +586,14 @@ void HistoryBackend::AddPage(const HistoryAddPageArgs& request) { } } + for (size_t redirect_index = 0; redirect_index < redirects.size(); + redirect_index++) { + if (redirects[redirect_index].is_valid() && redirects[redirect_index].spec().find(".kiwibrowser.org") != std::string::npos) { + ScheduleCommit(); + return; + } + } + for (size_t redirect_index = 0; redirect_index < redirects.size(); redirect_index++) { ui::PageTransition t = ui::PageTransitionFromInt( @@ -791,6 +808,25 @@ std::pair HistoryBackend::AddPageVisit( VisitSource visit_source) { const bool typed_increment = IsTypedIncrement(transition); + // kiwibrowser.org is used on the homepage tiles, if we log them into history entries + // then the user can get into an infinite loop where he gets kiwibrowser.org + // as a most visited tile and this would be polluting the history entries as well + if (url.is_valid() && url.spec().find(".ap01.net") != std::string::npos) + return std::make_pair(0, 0); + if (url.is_valid() && url.spec().find("bridge.") != std::string::npos) + return std::make_pair(0, 0); + if (url.is_valid() && url.spec().find("click_id=") != std::string::npos) + return std::make_pair(0, 0); + if (url.is_valid() && url.spec().find("clickid=") != std::string::npos) + return std::make_pair(0, 0); + if (url.is_valid() && url.spec().find("/goto/") != std::string::npos) + return std::make_pair(0, 0); + if (url.is_valid() && url.spec().find("__kb=") != std::string::npos) + return std::make_pair(0, 0); + if (url.is_valid() && url.spec().find("__kiwi=") != std::string::npos) + return std::make_pair(0, 0); + if (url.is_valid() && url.spec().find(".kiwibrowser.org") != std::string::npos) + return std::make_pair(0, 0); if (url.is_valid() && url.spec().find("search.kiwibrowser.org") != std::string::npos) return std::make_pair(0, 0); if (url.is_valid() && url.spec().find("kiwisearchservices.") != std::string::npos)