diff options
author | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-17 10:43:54 +0000 |
---|---|---|
committer | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-17 10:43:54 +0000 |
commit | 440dbb105f67a7701fd7abeede3e018611b59834 (patch) | |
tree | 45aeeef1044ee0b152b76ef0d1ca4528f0a1810e /chrome/browser/gtk | |
parent | f6c777ba63e454c9702521c77f86d95571e01b50 (diff) | |
download | chromium_src-440dbb105f67a7701fd7abeede3e018611b59834.zip chromium_src-440dbb105f67a7701fd7abeede3e018611b59834.tar.gz chromium_src-440dbb105f67a7701fd7abeede3e018611b59834.tar.bz2 |
Fix crash on opening a file save dialog when the parent tab has no content on Mac/Linux
BUG=29213
TEST=Check 'Ask where to save each file before downloading' in 'Under the Hood' preferences. Open a page that has links to downloadable items (like http://ftp.sunet.se/pub/Linux/kernels/v1.0/). Right-click on one of the item and choose 'Open Link in New Tab'.
Make sure an empty tab opens and a dialog appears for asking where to save the file. Make sure the dialog does not disappear immediately. Make sure that closing the empty tab do not crash the browser.
Review URL: http://codereview.chromium.org/507024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34820 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r-- | chrome/browser/gtk/dialogs_gtk.cc | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/chrome/browser/gtk/dialogs_gtk.cc b/chrome/browser/gtk/dialogs_gtk.cc index 5cd406b..12957ab 100644 --- a/chrome/browser/gtk/dialogs_gtk.cc +++ b/chrome/browser/gtk/dialogs_gtk.cc @@ -192,10 +192,11 @@ void SelectFileDialogImpl::SelectFile( gfx::NativeWindow owning_window, void* params) { type_ = type; - // TODO(estade): on windows, owning_window may be null. But I'm not sure when - // that's used and how to deal with it here. For now, don't allow it. - DCHECK(owning_window); - parents_.insert(owning_window); + // |owning_window| can be null when user right-clicks on a downloadable item + // and chooses 'Open Link in New Tab' when 'Ask where to save each file + // before downloading.' preference is turned on. (http://crbug.com/29213) + if (owning_window) + parents_.insert(owning_window); std::string title_string = UTF16ToUTF8(title); @@ -209,7 +210,7 @@ void SelectFileDialogImpl::SelectFile( switch (type) { case SELECT_FOLDER: dialog = CreateSelectFolderDialog(title_string, default_path, - owning_window); + owning_window); break; case SELECT_OPEN_FILE: dialog = CreateFileOpenDialog(title_string, default_path, owning_window); @@ -453,8 +454,11 @@ void* SelectFileDialogImpl::PopParamsForDialog(GtkWidget* dialog) { void SelectFileDialogImpl::FileDialogDestroyed(GtkWidget* dialog) { dialogs_.erase(dialog); - // Parent may be NULL on shutdown when AllBrowsersClosed() trigger this - // handler after all the browser windows got destroyed. + // Parent may be NULL in a few cases: 1) on shutdown when + // AllBrowsersClosed() trigger this handler after all the browser + // windows got destroyed, or 2) when the parent tab has been opened by + // 'Open Link in New Tab' context menu on a downloadable item and + // the tab has no content (see the comment in SelectFile as well). GtkWindow* parent = gtk_window_get_transient_for(GTK_WINDOW(dialog)); if (!parent) return; |