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

Unified Diff: chrome/common/win_util.cc

Issue 10621: Adds the ability for save dialogs to take a default extension.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 1 month 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
« chrome/browser/views/bookmark_manager_view.cc ('K') | « chrome/common/win_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/win_util.cc
===================================================================
--- chrome/common/win_util.cc (revision 5130)
+++ chrome/common/win_util.cc (working copy)
@@ -341,11 +341,9 @@
(*buffer)[offset] = L'\0'; // Double NULL required.
}
-bool SaveFileAs(HWND owner,
- const std::wstring& suggested_name,
- std::wstring* final_name) {
+std::wstring GetFileFilterFromPath(const std::wstring& file_name) {
std::wstring reg_description;
- std::wstring file_ext = file_util::GetFileExtensionFromPath(suggested_name);
+ std::wstring file_ext = file_util::GetFileExtensionFromPath(file_name);
if (!file_ext.empty()) {
file_ext = L"." + file_ext;
GetRegistryDescriptionFromExtension(file_ext, &reg_description);
@@ -353,11 +351,17 @@
std::vector<wchar_t> filter;
FormatSaveAsFilterForExtension(file_ext, reg_description, true, &filter);
+ return std::wstring(&filter[0], filter.size());
+}
+bool SaveFileAs(HWND owner,
+ const std::wstring& suggested_name,
+ std::wstring* final_name) {
+ std::wstring filter = GetFileFilterFromPath(suggested_name);
unsigned index = 1;
return SaveFileAsWithFilter(owner,
suggested_name,
- &filter[0],
+ filter.c_str(),
L"",
&index,
final_name);
@@ -390,7 +394,7 @@
save_as.hwndOwner = owner;
save_as.hInstance = NULL;
- save_as.lpstrFilter = &filter[0];
+ save_as.lpstrFilter = filter;
save_as.lpstrCustomFilter = NULL;
save_as.nMaxCustFilter = 0;
« chrome/browser/views/bookmark_manager_view.cc ('K') | « chrome/common/win_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698