From b99603ceb9cbec4a3b1ca9ac535f6b1cbc951bb8 Mon Sep 17 00:00:00 2001 From: "brettw@google.com" Date: Thu, 30 Dec 2010 22:13:32 +0000 Subject: Move some functions out of win_util and into hwnd_util, and into a new win/shell file. This also moves two functions that were only called once from win_util and inwo window_win and download_util, respectively. TEST=it compiles BUG=none Review URL: http://codereview.chromium.org/6035011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70321 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/download/download_util.cc | 35 +++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'chrome/browser/download') diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc index 1854d11..92c24a3 100644 --- a/chrome/browser/download/download_util.cc +++ b/chrome/browser/download/download_util.cc @@ -92,6 +92,39 @@ static const int kCompleteAnimationCycles = 5; // Also used by code that cleans up said files. static const int kMaxUniqueFiles = 100; +namespace { + +#if defined(OS_WIN) +// Returns whether the specified extension is automatically integrated into the +// windows shell. +bool IsShellIntegratedExtension(const string16& extension) { + string16 extension_lower = StringToLowerASCII(extension); + + static const wchar_t* const integrated_extensions[] = { + // See . + L"local", + // Right-clicking on shortcuts can be magical. + L"lnk", + }; + + for (int i = 0; i < arraysize(integrated_extensions); ++i) { + if (extension_lower == integrated_extensions[i]) + return true; + } + + // See . + // That vulnerability report is not exactly on point, but files become magical + // if their end in a CLSID. Here we block extensions that look like CLSIDs. + if (extension_lower.size() > 0 && extension_lower.at(0) == L'{' && + extension_lower.at(extension_lower.length() - 1) == L'}') + return true; + + return false; +} +#endif // OS_WIN + +} // namespace + // Download temporary file creation -------------------------------------------- class DefaultDownloadDirectory { @@ -157,7 +190,7 @@ void GenerateExtension(const FilePath& file_name, FILE_PATH_LITERAL("download"); // Rename shell-integrated extensions. - if (win_util::IsShellIntegratedExtension(extension)) + if (IsShellIntegratedExtension(extension)) extension.assign(default_extension); #endif -- cgit v1.1