summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-12 21:03:36 +0000
committerjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-12 21:03:36 +0000
commitf50cfce4449c12df27b68e670a0a8c47019384e6 (patch)
tree9fae24b20a1ef48035035e4e62446fdf524789a4
parentc38c6a8bafc2b1d44c5ecedfdc55c1ecd6a96f8e (diff)
downloadchromium_src-f50cfce4449c12df27b68e670a0a8c47019384e6.zip
chromium_src-f50cfce4449c12df27b68e670a0a8c47019384e6.tar.gz
chromium_src-f50cfce4449c12df27b68e670a0a8c47019384e6.tar.bz2
Merge 85169 - CrOS - Fix file selection dialog not respawning after closing with esc (3)
When the user hits escape, we need to call FileSelectionCanceled on the listener. Added OnWindowClosed() to HtmlDialogUIDelegate so we can catch this case. BUG=chromium-os:14698 TEST=Find or make a web page with a <input type=file /> element. Click on it to select a file. Cancel the file browser dialog with the escape key. Click on it again. Verify that the file browser reopens and works normally. Review URL: http://codereview.chromium.org/7014007 TBR=jamescook@chromium.org Review URL: http://codereview.chromium.org/7016023 git-svn-id: svn://svn.chromium.org/chrome/branches/742/src@85182 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/gtk/constrained_html_delegate_gtk.cc1
-rw-r--r--chrome/browser/ui/views/constrained_html_delegate_gtk.cc1
-rw-r--r--chrome/browser/ui/views/constrained_html_delegate_win.cc1
-rw-r--r--chrome/browser/ui/views/file_manager_dialogs.cc8
-rw-r--r--chrome/browser/ui/views/html_dialog_view.cc10
-rw-r--r--chrome/browser/ui/views/html_dialog_view.h1
-rw-r--r--chrome/browser/ui/webui/html_dialog_ui.cc3
-rw-r--r--chrome/browser/ui/webui/html_dialog_ui.h5
8 files changed, 29 insertions, 1 deletions
diff --git a/chrome/browser/ui/gtk/constrained_html_delegate_gtk.cc b/chrome/browser/ui/gtk/constrained_html_delegate_gtk.cc
index 612cba1..0b9cde6 100644
--- a/chrome/browser/ui/gtk/constrained_html_delegate_gtk.cc
+++ b/chrome/browser/ui/gtk/constrained_html_delegate_gtk.cc
@@ -32,6 +32,7 @@ class ConstrainedHtmlDelegateGtk : public ConstrainedWindowGtkDelegate,
return tab_.tab_contents()->GetContentNativeView();
}
virtual void DeleteDelegate() {
+ html_delegate_->OnWindowClosed();
html_delegate_->OnDialogClosed("");
delete this;
}
diff --git a/chrome/browser/ui/views/constrained_html_delegate_gtk.cc b/chrome/browser/ui/views/constrained_html_delegate_gtk.cc
index ea48190..53a4910 100644
--- a/chrome/browser/ui/views/constrained_html_delegate_gtk.cc
+++ b/chrome/browser/ui/views/constrained_html_delegate_gtk.cc
@@ -41,6 +41,7 @@ class ConstrainedHtmlDelegateGtk : public views::WidgetGtk,
return html_tab_contents_.GetContentNativeView();
}
virtual void DeleteDelegate() {
+ html_delegate_->OnWindowClosed();
html_delegate_->OnDialogClosed("");
tab_container_->ChangeTabContents(NULL);
}
diff --git a/chrome/browser/ui/views/constrained_html_delegate_win.cc b/chrome/browser/ui/views/constrained_html_delegate_win.cc
index 95781d2..8d4e34c 100644
--- a/chrome/browser/ui/views/constrained_html_delegate_win.cc
+++ b/chrome/browser/ui/views/constrained_html_delegate_win.cc
@@ -33,6 +33,7 @@ class ConstrainedHtmlDelegateWin : public TabContentsContainer,
return this;
}
virtual void WindowClosing() {
+ html_delegate_->OnWindowClosed();
html_delegate_->OnDialogClosed("");
}
diff --git a/chrome/browser/ui/views/file_manager_dialogs.cc b/chrome/browser/ui/views/file_manager_dialogs.cc
index 0038bff..4046778 100644
--- a/chrome/browser/ui/views/file_manager_dialogs.cc
+++ b/chrome/browser/ui/views/file_manager_dialogs.cc
@@ -87,6 +87,14 @@ class FileManagerDialog
owner_window_ = NULL;
}
+ virtual void OnWindowClosed() {
+ // Directly closing the window selects no files.
+ const FileDialogFunction::Callback& callback =
+ FileDialogFunction::Callback::Find(tab_id_);
+ if (!callback.IsNull())
+ callback.listener()->FileSelectionCanceled(callback.params());
+ }
+
// A callback to notify the delegate that the contents have gone
// away. Only relevant if your dialog hosts code that calls
// windows.close() and you've allowed that. If the output parameter
diff --git a/chrome/browser/ui/views/html_dialog_view.cc b/chrome/browser/ui/views/html_dialog_view.cc
index 229f606..180bfad 100644
--- a/chrome/browser/ui/views/html_dialog_view.cc
+++ b/chrome/browser/ui/views/html_dialog_view.cc
@@ -61,6 +61,7 @@ gfx::Size HtmlDialogView::GetPreferredSize() {
bool HtmlDialogView::AcceleratorPressed(const views::Accelerator& accelerator) {
// Pressing ESC closes the dialog.
DCHECK_EQ(ui::VKEY_ESCAPE, accelerator.GetKeyCode());
+ OnWindowClosed();
OnDialogClosed(std::string());
return true;
}
@@ -88,8 +89,10 @@ void HtmlDialogView::WindowClosing() {
// If we still have a delegate that means we haven't notified it of the
// dialog closing. This happens if the user clicks the Close button on the
// dialog.
- if (delegate_)
+ if (delegate_) {
+ OnWindowClosed();
OnDialogClosed("");
+ }
}
views::View* HtmlDialogView::GetContentsView() {
@@ -148,6 +151,11 @@ void HtmlDialogView::OnDialogClosed(const std::string& json_retval) {
window()->CloseWindow();
}
+void HtmlDialogView::OnWindowClosed() {
+ if (delegate_)
+ delegate_->OnWindowClosed();
+}
+
void HtmlDialogView::OnCloseContents(TabContents* source,
bool* out_close_dialog) {
if (delegate_)
diff --git a/chrome/browser/ui/views/html_dialog_view.h b/chrome/browser/ui/views/html_dialog_view.h
index af91ecf..38e59aa 100644
--- a/chrome/browser/ui/views/html_dialog_view.h
+++ b/chrome/browser/ui/views/html_dialog_view.h
@@ -65,6 +65,7 @@ class HtmlDialogView
std::vector<WebUIMessageHandler*>* handlers) const;
virtual void GetDialogSize(gfx::Size* size) const;
virtual std::string GetDialogArgs() const;
+ virtual void OnWindowClosed();
virtual void OnDialogClosed(const std::string& json_retval);
virtual void OnCloseContents(TabContents* source, bool* out_close_dialog);
virtual bool ShouldShowDialogTitle() const;
diff --git a/chrome/browser/ui/webui/html_dialog_ui.cc b/chrome/browser/ui/webui/html_dialog_ui.cc
index 871fea2..a8c0607 100644
--- a/chrome/browser/ui/webui/html_dialog_ui.cc
+++ b/chrome/browser/ui/webui/html_dialog_ui.cc
@@ -85,6 +85,9 @@ ExternalHtmlDialogUI::ExternalHtmlDialogUI(TabContents* tab_contents)
ExternalHtmlDialogUI::~ExternalHtmlDialogUI() {
}
+void HtmlDialogUIDelegate::OnWindowClosed() {
+}
+
bool HtmlDialogUIDelegate::HandleContextMenu(const ContextMenuParams& params) {
return false;
}
diff --git a/chrome/browser/ui/webui/html_dialog_ui.h b/chrome/browser/ui/webui/html_dialog_ui.h
index adfea4b..9453a9a 100644
--- a/chrome/browser/ui/webui/html_dialog_ui.h
+++ b/chrome/browser/ui/webui/html_dialog_ui.h
@@ -47,6 +47,11 @@ class HtmlDialogUIDelegate {
// A callback to notify the delegate that the dialog closed.
virtual void OnDialogClosed(const std::string& json_retval) = 0;
+ // Notifies the delegate that the dialog's containing window has been
+ // closed, and that OnDialogClosed() will be called shortly.
+ // TODO(jamescook): Make this pure virtual.
+ virtual void OnWindowClosed();
+
// A callback to notify the delegate that the contents have gone
// away. Only relevant if your dialog hosts code that calls
// windows.close() and you've allowed that. If the output parameter