| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 return true; | 79 return true; |
| 80 } | 80 } |
| 81 | 81 |
| 82 return false; | 82 return false; |
| 83 } | 83 } |
| 84 | 84 |
| 85 void ResetSchemesAndOriginsWhitelistForTesting() { | 85 void ResetSchemesAndOriginsWhitelistForTesting() { |
| 86 g_trustworthy_whitelist.Get().Reset(); | 86 g_trustworthy_whitelist.Get().Reset(); |
| 87 } | 87 } |
| 88 | 88 |
| 89 bool HasSuborigin(const GURL& url) { |
| 90 return url.host().find("_") != std::string::npos; |
| 91 } |
| 92 |
| 93 std::string SuboriginFromUrl(const GURL& url) { |
| 94 if (!HasSuborigin(url)) |
| 95 return ""; |
| 96 size_t suborigin_end = url.host().find("_"); |
| 97 return url.host().substr(0, suborigin_end); |
| 98 } |
| 99 |
| 100 std::string HostFromUrlStripSuborigin(const GURL& url) { |
| 101 std::string host = url.host(); |
| 102 size_t suborigin_end = host.find("_"); |
| 103 if (suborigin_end == std::string::npos) |
| 104 return host; |
| 105 return url.host().substr(suborigin_end + 1, |
| 106 host.length() - suborigin_end - 1); |
| 107 } |
| 108 |
| 89 } // namespace content | 109 } // namespace content |
| OLD | NEW |