diff options
author | paul@chromium.org <paul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-14 21:14:23 +0000 |
---|---|---|
committer | paul@chromium.org <paul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-14 21:14:23 +0000 |
commit | a1b9f5d1be682acc27767c121e282b2353510b48 (patch) | |
tree | 07f62ea3b9902775d2d61c018591e959dfb5f8b5 /app/win_util.cc | |
parent | e8b5f788d2e9df045f28ccbe701b662ee9d8e8d6 (diff) | |
download | chromium_src-a1b9f5d1be682acc27767c121e282b2353510b48.zip chromium_src-a1b9f5d1be682acc27767c121e282b2353510b48.tar.gz chromium_src-a1b9f5d1be682acc27767c121e282b2353510b48.tar.bz2 |
Provide a save file type for unknown extensions.
BUG=7246
TEST=Download a file with an unknown extension using the "Save as"
option. The Save As dialog will populate the "Save Type" combo
box with the unknown type and "All Files", instead of just
"All files".
Review URL: http://codereview.chromium.org/202032
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26160 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/win_util.cc')
-rw-r--r-- | app/win_util.cc | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/app/win_util.cc b/app/win_util.cc index 6c16d82..d0b7278 100644 --- a/app/win_util.cc +++ b/app/win_util.cc @@ -267,23 +267,33 @@ std::wstring FormatFilterForExtensions( size_t first_separator_index = first_extension.find(L';'); if (first_separator_index != std::wstring::npos) first_extension = first_extension.substr(0, first_separator_index); + + // Find the extension name without the preceeding '.' character. + std::wstring ext_name = first_extension; + size_t ext_index = ext_name.find_first_not_of(L'.'); + if (ext_index != std::wstring::npos) + ext_name = ext_name.substr(ext_index); + if (!GetRegistryDescriptionFromExtension(first_extension, &desc)) { - // The extension doesn't exist in the registry. It's likely bogus, so - // just drop it. + // The extension doesn't exist in the registry. Create a description + // based on the unknown extension type (i.e. if the extension is .qqq, + // the we create a description "QQQ File (.qqq)"). include_all_files = true; - continue; + desc = l10n_util::GetStringF(IDS_APP_SAVEAS_EXTENSION_FORMAT, + l10n_util::ToUpper(ext_name), + ext_name); } if (desc.empty()) - desc = L"*." + first_extension; + desc = L"*." + ext_name; } - result.append(desc.c_str(), desc.size()+1); // Append NULL too. - result.append(ext.c_str(), ext.size()+1); + result.append(desc.c_str(), desc.size() + 1); // Append NULL too. + result.append(ext.c_str(), ext.size() + 1); } if (include_all_files) { - result.append(all_desc.c_str(), all_desc.size()+1); - result.append(all_ext.c_str(), all_ext.size()+1); + result.append(all_desc.c_str(), all_desc.size() + 1); + result.append(all_ext.c_str(), all_ext.size() + 1); } result.append(1, '\0'); // Double NULL required. |