Skip to content

Commit

Permalink
Do not pollute history entries when user clicks on user tiles (kiwibr…
Browse files Browse the repository at this point in the history
…owser.org)
  • Loading branch information
kiwibrowser committed Feb 6, 2021
1 parent 7bdaa1a commit 2197e0c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
36 changes: 36 additions & 0 deletions components/history/core/browser/history_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -791,6 +808,25 @@ std::pair<URLID, VisitID> 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)
Expand Down

0 comments on commit 2197e0c

Please sign in to comment.