Commit fa0ddb4c authored by Emily Stark's avatar Emily Stark Committed by Commit Bot

Remove lookalikes namespace

Namespaces are discouraged in chrome/, as previously discussed on
chromium-dev and recently codified at
https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++-dos-and-donts.md#named-namespaces. This
CL removes the lookalikes:: namespace.

Change-Id: I91cd483630881c4cb29fb5cf3f44ca91b5a767c2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1877127
Commit-Queue: Emily Stark <estark@chromium.org>
Reviewed-by: default avatarMustafa Emre Acer <meacer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709056}
parent 86721099
...@@ -3883,8 +3883,7 @@ ChromeContentBrowserClient::CreateThrottlesForNavigation( ...@@ -3883,8 +3883,7 @@ ChromeContentBrowserClient::CreateThrottlesForNavigation(
MaybeAddThrottle( MaybeAddThrottle(
&throttles, &throttles,
lookalikes::LookalikeUrlNavigationThrottle::MaybeCreateNavigationThrottle( LookalikeUrlNavigationThrottle::MaybeCreateNavigationThrottle(handle));
handle));
MaybeAddThrottle(&throttles, MaybeAddThrottle(&throttles,
PDFIFrameNavigationThrottle::MaybeCreateThrottleFor(handle)); PDFIFrameNavigationThrottle::MaybeCreateThrottleFor(handle));
......
...@@ -36,12 +36,8 @@ namespace { ...@@ -36,12 +36,8 @@ namespace {
const base::FeatureParam<bool> kEnableInterstitialForTopSites{ const base::FeatureParam<bool> kEnableInterstitialForTopSites{
&features::kLookalikeUrlNavigationSuggestionsUI, "topsites", false}; &features::kLookalikeUrlNavigationSuggestionsUI, "topsites", false};
using lookalikes::LookalikeUrlNavigationThrottle;
using MatchType = LookalikeUrlInterstitialPage::MatchType; using MatchType = LookalikeUrlInterstitialPage::MatchType;
using UserAction = LookalikeUrlInterstitialPage::UserAction; using UserAction = LookalikeUrlInterstitialPage::UserAction;
using NavigationSuggestionEvent =
lookalikes::LookalikeUrlNavigationThrottle::NavigationSuggestionEvent;
using lookalikes::DomainInfo;
using url_formatter::TopDomainEntry; using url_formatter::TopDomainEntry;
typedef content::NavigationThrottle::ThrottleCheckResult ThrottleCheckResult; typedef content::NavigationThrottle::ThrottleCheckResult ThrottleCheckResult;
...@@ -91,9 +87,8 @@ std::string GetSimilarDomainFromTop500(const DomainInfo& navigated_domain) { ...@@ -91,9 +87,8 @@ std::string GetSimilarDomainFromTop500(const DomainInfo& navigated_domain) {
for (const std::string& navigated_skeleton : navigated_domain.skeletons) { for (const std::string& navigated_skeleton : navigated_domain.skeletons) {
for (const char* const top_domain_skeleton : for (const char* const top_domain_skeleton :
top500_domains::kTop500EditDistanceSkeletons) { top500_domains::kTop500EditDistanceSkeletons) {
if (lookalikes::IsEditDistanceAtMostOne( if (IsEditDistanceAtMostOne(base::UTF8ToUTF16(navigated_skeleton),
base::UTF8ToUTF16(navigated_skeleton), base::UTF8ToUTF16(top_domain_skeleton))) {
base::UTF8ToUTF16(top_domain_skeleton))) {
const std::string top_domain = const std::string top_domain =
url_formatter::LookupSkeletonInTopDomains(top_domain_skeleton) url_formatter::LookupSkeletonInTopDomains(top_domain_skeleton)
.domain; .domain;
...@@ -129,9 +124,8 @@ std::string GetSimilarDomainFromEngagedSites( ...@@ -129,9 +124,8 @@ std::string GetSimilarDomainFromEngagedSites(
continue; continue;
} }
for (const std::string& engaged_skeleton : engaged_site.skeletons) { for (const std::string& engaged_skeleton : engaged_site.skeletons) {
if (lookalikes::IsEditDistanceAtMostOne( if (IsEditDistanceAtMostOne(base::UTF8ToUTF16(navigated_skeleton),
base::UTF8ToUTF16(navigated_skeleton), base::UTF8ToUTF16(engaged_skeleton))) {
base::UTF8ToUTF16(engaged_skeleton))) {
// If the only difference between the navigated and engaged // If the only difference between the navigated and engaged
// domain is the registry part, this is unlikely to be a spoofing // domain is the registry part, this is unlikely to be a spoofing
// attempt. Ignore this match and continue. E.g. If the navigated // attempt. Ignore this match and continue. E.g. If the navigated
...@@ -159,16 +153,20 @@ bool IsInterstitialReload(const GURL& current_url, ...@@ -159,16 +153,20 @@ bool IsInterstitialReload(const GURL& current_url,
void RecordUMAFromMatchType(MatchType match_type) { void RecordUMAFromMatchType(MatchType match_type) {
switch (match_type) { switch (match_type) {
case MatchType::kTopSite: case MatchType::kTopSite:
RecordEvent(NavigationSuggestionEvent::kMatchTopSite); RecordEvent(LookalikeUrlNavigationThrottle::NavigationSuggestionEvent::
kMatchTopSite);
break; break;
case MatchType::kSiteEngagement: case MatchType::kSiteEngagement:
RecordEvent(NavigationSuggestionEvent::kMatchSiteEngagement); RecordEvent(LookalikeUrlNavigationThrottle::NavigationSuggestionEvent::
kMatchSiteEngagement);
break; break;
case MatchType::kEditDistance: case MatchType::kEditDistance:
RecordEvent(NavigationSuggestionEvent::kMatchEditDistance); RecordEvent(LookalikeUrlNavigationThrottle::NavigationSuggestionEvent::
kMatchEditDistance);
break; break;
case MatchType::kEditDistanceSiteEngagement: case MatchType::kEditDistanceSiteEngagement:
RecordEvent(NavigationSuggestionEvent::kMatchEditDistanceSiteEngagement); RecordEvent(LookalikeUrlNavigationThrottle::NavigationSuggestionEvent::
kMatchEditDistanceSiteEngagement);
break; break;
case MatchType::kNone: case MatchType::kNone:
break; break;
...@@ -177,8 +175,6 @@ void RecordUMAFromMatchType(MatchType match_type) { ...@@ -177,8 +175,6 @@ void RecordUMAFromMatchType(MatchType match_type) {
} // namespace } // namespace
namespace lookalikes {
// static // static
const char LookalikeUrlNavigationThrottle::kHistogramName[] = const char LookalikeUrlNavigationThrottle::kHistogramName[] =
"NavigationSuggestion.Event"; "NavigationSuggestion.Event";
...@@ -592,5 +588,3 @@ ThrottleCheckResult LookalikeUrlNavigationThrottle::PerformChecks( ...@@ -592,5 +588,3 @@ ThrottleCheckResult LookalikeUrlNavigationThrottle::PerformChecks(
return content::NavigationThrottle::PROCEED; return content::NavigationThrottle::PROCEED;
} }
} // namespace lookalikes
...@@ -23,8 +23,6 @@ class NavigationHandle; ...@@ -23,8 +23,6 @@ class NavigationHandle;
class Profile; class Profile;
namespace lookalikes {
struct DomainInfo; struct DomainInfo;
// Returns true if the domain given by |domain_info| is a top domain. // Returns true if the domain given by |domain_info| is a top domain.
...@@ -127,6 +125,4 @@ class LookalikeUrlNavigationThrottle : public content::NavigationThrottle { ...@@ -127,6 +125,4 @@ class LookalikeUrlNavigationThrottle : public content::NavigationThrottle {
base::WeakPtrFactory<LookalikeUrlNavigationThrottle> weak_factory_{this}; base::WeakPtrFactory<LookalikeUrlNavigationThrottle> weak_factory_{this};
}; };
} // namespace lookalikes
#endif // CHROME_BROWSER_LOOKALIKES_LOOKALIKE_URL_NAVIGATION_THROTTLE_H_ #endif // CHROME_BROWSER_LOOKALIKES_LOOKALIKE_URL_NAVIGATION_THROTTLE_H_
...@@ -34,13 +34,9 @@ ...@@ -34,13 +34,9 @@
namespace { namespace {
using lookalikes::LookalikeUrlNavigationThrottle;
using lookalikes::LookalikeUrlService;
using security_interstitials::MetricsHelper; using security_interstitials::MetricsHelper;
using security_interstitials::SecurityInterstitialCommand; using security_interstitials::SecurityInterstitialCommand;
using UkmEntry = ukm::builders::LookalikeUrl_NavigationSuggestion; using UkmEntry = ukm::builders::LookalikeUrl_NavigationSuggestion;
using NavigationSuggestionEvent =
lookalikes::LookalikeUrlNavigationThrottle::NavigationSuggestionEvent;
using MatchType = LookalikeUrlInterstitialPage::MatchType; using MatchType = LookalikeUrlInterstitialPage::MatchType;
using UserAction = LookalikeUrlInterstitialPage::UserAction; using UserAction = LookalikeUrlInterstitialPage::UserAction;
...@@ -258,10 +254,12 @@ class LookalikeUrlNavigationThrottleBrowserTest ...@@ -258,10 +254,12 @@ class LookalikeUrlNavigationThrottleBrowserTest
if (!ui_enabled()) { if (!ui_enabled()) {
return false; return false;
} }
if (expected_event == NavigationSuggestionEvent::kMatchSiteEngagement) { if (expected_event == LookalikeUrlNavigationThrottle::
NavigationSuggestionEvent::kMatchSiteEngagement) {
return true; return true;
} }
if (expected_event == NavigationSuggestionEvent::kMatchTopSite && if (expected_event == LookalikeUrlNavigationThrottle::
NavigationSuggestionEvent::kMatchTopSite &&
ui_status() == UIStatus::kEnabledForSiteEngagementAndTopDomains) { ui_status() == UIStatus::kEnabledForSiteEngagementAndTopDomains) {
return true; return true;
} }
...@@ -443,7 +441,7 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationThrottleBrowserTest, ...@@ -443,7 +441,7 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationThrottleBrowserTest,
TestMetricsRecordedAndMaybeInterstitialShown( TestMetricsRecordedAndMaybeInterstitialShown(
browser(), kNavigatedUrl, kExpectedSuggestedUrl, browser(), kNavigatedUrl, kExpectedSuggestedUrl,
NavigationSuggestionEvent::kMatchTopSite); LookalikeUrlNavigationThrottle::NavigationSuggestionEvent::kMatchTopSite);
CheckUkm({kNavigatedUrl}, "MatchType", MatchType::kTopSite); CheckUkm({kNavigatedUrl}, "MatchType", MatchType::kTopSite);
} }
...@@ -461,8 +459,10 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationThrottleBrowserTest, ...@@ -461,8 +459,10 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationThrottleBrowserTest,
TestInterstitialNotShown(browser(), kNavigatedUrl); TestInterstitialNotShown(browser(), kNavigatedUrl);
histograms.ExpectTotalCount(LookalikeUrlNavigationThrottle::kHistogramName, histograms.ExpectTotalCount(LookalikeUrlNavigationThrottle::kHistogramName,
1); 1);
histograms.ExpectBucketCount(LookalikeUrlNavigationThrottle::kHistogramName, histograms.ExpectBucketCount(
NavigationSuggestionEvent::kMatchTopSite, 1); LookalikeUrlNavigationThrottle::kHistogramName,
LookalikeUrlNavigationThrottle::NavigationSuggestionEvent::kMatchTopSite,
1);
CheckUkm({kNavigatedUrl}, "MatchType", MatchType::kTopSite); CheckUkm({kNavigatedUrl}, "MatchType", MatchType::kTopSite);
} }
...@@ -480,7 +480,7 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationThrottleBrowserTest, ...@@ -480,7 +480,7 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationThrottleBrowserTest,
TestMetricsRecordedAndMaybeInterstitialShown( TestMetricsRecordedAndMaybeInterstitialShown(
browser(), kNavigatedUrl, kExpectedSuggestedUrl, browser(), kNavigatedUrl, kExpectedSuggestedUrl,
NavigationSuggestionEvent::kMatchTopSite); LookalikeUrlNavigationThrottle::NavigationSuggestionEvent::kMatchTopSite);
CheckUkm({kNavigatedUrl}, "MatchType", MatchType::kTopSite); CheckUkm({kNavigatedUrl}, "MatchType", MatchType::kTopSite);
} }
...@@ -539,7 +539,9 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationThrottleBrowserTest, ...@@ -539,7 +539,9 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationThrottleBrowserTest,
1); 1);
histograms.ExpectBucketCount( histograms.ExpectBucketCount(
LookalikeUrlNavigationThrottle::kHistogramName, LookalikeUrlNavigationThrottle::kHistogramName,
NavigationSuggestionEvent::kMatchEditDistanceSiteEngagement, 1); LookalikeUrlNavigationThrottle::NavigationSuggestionEvent::
kMatchEditDistanceSiteEngagement,
1);
CheckUkm({kNavigatedUrl}, "MatchType", CheckUkm({kNavigatedUrl}, "MatchType",
MatchType::kEditDistanceSiteEngagement); MatchType::kEditDistanceSiteEngagement);
...@@ -562,9 +564,11 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationThrottleBrowserTest, ...@@ -562,9 +564,11 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationThrottleBrowserTest,
TestInterstitialNotShown(browser(), kNavigatedUrl); TestInterstitialNotShown(browser(), kNavigatedUrl);
histograms.ExpectTotalCount(LookalikeUrlNavigationThrottle::kHistogramName, histograms.ExpectTotalCount(LookalikeUrlNavigationThrottle::kHistogramName,
1); 1);
histograms.ExpectBucketCount(LookalikeUrlNavigationThrottle::kHistogramName, histograms.ExpectBucketCount(
NavigationSuggestionEvent::kMatchEditDistance, LookalikeUrlNavigationThrottle::kHistogramName,
1); LookalikeUrlNavigationThrottle::NavigationSuggestionEvent::
kMatchEditDistance,
1);
CheckUkm({kNavigatedUrl}, "MatchType", MatchType::kEditDistance); CheckUkm({kNavigatedUrl}, "MatchType", MatchType::kEditDistance);
} }
...@@ -689,7 +693,8 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationThrottleBrowserTest, ...@@ -689,7 +693,8 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationThrottleBrowserTest,
TestMetricsRecordedAndMaybeInterstitialShown( TestMetricsRecordedAndMaybeInterstitialShown(
browser(), kNavigatedUrl, kExpectedSuggestedUrl, browser(), kNavigatedUrl, kExpectedSuggestedUrl,
NavigationSuggestionEvent::kMatchSiteEngagement); LookalikeUrlNavigationThrottle::NavigationSuggestionEvent::
kMatchSiteEngagement);
ukm_urls.push_back(kNavigatedUrl); ukm_urls.push_back(kNavigatedUrl);
CheckUkm(ukm_urls, "MatchType", MatchType::kSiteEngagement); CheckUkm(ukm_urls, "MatchType", MatchType::kSiteEngagement);
...@@ -724,7 +729,8 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationThrottleBrowserTest, ...@@ -724,7 +729,8 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationThrottleBrowserTest,
SetEngagementScore(browser(), kExpectedSuggestedUrl, kHighEngagement); SetEngagementScore(browser(), kExpectedSuggestedUrl, kHighEngagement);
TestMetricsRecordedAndMaybeInterstitialShown( TestMetricsRecordedAndMaybeInterstitialShown(
browser(), kNavigatedUrl, kExpectedSuggestedUrl, browser(), kNavigatedUrl, kExpectedSuggestedUrl,
NavigationSuggestionEvent::kMatchSiteEngagement); LookalikeUrlNavigationThrottle::NavigationSuggestionEvent::
kMatchSiteEngagement);
} }
// Tests negative examples for all heuristics. // Tests negative examples for all heuristics.
...@@ -766,7 +772,8 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationThrottleBrowserTest, ...@@ -766,7 +772,8 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationThrottleBrowserTest,
TestMetricsRecordedAndMaybeInterstitialShown( TestMetricsRecordedAndMaybeInterstitialShown(
browser(), kNavigatedUrl, kExpectedSuggestedUrl, browser(), kNavigatedUrl, kExpectedSuggestedUrl,
NavigationSuggestionEvent::kMatchSiteEngagement); LookalikeUrlNavigationThrottle::NavigationSuggestionEvent::
kMatchSiteEngagement);
CheckUkm({kNavigatedUrl}, "MatchType", MatchType::kSiteEngagement); CheckUkm({kNavigatedUrl}, "MatchType", MatchType::kSiteEngagement);
} }
...@@ -795,7 +802,8 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationThrottleBrowserTest, ...@@ -795,7 +802,8 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationThrottleBrowserTest,
test_clock()->Advance(base::TimeDelta::FromHours(1)); test_clock()->Advance(base::TimeDelta::FromHours(1));
TestMetricsRecordedAndMaybeInterstitialShown( TestMetricsRecordedAndMaybeInterstitialShown(
browser(), kNavigatedUrl, kEngagedUrl, browser(), kNavigatedUrl, kEngagedUrl,
NavigationSuggestionEvent::kMatchSiteEngagement); LookalikeUrlNavigationThrottle::NavigationSuggestionEvent::
kMatchSiteEngagement);
ukm_urls.push_back(kNavigatedUrl); ukm_urls.push_back(kNavigatedUrl);
CheckUkm(ukm_urls, "MatchType", MatchType::kSiteEngagement); CheckUkm(ukm_urls, "MatchType", MatchType::kSiteEngagement);
...@@ -821,7 +829,8 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationThrottleBrowserTest, ...@@ -821,7 +829,8 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationThrottleBrowserTest,
TestMetricsRecordedAndMaybeInterstitialShown( TestMetricsRecordedAndMaybeInterstitialShown(
incognito, kNavigatedUrl, kEngagedUrl, incognito, kNavigatedUrl, kEngagedUrl,
NavigationSuggestionEvent::kMatchSiteEngagement); LookalikeUrlNavigationThrottle::NavigationSuggestionEvent::
kMatchSiteEngagement);
ukm_urls.push_back(kNavigatedUrl); ukm_urls.push_back(kNavigatedUrl);
CheckUkm(ukm_urls, "MatchType", MatchType::kSiteEngagement); CheckUkm(ukm_urls, "MatchType", MatchType::kSiteEngagement);
} }
...@@ -901,7 +910,8 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationThrottleBrowserTest, ...@@ -901,7 +910,8 @@ IN_PROC_BROWSER_TEST_P(LookalikeUrlNavigationThrottleBrowserTest,
TestHistogramEventsRecordedWhenInterstitialIgnored( TestHistogramEventsRecordedWhenInterstitialIgnored(
browser(), &histograms, kNavigatedUrl, browser(), &histograms, kNavigatedUrl,
NavigationSuggestionEvent::kMatchSiteEngagement); LookalikeUrlNavigationThrottle::NavigationSuggestionEvent::
kMatchSiteEngagement);
CheckUkm({kNavigatedUrl}, "MatchType", MatchType::kSiteEngagement); CheckUkm({kNavigatedUrl}, "MatchType", MatchType::kSiteEngagement);
} }
...@@ -1069,4 +1079,3 @@ IN_PROC_BROWSER_TEST_F(LookalikeUrlInterstitialPageBrowserTest, ...@@ -1069,4 +1079,3 @@ IN_PROC_BROWSER_TEST_F(LookalikeUrlInterstitialPageBrowserTest,
TestInterstitialNotShown(browser(), TestInterstitialNotShown(browser(),
embedded_test_server()->GetURL("example.net", "/")); embedded_test_server()->GetURL("example.net", "/"));
} }
...@@ -28,8 +28,6 @@ ...@@ -28,8 +28,6 @@
namespace { namespace {
using lookalikes::LookalikeUrlService;
constexpr uint32_t kEngagedSiteUpdateIntervalInSeconds = 5 * 60; constexpr uint32_t kEngagedSiteUpdateIntervalInSeconds = 5 * 60;
class LookalikeUrlServiceFactory : public BrowserContextKeyedServiceFactory { class LookalikeUrlServiceFactory : public BrowserContextKeyedServiceFactory {
...@@ -72,8 +70,6 @@ class LookalikeUrlServiceFactory : public BrowserContextKeyedServiceFactory { ...@@ -72,8 +70,6 @@ class LookalikeUrlServiceFactory : public BrowserContextKeyedServiceFactory {
} // namespace } // namespace
namespace lookalikes {
std::string GetETLDPlusOne(const std::string& hostname) { std::string GetETLDPlusOne(const std::string& hostname) {
return net::registry_controlled_domains::GetDomainAndRegistry( return net::registry_controlled_domains::GetDomainAndRegistry(
hostname, net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); hostname, net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES);
...@@ -191,5 +187,3 @@ void LookalikeUrlService::OnFetchEngagedSites( ...@@ -191,5 +187,3 @@ void LookalikeUrlService::OnFetchEngagedSites(
last_engagement_fetch_time_ = clock_->Now(); last_engagement_fetch_time_ = clock_->Now();
std::move(callback).Run(engaged_sites_); std::move(callback).Run(engaged_sites_);
} }
} // namespace lookalikes
...@@ -24,8 +24,6 @@ namespace base { ...@@ -24,8 +24,6 @@ namespace base {
class Clock; class Clock;
} }
namespace lookalikes {
// Returns eTLD+1 of |hostname|. This excludes private registries, and returns // Returns eTLD+1 of |hostname|. This excludes private registries, and returns
// "blogspot.com" for "test.blogspot.com" (blogspot.com is listed as a private // "blogspot.com" for "test.blogspot.com" (blogspot.com is listed as a private
// registry). We do this to be consistent with url_formatter's top domain list // registry). We do this to be consistent with url_formatter's top domain list
...@@ -99,6 +97,4 @@ class LookalikeUrlService : public KeyedService { ...@@ -99,6 +97,4 @@ class LookalikeUrlService : public KeyedService {
DISALLOW_COPY_AND_ASSIGN(LookalikeUrlService); DISALLOW_COPY_AND_ASSIGN(LookalikeUrlService);
}; };
} // namespace lookalikes
#endif // CHROME_BROWSER_LOOKALIKES_LOOKALIKE_URL_SERVICE_H_ #endif // CHROME_BROWSER_LOOKALIKES_LOOKALIKE_URL_SERVICE_H_
...@@ -29,19 +29,19 @@ namespace safety_tips { ...@@ -29,19 +29,19 @@ namespace safety_tips {
bool ShouldTriggerSafetyTipFromLookalike( bool ShouldTriggerSafetyTipFromLookalike(
const GURL& url, const GURL& url,
const lookalikes::DomainInfo& navigated_domain, const DomainInfo& navigated_domain,
const std::vector<lookalikes::DomainInfo>& engaged_sites, const std::vector<DomainInfo>& engaged_sites,
GURL* safe_url) { GURL* safe_url) {
std::string matched_domain; std::string matched_domain;
MatchType match_type; MatchType match_type;
if (!lookalikes::LookalikeUrlNavigationThrottle::GetMatchingDomain( if (!LookalikeUrlNavigationThrottle::GetMatchingDomain(
navigated_domain, engaged_sites, &matched_domain, &match_type)) { navigated_domain, engaged_sites, &matched_domain, &match_type)) {
return false; return false;
} }
// If we're already displaying an interstitial, don't warn again. // If we're already displaying an interstitial, don't warn again.
if (lookalikes::LookalikeUrlNavigationThrottle::ShouldDisplayInterstitial( if (LookalikeUrlNavigationThrottle::ShouldDisplayInterstitial(
match_type, navigated_domain)) { match_type, navigated_domain)) {
return false; return false;
} }
...@@ -74,7 +74,7 @@ bool ShouldTriggerSafetyTipFromKeywordInURL( ...@@ -74,7 +74,7 @@ bool ShouldTriggerSafetyTipFromKeywordInURL(
// "eTLD + 1 - 1": "www.google.com" -> "google" // "eTLD + 1 - 1": "www.google.com" -> "google"
std::string eTLD_plusminus; std::string eTLD_plusminus;
base::TrimString(url_formatter::top_domains::HostnameWithoutRegistry( base::TrimString(url_formatter::top_domains::HostnameWithoutRegistry(
lookalikes::GetETLDPlusOne(url.host())), GetETLDPlusOne(url.host())),
".", &eTLD_plusminus); ".", &eTLD_plusminus);
DCHECK(eTLD_plusminus.find('.') == std::string::npos); DCHECK(eTLD_plusminus.find('.') == std::string::npos);
......
...@@ -23,8 +23,8 @@ namespace safety_tips { ...@@ -23,8 +23,8 @@ namespace safety_tips {
// navigated domain is a lookalike to, in the passed |safe_url|. // navigated domain is a lookalike to, in the passed |safe_url|.
bool ShouldTriggerSafetyTipFromLookalike( bool ShouldTriggerSafetyTipFromLookalike(
const GURL& url, const GURL& url,
const lookalikes::DomainInfo& navigated_domain, const DomainInfo& navigated_domain,
const std::vector<lookalikes::DomainInfo>& engaged_sites, const std::vector<DomainInfo>& engaged_sites,
GURL* safe_url); GURL* safe_url);
// Checks to see whether a given URL contains sensitive keywords in a way // Checks to see whether a given URL contains sensitive keywords in a way
......
...@@ -28,8 +28,6 @@ namespace { ...@@ -28,8 +28,6 @@ namespace {
using chrome_browser_safety_tips::FlaggedPage; using chrome_browser_safety_tips::FlaggedPage;
using chrome_browser_safety_tips::UrlPattern; using chrome_browser_safety_tips::UrlPattern;
using lookalikes::DomainInfo;
using lookalikes::LookalikeUrlService;
using safe_browsing::V4ProtocolManagerUtil; using safe_browsing::V4ProtocolManagerUtil;
using safety_tips::ReputationService; using safety_tips::ReputationService;
...@@ -208,7 +206,7 @@ void ReputationService::GetReputationStatusWithEngagedSites( ...@@ -208,7 +206,7 @@ void ReputationService::GetReputationStatusWithEngagedSites(
ReputationCheckCallback callback, ReputationCheckCallback callback,
const GURL& url, const GURL& url,
const std::vector<DomainInfo>& engaged_sites) { const std::vector<DomainInfo>& engaged_sites) {
const DomainInfo navigated_domain = lookalikes::GetDomainInfo(url); const DomainInfo navigated_domain = GetDomainInfo(url);
// 0. Server-side warning suppression. // 0. Server-side warning suppression.
// If the URL is on the allowlist list, do nothing else. This is only used to // If the URL is on the allowlist list, do nothing else. This is only used to
...@@ -245,7 +243,7 @@ void ReputationService::GetReputationStatusWithEngagedSites( ...@@ -245,7 +243,7 @@ void ReputationService::GetReputationStatusWithEngagedSites(
// 3. Protect against bad false positives by allowing top domains. // 3. Protect against bad false positives by allowing top domains.
// Empty domain_and_registry happens on private domains. // Empty domain_and_registry happens on private domains.
if (navigated_domain.domain_and_registry.empty() || if (navigated_domain.domain_and_registry.empty() ||
lookalikes::IsTopDomain(navigated_domain)) { IsTopDomain(navigated_domain)) {
std::move(callback).Run(security_state::SafetyTipStatus::kNone, std::move(callback).Run(security_state::SafetyTipStatus::kNone,
IsIgnored(url), url, GURL()); IsIgnored(url), url, GURL());
return; return;
......
...@@ -17,10 +17,7 @@ ...@@ -17,10 +17,7 @@
#include "url/origin.h" #include "url/origin.h"
class Profile; class Profile;
namespace lookalikes {
struct DomainInfo; struct DomainInfo;
}
namespace safety_tips { namespace safety_tips {
...@@ -67,7 +64,7 @@ class ReputationService : public KeyedService { ...@@ -67,7 +64,7 @@ class ReputationService : public KeyedService {
void GetReputationStatusWithEngagedSites( void GetReputationStatusWithEngagedSites(
ReputationCheckCallback callback, ReputationCheckCallback callback,
const GURL& url, const GURL& url,
const std::vector<lookalikes::DomainInfo>& engaged_sites); const std::vector<DomainInfo>& engaged_sites);
// Set of origins that we've warned about, and the user has explicitly // Set of origins that we've warned about, and the user has explicitly
// ignored. Used to avoid re-warning the user. // ignored. Used to avoid re-warning the user.
......
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