Chromium Code Reviews

Side by Side Diff: ui/shell_dialogs/select_file_dialog_mac.mm

Issue 612143002: Disable package selection for multiple-selection file dialogs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « no previous file | 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 143 matching lines...)
154 if (is_multi) { 154 if (is_multi) {
155 listener_->MultiFilesSelected(files, params); 155 listener_->MultiFilesSelected(files, params);
156 } else { 156 } else {
157 listener_->FileSelected(files[0], index, params); 157 listener_->FileSelected(files[0], index, params);
158 } 158 }
159 } 159 }
160 } 160 }
161 161
162 bool SelectFileDialogImpl::ShouldEnableFilename(NSSavePanel* dialog, 162 bool SelectFileDialogImpl::ShouldEnableFilename(NSSavePanel* dialog,
163 NSString* filename) { 163 NSString* filename) {
164 // If this is a single open file dialog, disable selecting packages. 164 // If this is a single/multiple open file dialog, disable selecting packages.
165 if (type_map_[dialog] != SELECT_OPEN_FILE) 165 if (type_map_[dialog] != SELECT_OPEN_FILE &&
166 type_map_[dialog] != SELECT_OPEN_MULTI_FILE)
166 return true; 167 return true;
167 168
168 return ![[NSWorkspace sharedWorkspace] isFilePackageAtPath:filename]; 169 return ![[NSWorkspace sharedWorkspace] isFilePackageAtPath:filename];
169 } 170 }
170 171
171 void SelectFileDialogImpl::SelectFileImpl( 172 void SelectFileDialogImpl::SelectFileImpl(
172 Type type, 173 Type type,
173 const base::string16& title, 174 const base::string16& title,
174 const base::FilePath& default_path, 175 const base::FilePath& default_path,
175 const FileTypeInfo* file_types, 176 const FileTypeInfo* file_types,
(...skipping 242 matching lines...)
418 bool isMulti = type == ui::SelectFileDialog::SELECT_OPEN_MULTI_FILE; 419 bool isMulti = type == ui::SelectFileDialog::SELECT_OPEN_MULTI_FILE;
419 selectFileDialogImpl_->FileWasSelected(panel, 420 selectFileDialogImpl_->FileWasSelected(panel,
420 parentWindow, 421 parentWindow,
421 did_cancel, 422 did_cancel,
422 isMulti, 423 isMulti,
423 paths, 424 paths,
424 index); 425 index);
425 [panel release]; 426 [panel release];
426 } 427 }
427 428
428 - (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename { 429 - (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename {
erikchen 2014/09/29 19:42:59 For reference, this method was deprecated in 10.6
Avi (use Gerrit) 2014/09/29 20:20:39 Done.
429 return selectFileDialogImpl_->ShouldEnableFilename(sender, filename); 430 return selectFileDialogImpl_->ShouldEnableFilename(sender, filename);
430 } 431 }
431 432
432 @end 433 @end
433 434
434 namespace ui { 435 namespace ui {
435 436
436 SelectFileDialog* CreateMacSelectFileDialog( 437 SelectFileDialog* CreateMacSelectFileDialog(
437 SelectFileDialog::Listener* listener, 438 SelectFileDialog::Listener* listener,
438 SelectFilePolicy* policy) { 439 SelectFilePolicy* policy) {
439 return new SelectFileDialogImpl(listener, policy); 440 return new SelectFileDialogImpl(listener, policy);
440 } 441 }
441 442
442 } // namespace ui 443 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine