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 132f9a69adc6e558629eeada53e7bb704196b75e..cd13768fef7ed7d9b48e8a53b2c0c25a7e5e9b85 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 with |
Nico
2013/12/06 21:36:36
s/This/This happens/
davidben
2013/12/06 21:48:51
Done.
|
+ // 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) { |
Nico
2013/12/06 21:36:36
s/5/strlen(".foo.")/?
davidben
2013/12/06 21:48:51
It shouldn't include dots. It's just what the doub
|
+ [dialog setExtensionHidden:NO]; |
+ } else { |
+ [dialog setCanSelectHiddenExtension:YES]; |
+ } |
} else { |
NSOpenPanel* open_dialog = (NSOpenPanel*)dialog; |