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

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

Issue 2136453004: Reland of place string::find(prefix) == 0 pattern with base::StartsWith(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 | « media/blink/resource_multibuffer_data_provider.cc ('k') | net/cookies/canonical_cookie.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/path_service.h" 9 #include "base/path_service.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 std::string filename_lower = base::ToLowerASCII(base::WideToUTF8(filename)); 167 std::string filename_lower = base::ToLowerASCII(base::WideToUTF8(filename));
168 #elif defined(OS_POSIX) 168 #elif defined(OS_POSIX)
169 std::string filename_lower = base::ToLowerASCII(filename); 169 std::string filename_lower = base::ToLowerASCII(filename);
170 #endif 170 #endif
171 171
172 for (size_t i = 0; i < arraysize(known_devices); ++i) { 172 for (size_t i = 0; i < arraysize(known_devices); ++i) {
173 // Exact match. 173 // Exact match.
174 if (filename_lower == known_devices[i]) 174 if (filename_lower == known_devices[i])
175 return true; 175 return true;
176 // Starts with "DEVICE.". 176 // Starts with "DEVICE.".
177 if (filename_lower.find(std::string(known_devices[i]) + ".") == 0) 177 if (base::StartsWith(filename_lower, std::string(known_devices[i]) + ".",
178 base::CompareCase::SENSITIVE)) {
178 return true; 179 return true;
180 }
179 } 181 }
180 182
181 static const char* const magic_names[] = { 183 static const char* const magic_names[] = {
182 // These file names are used by the "Customize folder" feature of the 184 // These file names are used by the "Customize folder" feature of the
183 // shell. 185 // shell.
184 "desktop.ini", 186 "desktop.ini",
185 "thumbs.db", 187 "thumbs.db",
186 }; 188 };
187 189
188 for (size_t i = 0; i < arraysize(magic_names); ++i) { 190 for (size_t i = 0; i < arraysize(magic_names); ++i) {
189 if (filename_lower == magic_names[i]) 191 if (filename_lower == magic_names[i])
190 return true; 192 return true;
191 } 193 }
192 194
193 return false; 195 return false;
194 } 196 }
195 197
196 } // namespace net 198 } // namespace net
OLDNEW
« no previous file with comments | « media/blink/resource_multibuffer_data_provider.cc ('k') | net/cookies/canonical_cookie.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698