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

Side by Side Diff: net/base/net_util.cc

Issue 137233006: Support relative file paths in FilePathToFileURL(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address nit. Created 6 years, 11 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
« no previous file with comments | « no previous file | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <map> 9 #include <map>
10 10
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 991
992 size_t GetCountOfExplicitlyAllowedPorts() { 992 size_t GetCountOfExplicitlyAllowedPorts() {
993 return g_explicitly_allowed_ports.Get().size(); 993 return g_explicitly_allowed_ports.Get().size();
994 } 994 }
995 995
996 GURL FilePathToFileURL(const base::FilePath& path) { 996 GURL FilePathToFileURL(const base::FilePath& path) {
997 // Produce a URL like "file:///C:/foo" for a regular file, or 997 // Produce a URL like "file:///C:/foo" for a regular file, or
998 // "file://///server/path" for UNC. The URL canonicalizer will fix up the 998 // "file://///server/path" for UNC. The URL canonicalizer will fix up the
999 // latter case to be the canonical UNC form: "file://server/path" 999 // latter case to be the canonical UNC form: "file://server/path"
1000 base::FilePath::StringType url_string(kFileURLPrefix); 1000 base::FilePath::StringType url_string(kFileURLPrefix);
1001 if (!path.IsAbsolute()) {
1002 base::FilePath current_dir;
1003 PathService::Get(base::DIR_CURRENT, &current_dir);
1004 url_string.append(current_dir.value());
1005 url_string.push_back(base::FilePath::kSeparators[0]);
1006 }
1001 url_string.append(path.value()); 1007 url_string.append(path.value());
1002 1008
1003 // Now do replacement of some characters. Since we assume the input is a 1009 // Now do replacement of some characters. Since we assume the input is a
1004 // literal filename, anything the URL parser might consider special should 1010 // literal filename, anything the URL parser might consider special should
1005 // be escaped here. 1011 // be escaped here.
1006 1012
1007 // must be the first substitution since others will introduce percents as the 1013 // must be the first substitution since others will introduce percents as the
1008 // escape character 1014 // escape character
1009 ReplaceSubstringsAfterOffset(&url_string, 0, 1015 ReplaceSubstringsAfterOffset(&url_string, 0,
1010 FILE_PATH_LITERAL("%"), FILE_PATH_LITERAL("%25")); 1016 FILE_PATH_LITERAL("%"), FILE_PATH_LITERAL("%25"));
(...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after
2215 } 2221 }
2216 return a1.size() * CHAR_BIT; 2222 return a1.size() * CHAR_BIT;
2217 } 2223 }
2218 2224
2219 unsigned MaskPrefixLength(const IPAddressNumber& mask) { 2225 unsigned MaskPrefixLength(const IPAddressNumber& mask) {
2220 IPAddressNumber all_ones(mask.size(), 0xFF); 2226 IPAddressNumber all_ones(mask.size(), 0xFF);
2221 return CommonPrefixLength(mask, all_ones); 2227 return CommonPrefixLength(mask, all_ones);
2222 } 2228 }
2223 2229
2224 } // namespace net 2230 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698