Index: chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.cc |
diff --git a/chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.cc b/chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.cc |
index 3beecc718da28cca68b68300db6d7d34d55690be..67ad3a22d7dfaabf059aff940acef2bfe5579e10 100644 |
--- a/chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.cc |
+++ b/chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.cc |
@@ -2,6 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
+#include <gdk/gdkx.h> |
#include <gtk/gtk.h> |
#include <sys/stat.h> |
#include <sys/types.h> |
@@ -29,6 +30,7 @@ |
#include "ui/base/l10n/l10n_util.h" |
#include "ui/shell_dialogs/select_file_dialog.h" |
#include "ui/strings/grit/ui_strings.h" |
+#include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" |
#include "ui/views/widget/desktop_aura/x11_desktop_handler.h" |
namespace { |
@@ -57,6 +59,9 @@ class SelectFileDialogImplGTK : public SelectFileDialogImpl, |
explicit SelectFileDialogImplGTK(Listener* listener, |
ui::SelectFilePolicy* policy); |
+ // Close the file dialog. |
+ void Close() override; |
+ |
protected: |
~SelectFileDialogImplGTK() override; |
@@ -289,6 +294,25 @@ void SelectFileDialogImplGTK::SelectFileImpl( |
gtk_window_present_with_time(GTK_WINDOW(dialog), time); |
} |
+void SelectFileDialogImplGTK::Close() { |
+ // Close the file-picker. |
+ |
+ // Get the focused dialog. |
+ XID focused_window = 0; |
+ int revert = 0; |
+ XGetInputFocus(gfx::GetXDisplay(), &focused_window, &revert); |
+ |
+ // Check if the focused window is the file-picker dialog. |
+ for (auto it = dialogs_.begin(); it != dialogs_.end(); ++it) { |
+ if (focused_window == GDK_WINDOW_XID(gtk_widget_get_window(*it))) { |
+ gtk_widget_destroy(*it); |
+ return; |
+ } |
+ } |
sadrul
2015/11/02 01:31:38
This seems unnecessarily complex (e.g. there's no
|
+ |
+ NOTREACHED() << "Cannot find the focused dialog"; |
+} |
+ |
void SelectFileDialogImplGTK::AddFilters(GtkFileChooser* chooser) { |
for (size_t i = 0; i < file_types_.extensions.size(); ++i) { |
GtkFileFilter* filter = NULL; |