Chromium Code Reviews| Index: content/common/origin_util.cc |
| diff --git a/content/common/origin_util.cc b/content/common/origin_util.cc |
| index 4dfdc6ce8caf7efae0598c82dace3bc6171e8b65..bdf3795d4693af2d08e39c47d9a8790ecccaf764 100644 |
| --- a/content/common/origin_util.cc |
| +++ b/content/common/origin_util.cc |
| @@ -86,4 +86,24 @@ void ResetSchemesAndOriginsWhitelistForTesting() { |
| g_trustworthy_whitelist.Get().Reset(); |
| } |
| +bool HasSuborigin(const GURL& url) { |
| + return url.host().find("_") != std::string::npos; |
|
nasko
2016/05/25 21:46:19
This seems wrong. Underscores function just fine i
jww
2016/09/26 18:15:29
I believe this has been addressed by https://coder
|
| +} |
| + |
| +std::string SuboriginFromUrl(const GURL& url) { |
| + if (!HasSuborigin(url)) |
| + return ""; |
| + size_t suborigin_end = url.host().find("_"); |
| + return url.host().substr(0, suborigin_end); |
| +} |
| + |
| +std::string HostFromUrlStripSuborigin(const GURL& url) { |
| + std::string host = url.host(); |
| + size_t suborigin_end = host.find("_"); |
| + if (suborigin_end == std::string::npos) |
| + return host; |
| + return url.host().substr(suborigin_end + 1, |
| + host.length() - suborigin_end - 1); |
| +} |
| + |
| } // namespace content |