diff options
author | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-08 22:11:39 +0000 |
---|---|---|
committer | ericroman@google.com <ericroman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-08 22:11:39 +0000 |
commit | 6d748ec125d222f1d45c913d30a8e8317d10eb43 (patch) | |
tree | 0b4789f4e43958f1f98bee3a4517583ceeba8380 /net/base | |
parent | f8d434bd5be573b2954faa2ff4bfef37db6d194e (diff) | |
download | chromium_src-6d748ec125d222f1d45c913d30a8e8317d10eb43.zip chromium_src-6d748ec125d222f1d45c913d30a8e8317d10eb43.tar.gz chromium_src-6d748ec125d222f1d45c913d30a8e8317d10eb43.tar.bz2 |
Unrollback 3024 (partially rolled back in 3027).
It is fixed in mac build now -- problem was bad format string to StringPrintf, where passed string instead of char*.
Review URL: http://codereview.chromium.org/6359
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3064 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base')
-rw-r--r-- | net/base/net_util.cc | 22 | ||||
-rw-r--r-- | net/base/net_util.h | 5 | ||||
-rw-r--r-- | net/base/net_util_unittest.cc | 28 | ||||
-rw-r--r-- | net/base/sdch_manager.cc | 18 | ||||
-rw-r--r-- | net/base/sdch_manager.h | 3 |
5 files changed, 3 insertions, 73 deletions
diff --git a/net/base/net_util.cc b/net/base/net_util.cc index 57448af..305cbcc 100644 --- a/net/base/net_util.cc +++ b/net/base/net_util.cc @@ -913,26 +913,4 @@ bool IsPortAllowedByFtp(int port) { return IsPortAllowedByDefault(port); } -std::string GetImplicitPort(const GURL& url) { - if (url.has_port()) - return url.port(); - - // TODO(eroman): unify with DefaultPortForScheme() - // [url_canon_stdurl.cc] - - static const struct { - const char* scheme; - const char* port; - } scheme_map[] = { - { "http", "80" }, - { "https", "443" }, - { "ftp", "21" } - }; - for (int i = 0; i < static_cast<int>(ARRAYSIZE_UNSAFE(scheme_map)); ++i) { - if (url.SchemeIs(scheme_map[i].scheme)) - return scheme_map[i].port; - } - return std::string(""); -} - } // namespace net diff --git a/net/base/net_util.h b/net/base/net_util.h index 6ceead7..db28a76 100644 --- a/net/base/net_util.h +++ b/net/base/net_util.h @@ -131,11 +131,6 @@ bool IsPortAllowedByDefault(int port); // restricted. bool IsPortAllowedByFtp(int port); -// Get the port number for the URL. If the URL does not have a port number, -// then returns the default port for the scheme. If the scheme is unrecognized -// returns empty string. -std::string GetImplicitPort(const GURL& url); - } // namespace net #endif // NET_BASE_NET_UTIL_H__ diff --git a/net/base/net_util_unittest.cc b/net/base/net_util_unittest.cc index 884f2fe..22fb7d4 100644 --- a/net/base/net_util_unittest.cc +++ b/net/base/net_util_unittest.cc @@ -698,34 +698,6 @@ TEST(NetUtilTest, GetSuggestedFilename) { } } -TEST(NetUtilTest, GetImplicitPort) { - { - GURL url("http://foo.bar/baz"); - EXPECT_STREQ("80", net::GetImplicitPort(url).c_str()); - } - { - GURL url("http://foo.bar:443/baz"); - EXPECT_STREQ("443", net::GetImplicitPort(url).c_str()); - } - { - GURL url("https://foo.bar/baz"); - EXPECT_STREQ("443", net::GetImplicitPort(url).c_str()); - } - { - GURL url("https://foo.bar:80/baz"); - EXPECT_STREQ("80", net::GetImplicitPort(url).c_str()); - } - { - // Invalid input. - GURL url("file://foobar/baz"); - EXPECT_STREQ("", net::GetImplicitPort(url).c_str()); - } - { - GURL url("ftp://google.com"); - EXPECT_STREQ("21", net::GetImplicitPort(url).c_str()); - } -} - // This is currently a windows specific function. #if defined(OS_WIN) namespace { diff --git a/net/base/sdch_manager.cc b/net/base/sdch_manager.cc index 6c8bce3..de1e0b0 100644 --- a/net/base/sdch_manager.cc +++ b/net/base/sdch_manager.cc @@ -214,18 +214,6 @@ void SdchManager::UrlSafeBase64Encode(const std::string& input, // Security functions restricting loads and use of dictionaries. // static -int SdchManager::Dictionary::GetPortIncludingDefault(const GURL& url) { - std::string port(url.port()); - if (port.length()) - return StringToInt(port); - if (url.scheme() == "http") - return 80; // Default port value. - // TODO(jar): If sdch supports other schemes, then write a general function - // or surface functionality hidden in url_cannon_stdurl.cc into url_canon.h. - return -1; -} - -// static bool SdchManager::Dictionary::CanSet(const std::string& domain, const std::string& path, const std::set<int> ports, @@ -256,7 +244,7 @@ bool SdchManager::Dictionary::CanSet(const std::string& domain, // TODO(jar): Enforce item 4 above. if (!ports.empty() - && 0 == ports.count(GetPortIncludingDefault(dictionary_url))) + && 0 == ports.count(dictionary_url.EffectiveIntPort())) return false; return true; } @@ -276,7 +264,7 @@ bool SdchManager::Dictionary::CanUse(const GURL referring_url) { if (!DomainMatch(referring_url, domain_)) return false; if (!ports_.empty() - && 0 == ports_.count(GetPortIncludingDefault(referring_url))) + && 0 == ports_.count(referring_url.EffectiveIntPort())) return false; if (path_.size() && !PathMatch(referring_url.path(), path_)) return false; @@ -302,7 +290,7 @@ bool SdchManager::Dictionary::CanAdvertise(const GURL& target_url) { */ if (!DomainMatch(target_url, domain_)) return false; - if (!ports_.empty() && 0 == ports_.count(GetPortIncludingDefault(target_url))) + if (!ports_.empty() && 0 == ports_.count(target_url.EffectiveIntPort())) return false; if (path_.size() && !PathMatch(target_url.path(), path_)) return false; diff --git a/net/base/sdch_manager.h b/net/base/sdch_manager.h index 7926b52..ae5f2d3 100644 --- a/net/base/sdch_manager.h +++ b/net/base/sdch_manager.h @@ -72,9 +72,6 @@ class SdchManager { const GURL& url() const { return url_; } const std::string& client_hash() const { return client_hash_; } - // For a given URL, get the actual or default port. - static int GetPortIncludingDefault(const GURL& url); - // Security method to check if we can advertise this dictionary for use // if the |target_url| returns SDCH compressed data. bool CanAdvertise(const GURL& target_url); |