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

Unified Diff: chrome/browser/browser.cc

Issue 459008: Mac: the return of the tab-modal-sheets patch. (Closed)
Patch Set: Merged ToT. Must ... commit ... soon. Created 11 years 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 | chrome/browser/cocoa/constrained_window_mac.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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() {
« no previous file with comments | « no previous file | chrome/browser/cocoa/constrained_window_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698