Commit c02c8a68 authored by jeremy@chromium.org's avatar jeremy@chromium.org

Speculative Crash fix: Return early if user cancels save dialog.

I'm not able to repro the crash, but this seems safer overall.

BUG=16081
TEST=Right click an image, Save as, Chrome should not crash.

Review URL: http://codereview.chromium.org/149244

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20132 0039d316-1c4b-4281-b951-d872f2087c98
parent 16e0efd8
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment