Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/public/common/origin_util.h" | 5 #include "content/public/common/origin_util.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "content/public/common/content_client.h" | 10 #include "content/public/common/content_client.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 return true; | 83 return true; |
| 84 } | 84 } |
| 85 | 85 |
| 86 return false; | 86 return false; |
| 87 } | 87 } |
| 88 | 88 |
| 89 void ResetSchemesAndOriginsWhitelistForTesting() { | 89 void ResetSchemesAndOriginsWhitelistForTesting() { |
| 90 g_trustworthy_whitelist.Get().Reset(); | 90 g_trustworthy_whitelist.Get().Reset(); |
| 91 } | 91 } |
| 92 | 92 |
| 93 bool HasSuborigin(const GURL& url) { | |
| 94 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
| |
| 95 } | |
| 96 | |
| 97 std::string SuboriginFromUrl(const GURL& url) { | |
| 98 if (!HasSuborigin(url)) | |
| 99 return ""; | |
| 100 size_t suborigin_end = url.host().find("_"); | |
| 101 return url.host().substr(0, suborigin_end); | |
| 102 } | |
| 103 | |
| 104 std::string HostFromUrlStripSuborigin(const GURL& url) { | |
| 105 std::string host = url.host(); | |
| 106 size_t suborigin_end = host.find("_"); | |
| 107 if (suborigin_end == std::string::npos) | |
| 108 return host; | |
| 109 return url.host().substr(suborigin_end + 1, | |
| 110 host.length() - suborigin_end - 1); | |
| 111 } | |
| 112 | |
| 93 } // namespace content | 113 } // namespace content |
| OLD | NEW |