Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(698)

Unified Diff: third_party/WebKit/Source/platform/network/NetworkUtils.cpp

Issue 2196983002: Allow doc.written scripts with a matching domain and registry to execute. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix comment Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/network/NetworkUtils.cpp
diff --git a/third_party/WebKit/Source/platform/network/NetworkUtils.cpp b/third_party/WebKit/Source/platform/network/NetworkUtils.cpp
index 57c0b4c7ea7822c0070c6c3fa10307bfee963020..0067a1cd6e4a63477b959c0751c2549cd5bc182b 100644
--- a/third_party/WebKit/Source/platform/network/NetworkUtils.cpp
+++ b/third_party/WebKit/Source/platform/network/NetworkUtils.cpp
@@ -5,6 +5,7 @@
#include "platform/network/NetworkUtils.h"
#include "net/base/ip_address.h"
+#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "net/base/url_util.h"
#include "wtf/text/StringUTF8Adaptor.h"
#include "wtf/text/WTFString.h"
@@ -28,6 +29,14 @@ bool isLocalHostname(const String& host, bool* isLocal6)
return net::IsLocalHostname(utf8.asStringPiece(), isLocal6);
}
+String getDomainAndRegistry(const String& host, bool includePrivateRegistries)
+{
+ StringUTF8Adaptor hostUtf8(host);
+ net::registry_controlled_domains::PrivateRegistryFilter registryFilter = includePrivateRegistries ? net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES : net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES;
+ std::string domain = net::registry_controlled_domains::GetDomainAndRegistry(hostUtf8.asStringPiece(), registryFilter);
+ return String(domain.data(), domain.length());
+}
+
} // NetworkUtils
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698