summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorpaul@chromium.org <paul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-14 21:14:23 +0000
committerpaul@chromium.org <paul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-14 21:14:23 +0000
commita1b9f5d1be682acc27767c121e282b2353510b48 (patch)
tree07f62ea3b9902775d2d61c018591e959dfb5f8b5 /app
parente8b5f788d2e9df045f28ccbe701b662ee9d8e8d6 (diff)
downloadchromium_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')
-rw-r--r--app/resources/app_strings.grd3
-rw-r--r--app/win_util.cc26
2 files changed, 21 insertions, 8 deletions
diff --git a/app/resources/app_strings.grd b/app/resources/app_strings.grd
index 78c5f0e..38cd977 100644
--- a/app/resources/app_strings.grd
+++ b/app/resources/app_strings.grd
@@ -187,6 +187,9 @@ need to be translated for each locale.-->
<message name="IDS_APP_SAVEAS_ALL_FILES" desc="Save As dialog box default text">
All Files
</message>
+ <message name="IDS_APP_SAVEAS_EXTENSION_FORMAT" desc="Save As dialog box extension format text">
+ <ph name="SAVEAS_EXTENSION_TYPE">$1<ex>EXE</ex></ph> File (.<ph name="SAVEAS_EXTENSION_NAME">$2<ex>exe</ex></ph>)
+ </message>
<!--Accessible name/action strings-->
<message name="IDS_APP_ACCACTION_PRESS" desc="The accessible default action for a button.">
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.