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

Unified Diff: chrome/browser/download/download_util.cc

Issue 6386009: Remove app/win/win_util.h,cc etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with NSApp changes in r73581 Created 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/download/base_file.cc ('k') | chrome/browser/enumerate_modules_model_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/download_util.cc
diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc
index f7bf52f619ccf4f3d613229fba4fa63a4a8989ea..cbc352b5b5948bf6f047bcb6db8e2f79ae7e884a 100644
--- a/chrome/browser/download/download_util.cc
+++ b/chrome/browser/download/download_util.cc
@@ -69,7 +69,6 @@
#endif // defined(TOOLKIT_USES_GTK)
#if defined(OS_WIN)
-#include "app/win/win_util.h"
#include "base/win/scoped_comptr.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
@@ -119,6 +118,44 @@ bool IsShellIntegratedExtension(const string16& extension) {
return false;
}
+
+// Returns whether the specified file name is a reserved name on windows.
+// This includes names like "com2.zip" (which correspond to devices) and
+// desktop.ini and thumbs.db which have special meaning to the windows shell.
+bool IsReservedName(const string16& filename) {
+ // This list is taken from the MSDN article "Naming a file"
+ // http://msdn2.microsoft.com/en-us/library/aa365247(VS.85).aspx
+ // I also added clock$ because GetSaveFileName seems to consider it as a
+ // reserved name too.
+ static const wchar_t* const known_devices[] = {
+ L"con", L"prn", L"aux", L"nul", L"com1", L"com2", L"com3", L"com4", L"com5",
+ L"com6", L"com7", L"com8", L"com9", L"lpt1", L"lpt2", L"lpt3", L"lpt4",
+ L"lpt5", L"lpt6", L"lpt7", L"lpt8", L"lpt9", L"clock$"
+ };
+ string16 filename_lower = StringToLowerASCII(filename);
+
+ for (int i = 0; i < arraysize(known_devices); ++i) {
+ // Exact match.
+ if (filename_lower == known_devices[i])
+ return true;
+ // Starts with "DEVICE.".
+ if (filename_lower.find(string16(known_devices[i]) + L".") == 0)
+ return true;
+ }
+
+ static const wchar_t* const magic_names[] = {
+ // These file names are used by the "Customize folder" feature of the shell.
+ L"desktop.ini",
+ L"thumbs.db",
+ };
+
+ for (int i = 0; i < arraysize(magic_names); ++i) {
+ if (filename_lower == magic_names[i])
+ return true;
+ }
+
+ return false;
+}
#endif // OS_WIN
} // namespace
@@ -251,7 +288,7 @@ void GenerateSafeFileName(const std::string& mime_type, FilePath* file_name) {
// Prepend "_" to the file name if it's a reserved name
FilePath::StringType leaf_name = file_name->BaseName().value();
DCHECK(!leaf_name.empty());
- if (app::win::IsReservedName(leaf_name)) {
+ if (IsReservedName(leaf_name)) {
leaf_name = FilePath::StringType(FILE_PATH_LITERAL("_")) + leaf_name;
*file_name = file_name->DirName();
if (file_name->value() == FilePath::kCurrentDirectory) {
« no previous file with comments | « chrome/browser/download/base_file.cc ('k') | chrome/browser/enumerate_modules_model_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698