| Index: chrome/browser/engagement/important_sites_util.cc
|
| diff --git a/chrome/browser/engagement/important_sites_util.cc b/chrome/browser/engagement/important_sites_util.cc
|
| index fa56c26bc196293a42e04d827fd83f4ce211dda5..d79b9f79a9652fb0dc059d883a8967ff163d959f 100644
|
| --- a/chrome/browser/engagement/important_sites_util.cc
|
| +++ b/chrome/browser/engagement/important_sites_util.cc
|
| @@ -32,6 +32,7 @@
|
| #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
|
| #include "third_party/WebKit/public/platform/site_engagement.mojom.h"
|
| #include "url/gurl.h"
|
| +#include "url/url_util.h"
|
|
|
| namespace {
|
| using bookmarks::BookmarkModel;
|
| @@ -132,15 +133,6 @@ CrossedReason GetCrossedReasonFromBitfield(int32_t reason_bitfield) {
|
| return CROSSED_REASON_UNKNOWN;
|
| }
|
|
|
| -std::string GetRegisterableDomainOrIP(const GURL& url) {
|
| - std::string registerable_domain =
|
| - net::registry_controlled_domains::GetDomainAndRegistry(
|
| - url, net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
|
| - if (registerable_domain.empty() && url.HostIsIPAddress())
|
| - registerable_domain = url.host();
|
| - return registerable_domain;
|
| -}
|
| -
|
| void MaybePopulateImportantInfoForReason(
|
| const GURL& origin,
|
| std::set<GURL>* visited_origins,
|
| @@ -148,7 +140,8 @@ void MaybePopulateImportantInfoForReason(
|
| base::hash_map<std::string, ImportantDomainInfo>* output) {
|
| if (!origin.is_valid() || !visited_origins->insert(origin).second)
|
| return;
|
| - std::string registerable_domain = GetRegisterableDomainOrIP(origin);
|
| + std::string registerable_domain =
|
| + ImportantSitesUtil::GetRegisterableDomainOrIP(origin);
|
| ImportantDomainInfo& info = (*output)[registerable_domain];
|
| info.reason_bitfield |= 1 << reason;
|
| if (info.example_origin.is_empty()) {
|
| @@ -245,7 +238,8 @@ void PopulateInfoMapWithSiteEngagement(
|
| continue;
|
| }
|
| std::string registerable_domain =
|
| - GetRegisterableDomainOrIP(url_engagement_pair.first);
|
| + ImportantSitesUtil::GetRegisterableDomainOrIP(
|
| + url_engagement_pair.first);
|
| ImportantDomainInfo& info = (*output)[registerable_domain];
|
| if (url_engagement_pair.second > info.engagement_score) {
|
| info.registerable_domain = registerable_domain;
|
| @@ -347,6 +341,20 @@ void PopulateInfoMapWithHomeScreen(
|
|
|
| } // namespace
|
|
|
| +std::string ImportantSitesUtil::GetRegisterableDomainOrIP(const GURL& url) {
|
| + return GetRegisterableDomainOrIPFromHost(url.host_piece());
|
| +}
|
| +
|
| +std::string ImportantSitesUtil::GetRegisterableDomainOrIPFromHost(
|
| + base::StringPiece host) {
|
| + std::string registerable_domain =
|
| + net::registry_controlled_domains::GetDomainAndRegistry(
|
| + host, net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
|
| + if (registerable_domain.empty() && url::HostIsIPAddress(host))
|
| + registerable_domain = std::string(host);
|
| + return registerable_domain;
|
| +}
|
| +
|
| bool ImportantSitesUtil::IsDialogDisabled(Profile* profile) {
|
| PrefService* service = profile->GetPrefs();
|
| DictionaryPrefUpdate update(service, prefs::kImportantSitesDialogHistory);
|
|
|