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

Side by Side Diff: net/base/net_util_posix.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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/base/net_util.cc ('k') | 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
122 bool GetNetworkList(NetworkInterfaceList* networks, int policy) { 88 bool GetNetworkList(NetworkInterfaceList* networks, int policy) {
123 #if defined(OS_ANDROID) 89 #if defined(OS_ANDROID)
124 std::string network_list = android::GetNetworkList(); 90 std::string network_list = android::GetNetworkList();
125 base::StringTokenizer network_interfaces(network_list, "\n"); 91 base::StringTokenizer network_interfaces(network_list, "\n");
126 while (network_interfaces.GetNext()) { 92 while (network_interfaces.GetNext()) {
127 std::string network_item = network_interfaces.token(); 93 std::string network_item = network_interfaces.token();
128 base::StringTokenizer network_tokenizer(network_item, "\t"); 94 base::StringTokenizer network_tokenizer(network_item, "\t");
129 CHECK(network_tokenizer.GetNext()); 95 CHECK(network_tokenizer.GetNext());
130 std::string name = network_tokenizer.token(); 96 std::string name = network_tokenizer.token();
131 97
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 } 228 }
263 return true; 229 return true;
264 #endif 230 #endif
265 } 231 }
266 232
267 WifiPHYLayerProtocol GetWifiPHYLayerProtocol() { 233 WifiPHYLayerProtocol GetWifiPHYLayerProtocol() {
268 return WIFI_PHY_LAYER_PROTOCOL_UNKNOWN; 234 return WIFI_PHY_LAYER_PROTOCOL_UNKNOWN;
269 } 235 }
270 236
271 } // namespace net 237 } // namespace net
OLDNEW
« no previous file with comments | « net/base/net_util.cc ('k') | net/base/net_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698