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

Unified Diff: chrome/browser/cocoa/shell_dialogs_mac.mm

Issue 149244: Speculative Crash fix: Return early if user cancels save dialog. (Closed)
Patch Set: Created 11 years, 5 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/shell_dialogs_mac.mm
diff --git a/chrome/browser/cocoa/shell_dialogs_mac.mm b/chrome/browser/cocoa/shell_dialogs_mac.mm
index d439a5a447210cd29dde25b81b1ae6c6b8f7910b..400a848175bd6bc99c79d8c120a081775e120e20 100644
--- a/chrome/browser/cocoa/shell_dialogs_mac.mm
+++ b/chrome/browser/cocoa/shell_dialogs_mac.mm
@@ -314,25 +314,29 @@ NSView* SelectFileDialogImpl::GetAccessoryView(const FileTypeInfo* file_types,
bool isMulti = type == SelectFileDialog::SELECT_OPEN_MULTI_FILE;
std::vector<FilePath> paths;
- if (type == SelectFileDialog::SELECT_SAVEAS_FILE) {
- paths.push_back(FilePath(base::SysNSStringToUTF8([panel filename])));
-
- NSView* accessoryView = [panel accessoryView];
- if (accessoryView) {
- NSPopUpButton* popup = [accessoryView viewWithTag:kFileTypePopupTag];
- if (popup) {
- index = [popup indexOfSelectedItem]+1; // file type indexes are 1-based
+ bool did_cancel = returnCode == NSCancelButton;
+ if (!did_cancel) {
+ if (type == SelectFileDialog::SELECT_SAVEAS_FILE) {
+ paths.push_back(FilePath(base::SysNSStringToUTF8([panel filename])));
+
+ NSView* accessoryView = [panel accessoryView];
+ if (accessoryView) {
+ NSPopUpButton* popup = [accessoryView viewWithTag:kFileTypePopupTag];
+ if (popup) {
+ // File type indexes are 1-based.
+ index = [popup indexOfSelectedItem] + 1;
+ }
}
+ } else {
+ NSArray* filenames = [panel filenames];
+ for (NSString* filename in filenames)
+ paths.push_back(FilePath(base::SysNSStringToUTF8(filename)));
}
- } else {
- NSArray* filenames = [panel filenames];
- for (NSString* filename in filenames)
- paths.push_back(FilePath(base::SysNSStringToUTF8(filename)));
}
selectFileDialogImpl_->FileWasSelected(panel,
parentWindow,
- returnCode==NSCancelButton,
+ did_cancel,
isMulti,
paths,
index);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698