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

Side by Side Diff: chrome/browser/ui/gtk/js_modal_dialog_gtk.cc

Issue 6873082: Fix DELETE_EVENT handling in 3 places. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/gtk/hung_renderer_dialog_gtk.cc ('k') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/gtk/js_modal_dialog_gtk.h" 5 #include "chrome/browser/ui/gtk/js_modal_dialog_gtk.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 } else { 128 } else {
129 // Add the OK button and focus it. 129 // Add the OK button and focus it.
130 GtkWidget* ok_button = gtk_dialog_add_button(GTK_DIALOG(gtk_dialog_), 130 GtkWidget* ok_button = gtk_dialog_add_button(GTK_DIALOG(gtk_dialog_),
131 GTK_STOCK_OK, GTK_RESPONSE_OK); 131 GTK_STOCK_OK, GTK_RESPONSE_OK);
132 if (ui::MessageBoxFlags::kIsJavascriptPrompt != dialog_->dialog_flags()) 132 if (ui::MessageBoxFlags::kIsJavascriptPrompt != dialog_->dialog_flags())
133 gtk_widget_grab_focus(ok_button); 133 gtk_widget_grab_focus(ok_button);
134 } 134 }
135 135
136 gtk_dialog_set_default_response(GTK_DIALOG(gtk_dialog_), GTK_RESPONSE_OK); 136 gtk_dialog_set_default_response(GTK_DIALOG(gtk_dialog_), GTK_RESPONSE_OK);
137 g_signal_connect(gtk_dialog_, "response", G_CALLBACK(OnResponseThunk), this); 137 g_signal_connect(gtk_dialog_, "response", G_CALLBACK(OnResponseThunk), this);
138 // NULL out |gtk_dialog_| when it's destroyed.
Elliot Glaysher 2011/04/19 19:40:13 Today I learn something about GTK.
139 g_signal_connect(gtk_dialog_, "destroy",
140 G_CALLBACK(gtk_widget_destroyed), &gtk_dialog_);
138 } 141 }
139 142
140 JSModalDialogGtk::~JSModalDialogGtk() { 143 JSModalDialogGtk::~JSModalDialogGtk() {
144 if (gtk_dialog_)
145 gtk_widget_destroy(gtk_dialog_);
146
147 // Now that the dialog is gone, we can put all the windows into separate
148 // window groups so other dialogs are no longer app modal.
149 gtk_util::AppModalDismissedUngroupWindows();
141 } 150 }
142 151
143 //////////////////////////////////////////////////////////////////////////////// 152 ////////////////////////////////////////////////////////////////////////////////
144 // JSModalDialogGtk, NativeAppModalDialog implementation: 153 // JSModalDialogGtk, NativeAppModalDialog implementation:
145 154
146 int JSModalDialogGtk::GetAppModalDialogButtons() const { 155 int JSModalDialogGtk::GetAppModalDialogButtons() const {
147 switch (dialog_->dialog_flags()) { 156 switch (dialog_->dialog_flags()) {
148 case ui::MessageBoxFlags::kIsJavascriptAlert: 157 case ui::MessageBoxFlags::kIsJavascriptAlert:
149 return ui::MessageBoxFlags::DIALOGBUTTON_OK; 158 return ui::MessageBoxFlags::DIALOGBUTTON_OK;
150 159
(...skipping 10 matching lines...) Expand all
161 } 170 }
162 } 171 }
163 172
164 void JSModalDialogGtk::ShowAppModalDialog() { 173 void JSModalDialogGtk::ShowAppModalDialog() {
165 gtk_util::ShowDialogWithMinLocalizedWidth(GTK_WIDGET(gtk_dialog_), 174 gtk_util::ShowDialogWithMinLocalizedWidth(GTK_WIDGET(gtk_dialog_),
166 IDS_ALERT_DIALOG_WIDTH_CHARS); 175 IDS_ALERT_DIALOG_WIDTH_CHARS);
167 } 176 }
168 177
169 void JSModalDialogGtk::ActivateAppModalDialog() { 178 void JSModalDialogGtk::ActivateAppModalDialog() {
170 DCHECK(gtk_dialog_); 179 DCHECK(gtk_dialog_);
171 gtk_window_present(GTK_WINDOW(gtk_dialog_));} 180 gtk_window_present(GTK_WINDOW(gtk_dialog_));
181 }
172 182
173 void JSModalDialogGtk::CloseAppModalDialog() { 183 void JSModalDialogGtk::CloseAppModalDialog() {
174 DCHECK(gtk_dialog_); 184 DCHECK(gtk_dialog_);
175 OnResponse(gtk_dialog_, GTK_RESPONSE_DELETE_EVENT); 185 OnResponse(gtk_dialog_, GTK_RESPONSE_DELETE_EVENT);
176 } 186 }
177 187
178 void JSModalDialogGtk::AcceptAppModalDialog() { 188 void JSModalDialogGtk::AcceptAppModalDialog() {
179 OnResponse(gtk_dialog_, GTK_RESPONSE_OK); 189 OnResponse(gtk_dialog_, GTK_RESPONSE_OK);
180 } 190 }
181 191
(...skipping 14 matching lines...) Expand all
196 break; 206 break;
197 207
198 case GTK_RESPONSE_CANCEL: 208 case GTK_RESPONSE_CANCEL:
199 case GTK_RESPONSE_DELETE_EVENT: // User hit the X on the dialog. 209 case GTK_RESPONSE_DELETE_EVENT: // User hit the X on the dialog.
200 dialog_->OnCancel(ShouldSuppressJSDialogs(GTK_DIALOG(dialog))); 210 dialog_->OnCancel(ShouldSuppressJSDialogs(GTK_DIALOG(dialog)));
201 break; 211 break;
202 212
203 default: 213 default:
204 NOTREACHED(); 214 NOTREACHED();
205 } 215 }
206 gtk_widget_destroy(dialog);
207 216
208 // Now that the dialog is gone, we can put all the windows into separate
209 // window groups so other dialogs are no longer app modal.
210 gtk_util::AppModalDismissedUngroupWindows();
211 delete this; 217 delete this;
212 } 218 }
213 219
214 //////////////////////////////////////////////////////////////////////////////// 220 ////////////////////////////////////////////////////////////////////////////////
215 // NativeAppModalDialog, public: 221 // NativeAppModalDialog, public:
216 222
217 // static 223 // static
218 NativeAppModalDialog* NativeAppModalDialog::CreateNativeJavaScriptPrompt( 224 NativeAppModalDialog* NativeAppModalDialog::CreateNativeJavaScriptPrompt(
219 JavaScriptAppModalDialog* dialog, 225 JavaScriptAppModalDialog* dialog,
220 gfx::NativeWindow parent_window) { 226 gfx::NativeWindow parent_window) {
221 return new JSModalDialogGtk(dialog, parent_window); 227 return new JSModalDialogGtk(dialog, parent_window);
222 } 228 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/hung_renderer_dialog_gtk.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698