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

Unified Diff: app/win_util.cc

Issue 202032: Provide a save file type for unknown extensions (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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 | « app/resources/app_strings.grd ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: app/win_util.cc
===================================================================
--- app/win_util.cc (revision 26141)
+++ app/win_util.cc (working copy)
@@ -267,23 +267,33 @@
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.
« no previous file with comments | « app/resources/app_strings.grd ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698