Commit 713805e4 authored by Mustafa Emre Acer's avatar Mustafa Emre Acer Committed by Commit Bot

Change engagement threshold to medium for lookalike URLs

The current threshold is LOW which corresponds to any non-zero score. This will cause any site with a non-zero engagement score to be ignored from lookalike suggestions.

The effect of this change is:
- The navigated site will be more likely to be considered for a lookalike suggestion
- The navigated site will be compared to fewer engaged sites

Bug: 878153
Change-Id: I19928398b207d36981736ed22e6a026263f93751
Reviewed-on: https://chromium-review.googlesource.com/c/1334851Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Commit-Queue: Mustafa Emre Acer <meacer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608067}
parent 2ddd7868
......@@ -73,7 +73,7 @@ void LookalikeUrlNavigationObserver::DidFinishNavigation(
Profile* profile =
Profile::FromBrowserContext(web_contents()->GetBrowserContext());
SiteEngagementService* service = SiteEngagementService::Get(profile);
if (service->IsEngagementAtLeast(url, blink::mojom::EngagementLevel::LOW))
if (service->IsEngagementAtLeast(url, blink::mojom::EngagementLevel::MEDIUM))
return;
const base::StringPiece host = url.host_piece();
......@@ -154,7 +154,7 @@ std::string LookalikeUrlNavigationObserver::GetMatchingSiteEngagementDomain(
for (const auto& detail : engagement_details) {
// Ignore sites with an engagement score lower than LOW.
if (!service->IsEngagementAtLeast(detail.origin,
blink::mojom::EngagementLevel::LOW))
blink::mojom::EngagementLevel::MEDIUM))
continue;
// If the user has engaged with eTLD+1 of this site, don't show any
......
......@@ -33,6 +33,12 @@ using UkmEntry = ukm::builders::LookalikeUrl_NavigationSuggestion;
enum class FeatureTestState { kDisabled, kEnabled };
// An engagement score above MEDIUM.
const int kHighEngagement = 20;
// An engagement score below MEDIUM.
const int kLowEngagement = 1;
struct SiteEngagementTestCase {
const char* const navigated;
const char* const suggested;
......@@ -201,7 +207,7 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationObserverBrowserTest,
IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationObserverBrowserTest,
TopDomainIdn_EngagedSite_NoInfobar) {
const GURL url = embedded_test_server()->GetURL("googlé.com", "/title1.html");
SetSiteEngagementScore(url, 20);
SetSiteEngagementScore(url, kHighEngagement);
TestInfobarNotShown(url);
CheckNoUkm();
}
......@@ -217,6 +223,9 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationObserverBrowserTest,
embedded_test_server()->GetURL("googlé.com", "/title1.html");
if (GetParam() == FeatureTestState::kEnabled) {
// Even if the navigated site has a low engagement score, it should be
// considered for lookalike suggestions.
SetSiteEngagementScore(kNavigatedUrl, kLowEngagement);
// If the feature is enabled, the UI will be displayed. Expect extra
// histogram entries for kInfobarShown and kLinkClicked events.
TestInfobarShown(kNavigatedUrl,
......@@ -256,16 +265,19 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationObserverBrowserTest,
// a feature param.
IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationObserverBrowserTest,
Idn_SiteEngagement_Match) {
SetSiteEngagementScore(GURL("http://site1.test"), 20);
SetSiteEngagementScore(GURL("http://www.site2.test"), 20);
SetSiteEngagementScore(GURL("http://sité3.test"), 20);
SetSiteEngagementScore(GURL("http://www.sité4.test"), 20);
SetSiteEngagementScore(GURL("http://site1.test"), kHighEngagement);
SetSiteEngagementScore(GURL("http://www.site2.test"), kHighEngagement);
SetSiteEngagementScore(GURL("http://sité3.test"), kHighEngagement);
SetSiteEngagementScore(GURL("http://www.sité4.test"), kHighEngagement);
std::vector<GURL> ukm_urls;
for (const auto& test_case : kSiteEngagementTestCases) {
base::HistogramTester histograms;
const GURL kNavigatedUrl =
embedded_test_server()->GetURL(test_case.navigated, "/title1.html");
// Even if the navigated site has a low engagement score, it should be
// considered for lookalike suggestions.
SetSiteEngagementScore(kNavigatedUrl, kLowEngagement);
if (GetParam() == FeatureTestState::kEnabled) {
// If the feature is enabled, the UI will be displayed. Expect extra
......@@ -306,6 +318,20 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationObserverBrowserTest,
LookalikeUrlNavigationObserver::MatchType::kSiteEngagement);
}
IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationObserverBrowserTest,
Idn_SiteEngagement_Match_Ignored) {
// Test that navigations to a site with a high engagement score shouldn't
// record metrics or show infobar.
base::HistogramTester histograms;
SetSiteEngagementScore(GURL("http://site5.test"), kHighEngagement);
const GURL high_engagement_url =
embedded_test_server()->GetURL("síte5.test", "/title1.html");
SetSiteEngagementScore(high_engagement_url, kHighEngagement);
TestInfobarNotShown(high_engagement_url);
histograms.ExpectTotalCount(LookalikeUrlNavigationObserver::kHistogramName,
0);
}
// IDNs with a single label should be properly handled. There are two cases
// where this might occur:
// 1. The navigated URL is an IDN with a single label.
......@@ -320,7 +346,7 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationObserverBrowserTest,
// Case 2: An IDN with a single label with a site engagement score shouldn't
// cause a crash.
SetSiteEngagementScore(GURL("http://tést"), 20);
SetSiteEngagementScore(GURL("http://tést"), kHighEngagement);
TestInfobarNotShown(
embedded_test_server()->GetURL("tést.com", "/title1.html"));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment