OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/shell_dialogs/select_file_dialog.h" | 5 #include "ui/shell_dialogs/select_file_dialog.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 #include <CoreServices/CoreServices.h> | 8 #include <CoreServices/CoreServices.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
259 hasMultipleFileTypeChoices_ = | 259 hasMultipleFileTypeChoices_ = |
260 file_types ? file_types->extensions.size() > 1 : true; | 260 file_types ? file_types->extensions.size() > 1 : true; |
261 | 261 |
262 if (!default_extension.empty()) | 262 if (!default_extension.empty()) |
263 [dialog setAllowedFileTypes:@[base::SysUTF8ToNSString(default_extension)]]; | 263 [dialog setAllowedFileTypes:@[base::SysUTF8ToNSString(default_extension)]]; |
264 | 264 |
265 params_map_[dialog] = params; | 265 params_map_[dialog] = params; |
266 type_map_[dialog] = type; | 266 type_map_[dialog] = type; |
267 | 267 |
268 if (type == SELECT_SAVEAS_FILE) { | 268 if (type == SELECT_SAVEAS_FILE) { |
269 [dialog setCanSelectHiddenExtension:YES]; | 269 // When file extensions are hidden and removing the extension from |
270 // the default filename gives one which still has an extension | |
271 // that OS X recognizes, it will get confused and think the user | |
272 // 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.
| |
273 // filenames like "foo.tar.gz" or "ball.of.tar.png". Work around | |
274 // this by never hiding extensions in that case. | |
275 base::FilePath::StringType penultimate_extension = | |
276 default_path.RemoveFinalExtension().FinalExtension(); | |
277 if (!penultimate_extension.empty() && | |
278 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
| |
279 [dialog setExtensionHidden:NO]; | |
280 } else { | |
281 [dialog setCanSelectHiddenExtension:YES]; | |
282 } | |
270 } else { | 283 } else { |
271 NSOpenPanel* open_dialog = (NSOpenPanel*)dialog; | 284 NSOpenPanel* open_dialog = (NSOpenPanel*)dialog; |
272 | 285 |
273 if (type == SELECT_OPEN_MULTI_FILE) | 286 if (type == SELECT_OPEN_MULTI_FILE) |
274 [open_dialog setAllowsMultipleSelection:YES]; | 287 [open_dialog setAllowsMultipleSelection:YES]; |
275 else | 288 else |
276 [open_dialog setAllowsMultipleSelection:NO]; | 289 [open_dialog setAllowsMultipleSelection:NO]; |
277 | 290 |
278 if (type == SELECT_FOLDER || type == SELECT_UPLOAD_FOLDER) { | 291 if (type == SELECT_FOLDER || type == SELECT_UPLOAD_FOLDER) { |
279 [open_dialog setCanChooseFiles:NO]; | 292 [open_dialog setCanChooseFiles:NO]; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
420 | 433 |
421 namespace ui { | 434 namespace ui { |
422 | 435 |
423 SelectFileDialog* CreateMacSelectFileDialog( | 436 SelectFileDialog* CreateMacSelectFileDialog( |
424 SelectFileDialog::Listener* listener, | 437 SelectFileDialog::Listener* listener, |
425 SelectFilePolicy* policy) { | 438 SelectFilePolicy* policy) { |
426 return new SelectFileDialogImpl(listener, policy); | 439 return new SelectFileDialogImpl(listener, policy); |
427 } | 440 } |
428 | 441 |
429 } // namespace ui | 442 } // namespace ui |
OLD | NEW |