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

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

Issue 1200393002: Add more string_util functions to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@string
Patch Set: Android Created 5 years, 6 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 | « net/base/filename_util.cc ('k') | net/ftp/ftp_util.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/filename_util.h" 5 #include "net/base/filename_util.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
(...skipping 23 matching lines...) Expand all
34 if (filename->empty()) 34 if (filename->empty())
35 return; 35 return;
36 size_t trimmed = length - filename->size(); 36 size_t trimmed = length - filename->size();
37 if (trimmed) 37 if (trimmed)
38 filename->insert(filename->end(), trimmed, kReplace[0]); 38 filename->insert(filename->end(), trimmed, kReplace[0]);
39 } 39 }
40 base::TrimString(*filename, FILE_PATH_LITERAL("."), filename); 40 base::TrimString(*filename, FILE_PATH_LITERAL("."), filename);
41 if (filename->empty()) 41 if (filename->empty())
42 return; 42 return;
43 // Replace any path information by changing path separators. 43 // Replace any path information by changing path separators.
44 ReplaceSubstringsAfterOffset(filename, 0, FILE_PATH_LITERAL("/"), kReplace); 44 base::ReplaceSubstringsAfterOffset(
45 ReplaceSubstringsAfterOffset(filename, 0, FILE_PATH_LITERAL("\\"), kReplace); 45 filename, 0, FILE_PATH_LITERAL("/"), kReplace);
46 base::ReplaceSubstringsAfterOffset(
47 filename, 0, FILE_PATH_LITERAL("\\"), kReplace);
46 } 48 }
47 49
48 // Returns the filename determined from the last component of the path portion 50 // Returns the filename determined from the last component of the path portion
49 // of the URL. Returns an empty string if the URL doesn't have a path or is 51 // of the URL. Returns an empty string if the URL doesn't have a path or is
50 // invalid. If the generated filename is not reliable, 52 // invalid. If the generated filename is not reliable,
51 // |should_overwrite_extension| will be set to true, in which case a better 53 // |should_overwrite_extension| will be set to true, in which case a better
52 // extension should be determined based on the content type. 54 // extension should be determined based on the content type.
53 std::string GetFileNameFromURL(const GURL& url, 55 std::string GetFileNameFromURL(const GURL& url,
54 const std::string& referrer_charset, 56 const std::string& referrer_charset,
55 bool* should_overwrite_extension) { 57 bool* should_overwrite_extension) {
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 base::FilePath generated_name( 320 base::FilePath generated_name(
319 base::SysWideToNativeMB(base::UTF16ToWide(file_name))); 321 base::SysWideToNativeMB(base::UTF16ToWide(file_name)));
320 #endif 322 #endif
321 323
322 DCHECK(!generated_name.empty()); 324 DCHECK(!generated_name.empty());
323 325
324 return generated_name; 326 return generated_name;
325 } 327 }
326 328
327 } // namespace net 329 } // namespace net
OLDNEW
« no previous file with comments | « net/base/filename_util.cc ('k') | net/ftp/ftp_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698