Chromium Code Reviews| Index: content/common/origin_util.cc |
| diff --git a/content/common/origin_util.cc b/content/common/origin_util.cc |
| index 11873d63cfd9de6f8b7b2c4592d785abef089e42..3dcc1558f7a679d2522a12aea0ee6b3d0b52c456 100644 |
| --- a/content/common/origin_util.cc |
| +++ b/content/common/origin_util.cc |
| @@ -90,4 +90,24 @@ void ResetSchemesAndOriginsWhitelistForTesting() { |
| g_trustworthy_whitelist.Get().Reset(); |
| } |
| +bool HasSuborigin(const GURL& url) { |
| + return url.host().find("_") != std::string::npos; |
|
nasko
2016/09/26 18:26:13
Huh, I thought we changed how we serialize suborig
jww
2016/09/26 21:18:57
Indeed! I'm a moron. New patch should address this
|
| +} |
| + |
| +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 |