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 e31a809d8242b91e6264d4cd2497911401ca6cff..2abf2d6410f7c8e4f6aec3619249d25753ca576b 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; |
@@ -341,6 +335,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); |