summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/shell_dialogs_win.cc
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-03 00:52:10 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-03 00:52:10 +0000
commitd8f33a693a3b49024bd0ceaca04a7ada2f15f997 (patch)
tree0e53531100367b47dabe71553abf61a20ffc15d4 /chrome/browser/views/shell_dialogs_win.cc
parent657004660dca7a6919ecd110ddd8bfccd3f15c3b (diff)
downloadchromium_src-d8f33a693a3b49024bd0ceaca04a7ada2f15f997.zip
chromium_src-d8f33a693a3b49024bd0ceaca04a7ada2f15f997.tar.gz
chromium_src-d8f33a693a3b49024bd0ceaca04a7ada2f15f997.tar.bz2
When picking a filename to save, check whether the user's extension is registered on the system at all, rather than checking whether it has a known MIME type. Many known extensions have no MIME type.
BUG=7499 TEST=Save a text file as "foo.reg" and ensure it doesn't get ".txt" appended. Review URL: http://codereview.chromium.org/3050031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54645 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/shell_dialogs_win.cc')
-rw-r--r--chrome/browser/views/shell_dialogs_win.cc11
1 files changed, 6 insertions, 5 deletions
diff --git a/chrome/browser/views/shell_dialogs_win.cc b/chrome/browser/views/shell_dialogs_win.cc
index c1b6f5c..17d5b1e 100644
--- a/chrome/browser/views/shell_dialogs_win.cc
+++ b/chrome/browser/views/shell_dialogs_win.cc
@@ -23,7 +23,6 @@
#include "gfx/font.h"
#include "grit/app_strings.h"
#include "grit/generated_resources.h"
-#include "net/base/mime_util.h"
// This function takes the output of a SaveAs dialog: a filename, a filter and
// the extension originally suggested to the user (shown in the dialog box) and
@@ -43,11 +42,13 @@ std::wstring AppendExtensionIfNeeded(const std::wstring& filename,
// If we wanted a specific extension, but the user's filename deleted it or
// changed it to something that the system doesn't understand, re-append.
- std::string selected_mime_type;
- std::wstring file_extension = file_util::GetFileExtensionFromPath(filename);
+ // Careful: Checking net::GetMimeTypeFromExtension() will only find
+ // extensions with a known MIME type, which many "known" extensions on Windows
+ // don't have. So we check directly for the "known extension" registry key.
+ std::wstring file_extension(file_util::GetFileExtensionFromPath(filename));
+ std::wstring key(L"." + file_extension);
if (!(filter_selected.empty() || filter_selected == L"*.*") &&
- !net::GetMimeTypeFromExtension(
- file_extension, &selected_mime_type) &&
+ !RegKey(HKEY_CLASSES_ROOT, key.c_str()).Valid() &&
file_extension != suggested_ext) {
if (return_value[return_value.length() - 1] != L'.')
return_value.append(L".");