Index: content/common/origin_util.cc |
diff --git a/content/common/origin_util.cc b/content/common/origin_util.cc |
index 4af685acc31a38c9b8164e6f4c90eebdd5f2ac4d..11873d63cfd9de6f8b7b2c4592d785abef089e42 100644 |
--- a/content/common/origin_util.cc |
+++ b/content/common/origin_util.cc |
@@ -4,17 +4,12 @@ |
#include "content/public/common/origin_util.h" |
-#include <string> |
- |
#include "base/lazy_instance.h" |
#include "base/macros.h" |
#include "base/stl_util.h" |
-#include "base/strings/string_piece.h" |
#include "content/public/common/content_client.h" |
-#include "content/public/common/url_constants.h" |
#include "net/base/url_util.h" |
#include "url/gurl.h" |
-#include "url/url_constants.h" |
namespace content { |
@@ -95,63 +90,4 @@ void ResetSchemesAndOriginsWhitelistForTesting() { |
g_trustworthy_whitelist.Get().Reset(); |
} |
-bool HasSuborigin(const GURL& url) { |
- if (!url.is_valid()) |
- return false; |
- |
- if (url.scheme() != kHttpSuboriginScheme && |
- url.scheme() != kHttpsSuboriginScheme) { |
- return false; |
- } |
- |
- base::StringPiece host_piece = url.host_piece(); |
- size_t first_period = host_piece.find('.'); |
- |
- // If the first period is the first position in the hostname, or there is no |
- // period at all, there is no suborigin serialized in the hostname. |
- if (first_period == 0 || first_period == base::StringPiece::npos) |
- return false; |
- |
- // If there's nothing after the first dot, then there is no host for the |
- // physical origin, which is not a valid suborigin serialization. |
- if (first_period == (host_piece.size() - 1)) |
- return false; |
- |
- return true; |
-} |
- |
-std::string SuboriginFromUrl(const GURL& url) { |
- if (!HasSuborigin(url)) |
- return ""; |
- |
- std::string host = url.host(); |
- size_t suborigin_end = host.find("."); |
- return (suborigin_end == std::string::npos) ? "" |
- : host.substr(0, suborigin_end); |
-} |
- |
-GURL StripSuboriginFromUrl(const GURL& url) { |
- if (!HasSuborigin(url)) |
- return url; |
- |
- GURL::Replacements replacements; |
- if (url.scheme() == kHttpSuboriginScheme) { |
- replacements.SetSchemeStr(url::kHttpScheme); |
- } else { |
- DCHECK(url.scheme() == kHttpsSuboriginScheme); |
- replacements.SetSchemeStr(url::kHttpsScheme); |
- } |
- |
- std::string host = url.host(); |
- size_t suborigin_end = host.find("."); |
- std::string new_host( |
- (suborigin_end == std::string::npos) |
- ? "" |
- : host.substr(suborigin_end + 1, |
- url.host().length() - suborigin_end - 1)); |
- replacements.SetHostStr(new_host); |
- |
- return url.ReplaceComponents(replacements); |
-} |
- |
} // namespace content |