| Index: chrome/browser/browser.cc
|
| diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
|
| index 52eedaddd615977c8d4b74a9b8f02d385fb7235e..1f8ddff485829c7bff3da63499223b0c98728de4 100644
|
| --- a/chrome/browser/browser.cc
|
| +++ b/chrome/browser/browser.cc
|
| @@ -1163,15 +1163,53 @@ void Browser::FocusSearch() {
|
|
|
| void Browser::OpenFile() {
|
| UserMetrics::RecordAction("OpenFile", profile_);
|
| - if (!select_file_dialog_.get())
|
| - select_file_dialog_ = SelectFileDialog::Create(this);
|
| +
|
| + TabContents* contents = GetSelectedTabContents();
|
| + if (!contents) { // Avoid crashing in release.
|
| + NOTREACHED();
|
| + return;
|
| + }
|
|
|
| // TODO(beng): figure out how to juggle this.
|
| +#if defined(OS_MACOSX)
|
| + // TODO(viettrungluu): If there's a constrained dialog in the current tab, we
|
| + // should probably just create a new tab and go do the open there. (Why not
|
| + // just close the current dialog, esp. if it's not important? If we did that,
|
| + // then the previous one should come back with its original state on cancel.)
|
| + if (!contents->CanCreateConstrainedDialog()) {
|
| + if (type() == TYPE_NORMAL) {
|
| + contents = AddBlankTab(true);
|
| + if (!contents) { // Avoid crashing in release.
|
| + NOTREACHED();
|
| + return;
|
| + }
|
| + } else {
|
| + // TODO(viettrungluu): the other cases.
|
| + NOTIMPLEMENTED();
|
| + return;
|
| + }
|
| + }
|
| +
|
| + if (!contents->CanCreateConstrainedDialog()) { // Avoid crashing in release.
|
| + NOTREACHED();
|
| + return;
|
| + }
|
| +
|
| + if (!select_file_dialog_.get())
|
| + select_file_dialog_ = SelectFileDialog::Create(this);
|
| + select_file_dialog_->SelectFileInTab(SelectFileDialog::SELECT_OPEN_FILE,
|
| + string16(), FilePath(),
|
| + NULL, 0, FILE_PATH_LITERAL(""),
|
| + contents, NULL);
|
| +#else
|
| + if (!select_file_dialog_.get())
|
| + select_file_dialog_ = SelectFileDialog::Create(this);
|
| gfx::NativeWindow parent_window = window_->GetNativeHandle();
|
| select_file_dialog_->SelectFile(SelectFileDialog::SELECT_OPEN_FILE,
|
| string16(), FilePath(),
|
| NULL, 0, FILE_PATH_LITERAL(""),
|
| parent_window, NULL);
|
| +#endif
|
| }
|
|
|
| void Browser::OpenCreateShortcutsDialog() {
|
|
|