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

Side by Side Diff: chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.cc

Issue 2398723002: Fix crash in aura::Window::GetHost (Closed)
Patch Set: Created 4 years, 2 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.h" 5 #include "chrome/browser/ui/libgtk2ui/select_file_dialog_impl_gtk2.h"
6 6
7 #include <gdk/gdkx.h> 7 #include <gdk/gdkx.h>
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <sys/stat.h> 10 #include <sys/stat.h>
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 preview_ = gtk_image_new(); 163 preview_ = gtk_image_new();
164 g_signal_connect(dialog, "destroy", 164 g_signal_connect(dialog, "destroy",
165 G_CALLBACK(OnFileChooserDestroyThunk), this); 165 G_CALLBACK(OnFileChooserDestroyThunk), this);
166 g_signal_connect(dialog, "update-preview", 166 g_signal_connect(dialog, "update-preview",
167 G_CALLBACK(OnUpdatePreviewThunk), this); 167 G_CALLBACK(OnUpdatePreviewThunk), this);
168 gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(dialog), preview_); 168 gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(dialog), preview_);
169 169
170 params_map_[dialog] = params; 170 params_map_[dialog] = params;
171 171
172 // Disable input events handling in the host window to make this dialog modal. 172 // Disable input events handling in the host window to make this dialog modal.
173 views::DesktopWindowTreeHostX11* host = 173 aura::WindowTreeHost* host = owning_window->GetHost();
174 views::DesktopWindowTreeHostX11::GetHostForXID( 174 if (host) {
175 owning_window->GetHost()->GetAcceleratedWidget()); 175 std::unique_ptr<base::Closure> callback =
176 std::unique_ptr<base::Closure> callback = host->DisableEventListening( 176 views::DesktopWindowTreeHostX11::GetHostForXID(
177 GDK_WINDOW_XID(gtk_widget_get_window(dialog))); 177 host->GetAcceleratedWidget())->DisableEventListening(
178 // OnFilePickerDestroy() is called when |dialog| destroyed, which allows to 178 GDK_WINDOW_XID(gtk_widget_get_window(dialog)));
179 // invoke the callback function to re-enable events on the owning window. 179 // OnFilePickerDestroy() is called when |dialog| destroyed, which allows to
180 g_object_set_data_full(G_OBJECT(dialog), "callback", callback.release(), 180 // invoke the callback function to re-enable events on the owning window.
181 reinterpret_cast<GDestroyNotify>(OnFilePickerDestroy)); 181 g_object_set_data_full(G_OBJECT(dialog), "callback", callback.release(),
182 gtk_window_set_modal(GTK_WINDOW(dialog), TRUE); 182 reinterpret_cast<GDestroyNotify>(OnFilePickerDestroy));
183 gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
184 }
183 185
184 gtk_widget_show_all(dialog); 186 gtk_widget_show_all(dialog);
185 187
186 // We need to call gtk_window_present after making the widgets visible to make 188 // We need to call gtk_window_present after making the widgets visible to make
187 // sure window gets correctly raised and gets focus. 189 // sure window gets correctly raised and gets focus.
188 gtk_window_present_with_time( 190 gtk_window_present_with_time(
189 GTK_WINDOW(dialog), ui::X11EventSource::GetInstance()->GetTimestamp()); 191 GTK_WINDOW(dialog), ui::X11EventSource::GetInstance()->GetTimestamp());
190 } 192 }
191 193
192 void SelectFileDialogImplGTK::AddFilters(GtkFileChooser* chooser) { 194 void SelectFileDialogImplGTK::AddFilters(GtkFileChooser* chooser) {
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 g_free(filename); 549 g_free(filename);
548 if (pixbuf) { 550 if (pixbuf) {
549 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf); 551 gtk_image_set_from_pixbuf(GTK_IMAGE(preview_), pixbuf);
550 g_object_unref(pixbuf); 552 g_object_unref(pixbuf);
551 } 553 }
552 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser), 554 gtk_file_chooser_set_preview_widget_active(GTK_FILE_CHOOSER(chooser),
553 pixbuf ? TRUE : FALSE); 555 pixbuf ? TRUE : FALSE);
554 } 556 }
555 557
556 } // namespace libgtk2ui 558 } // namespace libgtk2ui
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698