Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(787)

Unified Diff: net/base/net_util_win.cc

Issue 220253002: Add net/base/filename_util.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/net_util_unittest.cc ('k') | net/filter/filter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/net_util_win.cc
diff --git a/net/base/net_util_win.cc b/net/base/net_util_win.cc
index 14f3170dc3c3319545d8cbbf4f060b7ed6b431dd..c4cedee472079ae7b418f376fb016a175c185e3c 100644
--- a/net/base/net_util_win.cc
+++ b/net/base/net_util_win.cc
@@ -85,59 +85,6 @@ struct WlanApi {
namespace net {
-bool FileURLToFilePath(const GURL& url, base::FilePath* file_path) {
- *file_path = base::FilePath();
- std::wstring& file_path_str = const_cast<std::wstring&>(file_path->value());
- file_path_str.clear();
-
- if (!url.is_valid())
- return false;
-
- std::string path;
- std::string host = url.host();
- if (host.empty()) {
- // URL contains no host, the path is the filename. In this case, the path
- // will probably be preceeded with a slash, as in "/C:/foo.txt", so we
- // trim out that here.
- path = url.path();
- size_t first_non_slash = path.find_first_not_of("/\\");
- if (first_non_slash != std::string::npos && first_non_slash > 0)
- path.erase(0, first_non_slash);
- } else {
- // URL contains a host: this means it's UNC. We keep the preceeding slash
- // on the path.
- path = "\\\\";
- path.append(host);
- path.append(url.path());
- }
-
- if (path.empty())
- return false;
- std::replace(path.begin(), path.end(), '/', '\\');
-
- // GURL stores strings as percent-encoded UTF-8, this will undo if possible.
- path = UnescapeURLComponent(path,
- UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS);
-
- if (!IsStringUTF8(path)) {
- // Not UTF-8, assume encoding is native codepage and we're done. We know we
- // are giving the conversion function a nonempty string, and it may fail if
- // the given string is not in the current encoding and give us an empty
- // string back. We detect this and report failure.
- file_path_str = base::SysNativeMBToWide(path);
- return !file_path_str.empty();
- }
- file_path_str.assign(base::UTF8ToWide(path));
-
- // We used to try too hard and see if |path| made up entirely of
- // the 1st 256 characters in the Unicode was a zero-extended UTF-16.
- // If so, we converted it to 'Latin-1' and checked if the result was UTF-8.
- // If the check passed, we converted the result to UTF-8.
- // Otherwise, we treated the result as the native OS encoding.
- // However, that led to http://crbug.com/4619 and http://crbug.com/14153
- return true;
-}
-
bool GetNetworkList(NetworkInterfaceList* networks, int policy) {
// GetAdaptersAddresses() may require IO operations.
base::ThreadRestrictions::AssertIOAllowed();
« no previous file with comments | « net/base/net_util_unittest.cc ('k') | net/filter/filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698