OLD | NEW |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |