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

Unified Diff: ui/shell_dialogs/select_file_dialog_mac.mm

Issue 4883003: Add FilePath::FinalExtension() to avoid double extensions (.tar.gz) for file selector (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment (also a rebase) Created 7 years 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 | « chrome/browser/download/save_package_file_picker.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/shell_dialogs/select_file_dialog_mac.mm
diff --git a/ui/shell_dialogs/select_file_dialog_mac.mm b/ui/shell_dialogs/select_file_dialog_mac.mm
index 641fc2eadafd14f684c0fa6cedaae8ab53ef57ce..a29c4047010ea293ef2950f7eedfd3b57619e206 100644
--- a/ui/shell_dialogs/select_file_dialog_mac.mm
+++ b/ui/shell_dialogs/select_file_dialog_mac.mm
@@ -266,7 +266,20 @@ void SelectFileDialogImpl::SelectFileImpl(
type_map_[dialog] = type;
if (type == SELECT_SAVEAS_FILE) {
- [dialog setCanSelectHiddenExtension:YES];
+ // When file extensions are hidden and removing the extension from
+ // the default filename gives one which still has an extension
+ // that OS X recognizes, it will get confused and think the user
+ // is trying to override the default extension. This happens with
+ // filenames like "foo.tar.gz" or "ball.of.tar.png". Work around
+ // this by never hiding extensions in that case.
+ base::FilePath::StringType penultimate_extension =
+ default_path.RemoveFinalExtension().FinalExtension();
+ if (!penultimate_extension.empty() &&
+ penultimate_extension.length() <= 5U) {
+ [dialog setExtensionHidden:NO];
+ } else {
+ [dialog setCanSelectHiddenExtension:YES];
+ }
} else {
NSOpenPanel* open_dialog = (NSOpenPanel*)dialog;
« no previous file with comments | « chrome/browser/download/save_package_file_picker.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698