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

Unified Diff: chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.cc

Issue 1363093004: Add BrowserSelectFileDialogTest.OpenCloseFileDialog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: call gtk_widget_destroy() to close the file-picker Created 5 years, 1 month 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/ui/views/frame/browser_view_focus_uitest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « no previous file | chrome/browser/ui/views/frame/browser_view_focus_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698