OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/shell_dialogs.h" | 5 #include "chrome/browser/shell_dialogs.h" |
6 | 6 |
7 #include <CoreServices/CoreServices.h> | 7 #include <CoreServices/CoreServices.h> |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 SelectFileDialogImpl::SheetContext* context_struct = | 307 SelectFileDialogImpl::SheetContext* context_struct = |
308 (SelectFileDialogImpl::SheetContext*)context; | 308 (SelectFileDialogImpl::SheetContext*)context; |
309 | 309 |
310 SelectFileDialog::Type type = context_struct->type; | 310 SelectFileDialog::Type type = context_struct->type; |
311 NSWindow* parentWindow = context_struct->owning_window; | 311 NSWindow* parentWindow = context_struct->owning_window; |
312 delete context_struct; | 312 delete context_struct; |
313 | 313 |
314 bool isMulti = type == SelectFileDialog::SELECT_OPEN_MULTI_FILE; | 314 bool isMulti = type == SelectFileDialog::SELECT_OPEN_MULTI_FILE; |
315 | 315 |
316 std::vector<FilePath> paths; | 316 std::vector<FilePath> paths; |
317 if (type == SelectFileDialog::SELECT_SAVEAS_FILE) { | 317 bool did_cancel = returnCode == NSCancelButton; |
318 paths.push_back(FilePath(base::SysNSStringToUTF8([panel filename]))); | 318 if (!did_cancel) { |
| 319 if (type == SelectFileDialog::SELECT_SAVEAS_FILE) { |
| 320 paths.push_back(FilePath(base::SysNSStringToUTF8([panel filename]))); |
319 | 321 |
320 NSView* accessoryView = [panel accessoryView]; | 322 NSView* accessoryView = [panel accessoryView]; |
321 if (accessoryView) { | 323 if (accessoryView) { |
322 NSPopUpButton* popup = [accessoryView viewWithTag:kFileTypePopupTag]; | 324 NSPopUpButton* popup = [accessoryView viewWithTag:kFileTypePopupTag]; |
323 if (popup) { | 325 if (popup) { |
324 index = [popup indexOfSelectedItem]+1; // file type indexes are 1-based | 326 // File type indexes are 1-based. |
| 327 index = [popup indexOfSelectedItem] + 1; |
| 328 } |
325 } | 329 } |
| 330 } else { |
| 331 NSArray* filenames = [panel filenames]; |
| 332 for (NSString* filename in filenames) |
| 333 paths.push_back(FilePath(base::SysNSStringToUTF8(filename))); |
326 } | 334 } |
327 } else { | |
328 NSArray* filenames = [panel filenames]; | |
329 for (NSString* filename in filenames) | |
330 paths.push_back(FilePath(base::SysNSStringToUTF8(filename))); | |
331 } | 335 } |
332 | 336 |
333 selectFileDialogImpl_->FileWasSelected(panel, | 337 selectFileDialogImpl_->FileWasSelected(panel, |
334 parentWindow, | 338 parentWindow, |
335 returnCode==NSCancelButton, | 339 did_cancel, |
336 isMulti, | 340 isMulti, |
337 paths, | 341 paths, |
338 index); | 342 index); |
339 } | 343 } |
340 | 344 |
341 @end | 345 @end |
OLD | NEW |