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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/download/save_package_file_picker.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 happens with
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) {
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
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
OLDNEW
« 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