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

Side by Side Diff: trunk/src/net/base/net_util_posix.cc

Issue 228763004: Revert 262487 "Add net/base/filename_util.h." (Closed) Base URL: svn://svn.chromium.org/chrome/
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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « trunk/src/net/base/net_util.cc ('k') | trunk/src/net/base/net_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "net/base/net_util.h" 5 #include "net/base/net_util.h"
6 6
7 #include <set> 7 #include <set>
8 #include <sys/types.h> 8 #include <sys/types.h>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 } else { 78 } else {
79 ++i; 79 ++i;
80 } 80 }
81 } 81 }
82 } 82 }
83 83
84 #endif 84 #endif
85 85
86 } // namespace 86 } // namespace
87 87
88 bool FileURLToFilePath(const GURL& url, base::FilePath* path) {
89 *path = base::FilePath();
90 std::string& file_path_str = const_cast<std::string&>(path->value());
91 file_path_str.clear();
92
93 if (!url.is_valid())
94 return false;
95
96 // Firefox seems to ignore the "host" of a file url if there is one. That is,
97 // file://foo/bar.txt maps to /bar.txt.
98 // TODO(dhg): This should probably take into account UNCs which could
99 // include a hostname other than localhost or blank
100 std::string old_path = url.path();
101
102 if (old_path.empty())
103 return false;
104
105 // GURL stores strings as percent-encoded 8-bit, this will undo if possible.
106 old_path = UnescapeURLComponent(old_path,
107 UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS);
108
109 // Collapse multiple path slashes into a single path slash.
110 std::string new_path;
111 do {
112 new_path = old_path;
113 ReplaceSubstringsAfterOffset(&new_path, 0, "//", "/");
114 old_path.swap(new_path);
115 } while (new_path != old_path);
116
117 file_path_str.assign(old_path);
118
119 return !file_path_str.empty();
120 }
121
88 bool GetNetworkList(NetworkInterfaceList* networks, int policy) { 122 bool GetNetworkList(NetworkInterfaceList* networks, int policy) {
89 #if defined(OS_ANDROID) 123 #if defined(OS_ANDROID)
90 std::string network_list = android::GetNetworkList(); 124 std::string network_list = android::GetNetworkList();
91 base::StringTokenizer network_interfaces(network_list, "\n"); 125 base::StringTokenizer network_interfaces(network_list, "\n");
92 while (network_interfaces.GetNext()) { 126 while (network_interfaces.GetNext()) {
93 std::string network_item = network_interfaces.token(); 127 std::string network_item = network_interfaces.token();
94 base::StringTokenizer network_tokenizer(network_item, "\t"); 128 base::StringTokenizer network_tokenizer(network_item, "\t");
95 CHECK(network_tokenizer.GetNext()); 129 CHECK(network_tokenizer.GetNext());
96 std::string name = network_tokenizer.token(); 130 std::string name = network_tokenizer.token();
97 131
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 } 262 }
229 return true; 263 return true;
230 #endif 264 #endif
231 } 265 }
232 266
233 WifiPHYLayerProtocol GetWifiPHYLayerProtocol() { 267 WifiPHYLayerProtocol GetWifiPHYLayerProtocol() {
234 return WIFI_PHY_LAYER_PROTOCOL_UNKNOWN; 268 return WIFI_PHY_LAYER_PROTOCOL_UNKNOWN;
235 } 269 }
236 270
237 } // namespace net 271 } // namespace net
OLDNEW
« no previous file with comments | « trunk/src/net/base/net_util.cc ('k') | trunk/src/net/base/net_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698