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

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

Issue 6627038: gtk: Rename OnDialogResponse() to OnResponse() to standardize on a consistent naming scheme. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 9 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
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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 GTK_RESPONSE_CANCEL); 127 GTK_RESPONSE_CANCEL);
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", 137 g_signal_connect(gtk_dialog_, "response", G_CALLBACK(OnResponseThunk), this);
138 G_CALLBACK(OnDialogResponseThunk), this);
139 } 138 }
140 139
141 JSModalDialogGtk::~JSModalDialogGtk() { 140 JSModalDialogGtk::~JSModalDialogGtk() {
142 } 141 }
143 142
144 //////////////////////////////////////////////////////////////////////////////// 143 ////////////////////////////////////////////////////////////////////////////////
145 // JSModalDialogGtk, NativeAppModalDialog implementation: 144 // JSModalDialogGtk, NativeAppModalDialog implementation:
146 145
147 int JSModalDialogGtk::GetAppModalDialogButtons() const { 146 int JSModalDialogGtk::GetAppModalDialogButtons() const {
148 switch (dialog_->dialog_flags()) { 147 switch (dialog_->dialog_flags()) {
(...skipping 17 matching lines...) Expand all
166 gtk_util::ShowModalDialogWithMinLocalizedWidth(GTK_WIDGET(gtk_dialog_), 165 gtk_util::ShowModalDialogWithMinLocalizedWidth(GTK_WIDGET(gtk_dialog_),
167 IDS_ALERT_DIALOG_WIDTH_CHARS); 166 IDS_ALERT_DIALOG_WIDTH_CHARS);
168 } 167 }
169 168
170 void JSModalDialogGtk::ActivateAppModalDialog() { 169 void JSModalDialogGtk::ActivateAppModalDialog() {
171 DCHECK(gtk_dialog_); 170 DCHECK(gtk_dialog_);
172 gtk_window_present(GTK_WINDOW(gtk_dialog_));} 171 gtk_window_present(GTK_WINDOW(gtk_dialog_));}
173 172
174 void JSModalDialogGtk::CloseAppModalDialog() { 173 void JSModalDialogGtk::CloseAppModalDialog() {
175 DCHECK(gtk_dialog_); 174 DCHECK(gtk_dialog_);
176 OnDialogResponse(gtk_dialog_, GTK_RESPONSE_DELETE_EVENT); 175 OnResponse(gtk_dialog_, GTK_RESPONSE_DELETE_EVENT);
177 } 176 }
178 177
179 void JSModalDialogGtk::AcceptAppModalDialog() { 178 void JSModalDialogGtk::AcceptAppModalDialog() {
180 OnDialogResponse(gtk_dialog_, GTK_RESPONSE_OK); 179 OnResponse(gtk_dialog_, GTK_RESPONSE_OK);
181 } 180 }
182 181
183 void JSModalDialogGtk::CancelAppModalDialog() { 182 void JSModalDialogGtk::CancelAppModalDialog() {
184 OnDialogResponse(gtk_dialog_, GTK_RESPONSE_CANCEL); 183 OnResponse(gtk_dialog_, GTK_RESPONSE_CANCEL);
185 } 184 }
186 185
187 //////////////////////////////////////////////////////////////////////////////// 186 ////////////////////////////////////////////////////////////////////////////////
188 // JSModalDialogGtk, private: 187 // JSModalDialogGtk, private:
189 188
190 void JSModalDialogGtk::OnDialogResponse(GtkWidget* dialog, 189 void JSModalDialogGtk::OnResponse(GtkWidget* dialog, int response_id) {
191 int response_id) {
192 switch (response_id) { 190 switch (response_id) {
193 case GTK_RESPONSE_OK: 191 case GTK_RESPONSE_OK:
194 // The first arg is the prompt text and the second is true if we want to 192 // The first arg is the prompt text and the second is true if we want to
195 // suppress additional popups from the page. 193 // suppress additional popups from the page.
196 dialog_->OnAccept(GetPromptText(GTK_DIALOG(dialog)), 194 dialog_->OnAccept(GetPromptText(GTK_DIALOG(dialog)),
197 ShouldSuppressJSDialogs(GTK_DIALOG(dialog))); 195 ShouldSuppressJSDialogs(GTK_DIALOG(dialog)));
198 break; 196 break;
199 197
200 case GTK_RESPONSE_CANCEL: 198 case GTK_RESPONSE_CANCEL:
201 case GTK_RESPONSE_DELETE_EVENT: // User hit the X on the dialog. 199 case GTK_RESPONSE_DELETE_EVENT: // User hit the X on the dialog.
202 dialog_->OnCancel(ShouldSuppressJSDialogs(GTK_DIALOG(dialog))); 200 dialog_->OnCancel(ShouldSuppressJSDialogs(GTK_DIALOG(dialog)));
203 break; 201 break;
204 202
205 default: 203 default:
206 NOTREACHED(); 204 NOTREACHED();
207 } 205 }
208 gtk_widget_destroy(GTK_WIDGET(dialog)); 206 gtk_widget_destroy(dialog);
209 207
210 // Now that the dialog is gone, we can put all the windows into separate 208 // Now that the dialog is gone, we can put all the windows into separate
211 // window groups so other dialogs are no longer app modal. 209 // window groups so other dialogs are no longer app modal.
212 gtk_util::AppModalDismissedUngroupWindows(); 210 gtk_util::AppModalDismissedUngroupWindows();
213 delete this; 211 delete this;
214 } 212 }
215 213
216 //////////////////////////////////////////////////////////////////////////////// 214 ////////////////////////////////////////////////////////////////////////////////
217 // NativeAppModalDialog, public: 215 // NativeAppModalDialog, public:
218 216
219 // static 217 // static
220 NativeAppModalDialog* NativeAppModalDialog::CreateNativeJavaScriptPrompt( 218 NativeAppModalDialog* NativeAppModalDialog::CreateNativeJavaScriptPrompt(
221 JavaScriptAppModalDialog* dialog, 219 JavaScriptAppModalDialog* dialog,
222 gfx::NativeWindow parent_window) { 220 gfx::NativeWindow parent_window) {
223 return new JSModalDialogGtk(dialog, parent_window); 221 return new JSModalDialogGtk(dialog, parent_window);
224 } 222 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698