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

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 compiler error Created 4 years, 4 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..49d0ba039d992cfd9446cee8ba172ddfc96ba164 100644
--- a/third_party/WebKit/Source/platform/network/NetworkUtils.cpp
+++ b/third_party/WebKit/Source/platform/network/NetworkUtils.cpp
@@ -5,10 +5,30 @@
#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"
+namespace {
+
+net::registry_controlled_domains::PrivateRegistryFilter getNetPrivateRegistryFilter(blink::NetworkUtils::PrivateRegistryFilter filter)
+{
+ switch (filter) {
+ case blink::NetworkUtils::IncludePrivateRegistries:
+ return net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES;
+ case blink::NetworkUtils::ExcludePrivateRegistries:
+ return net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES;
+ }
+ // There are only two NetworkUtils::PrivateRegistryFilter enum entries, so
+ // we should never reach this point. However, we must have a default return
+ // value to avoid a compiler error.
+ NOTREACHED();
+ return net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES;
+}
kinuko 2016/08/04 18:08:04 nit: Probably we can just have static_assert's (l
+
+} // namespace
+
namespace blink {
namespace NetworkUtils {
@@ -28,6 +48,13 @@ bool isLocalHostname(const String& host, bool* isLocal6)
return net::IsLocalHostname(utf8.asStringPiece(), isLocal6);
}
+String getDomainAndRegistry(const String& host, PrivateRegistryFilter filter)
+{
+ StringUTF8Adaptor hostUtf8(host);
+ std::string domain = net::registry_controlled_domains::GetDomainAndRegistry(hostUtf8.asStringPiece(), getNetPrivateRegistryFilter(filter));
+ return String(domain.data(), domain.length());
+}
+
} // NetworkUtils
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698