1- // Default dialog handler implementation on Linux.
2- // Copied from upstream cefclient with changes:
3- // - Rewrote GetWindow() func
4- // - Removed "client" namespace
5- // - Changed titles of JS alerts, removed URL and "Javascript" word
1+ // COPIED from upstream "cef/tests/cefclient/browser/" directory
2+ // with minor modifications. See the .patch file in current directory.
63
74// Copyright (c) 2015 The Chromium Embedded Framework Authors. All rights
85// reserved. Use of this source code is governed by a BSD-style license that
96// can be found in the LICENSE file.
107
118#include < libgen.h>
129#include < sys/stat.h>
13- #include < X11/Xlib.h>
14- #include < gtk/gtk.h>
15- #include < gdk/gdkx.h>
1610
1711#include " include/cef_browser.h"
1812#include " include/cef_parser.h"
1913#include " include/wrapper/cef_helpers.h"
2014
2115#include " include/base/cef_logging.h"
22-
2316#include " dialog_handler_gtk.h"
2417#include " x11.h"
2518
@@ -43,10 +36,10 @@ std::string GetDescriptionFromMimeType(const std::string& mime_type) {
4336 const char * mime_type;
4437 const char * label;
4538 } kWildCardMimeTypes [] = {
46- { " audio" , " Audio Files" },
47- { " image" , " Image Files" },
48- { " text" , " Text Files" },
49- { " video" , " Video Files" },
39+ { " audio" , " Audio Files" },
40+ { " image" , " Image Files" },
41+ { " text" , " Text Files" },
42+ { " video" , " Video Files" },
5043 };
5144
5245 for (size_t i = 0 ;
@@ -140,11 +133,7 @@ void AddFilters(GtkFileChooser* chooser,
140133
141134} // namespace
142135
143-
144-
145- ClientDialogHandlerGtk::ClientDialogHandlerGtk ()
146- : gtk_dialog_(NULL ) {
147- }
136+ ClientDialogHandlerGtk::ClientDialogHandlerGtk () : gtk_dialog_(NULL ) {}
148137
149138bool ClientDialogHandlerGtk::OnFileDialog (
150139 CefRefPtr<CefBrowser> browser,
@@ -161,7 +150,7 @@ bool ClientDialogHandlerGtk::OnFileDialog(
161150
162151 // Remove any modifier flags.
163152 FileDialogMode mode_type =
164- static_cast <FileDialogMode>(mode & FILE_DIALOG_TYPE_MASK);
153+ static_cast <FileDialogMode>(mode & FILE_DIALOG_TYPE_MASK);
165154
166155 if (mode_type == FILE_DIALOG_OPEN || mode_type == FILE_DIALOG_OPEN_MULTIPLE) {
167156 action = GTK_FILE_CHOOSER_ACTION_OPEN;
@@ -204,20 +193,15 @@ bool ClientDialogHandlerGtk::OnFileDialog(
204193 return false ;
205194
206195 GtkWidget* dialog = gtk_file_chooser_dialog_new (
207- title_str.c_str (),
208- GTK_WINDOW (window),
209- action,
210- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
211- accept_button, GTK_RESPONSE_ACCEPT,
212- NULL );
196+ title_str.c_str (), GTK_WINDOW (window), action, GTK_STOCK_CANCEL,
197+ GTK_RESPONSE_CANCEL, accept_button, GTK_RESPONSE_ACCEPT, NULL );
213198
214199 if (mode_type == FILE_DIALOG_OPEN_MULTIPLE)
215200 gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE );
216201
217202 if (mode_type == FILE_DIALOG_SAVE) {
218203 gtk_file_chooser_set_do_overwrite_confirmation (
219- GTK_FILE_CHOOSER (dialog),
220- !!(mode & FILE_DIALOG_OVERWRITEPROMPT_FLAG));
204+ GTK_FILE_CHOOSER (dialog), !!(mode & FILE_DIALOG_OVERWRITEPROMPT_FLAG));
221205 }
222206
223207 gtk_file_chooser_set_show_hidden (GTK_FILE_CHOOSER (dialog),
@@ -230,8 +214,7 @@ bool ClientDialogHandlerGtk::OnFileDialog(
230214 struct stat sb;
231215 if (stat (file_path.c_str (), &sb) == 0 && S_ISREG (sb.st_mode )) {
232216 // Use the directory and name of the existing file.
233- gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (dialog),
234- file_path.data ());
217+ gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (dialog), file_path.data ());
235218 exists = true ;
236219 }
237220
@@ -298,14 +281,13 @@ bool ClientDialogHandlerGtk::OnFileDialog(
298281 return true ;
299282}
300283
301- bool ClientDialogHandlerGtk::OnJSDialog (
302- CefRefPtr<CefBrowser> browser,
303- const CefString& origin_url,
304- JSDialogType dialog_type,
305- const CefString& message_text,
306- const CefString& default_prompt_text,
307- CefRefPtr<CefJSDialogCallback> callback,
308- bool & suppress_message) {
284+ bool ClientDialogHandlerGtk::OnJSDialog (CefRefPtr<CefBrowser> browser,
285+ const CefString& origin_url,
286+ JSDialogType dialog_type,
287+ const CefString& message_text,
288+ const CefString& default_prompt_text,
289+ CefRefPtr<CefJSDialogCallback> callback,
290+ bool & suppress_message) {
309291 CEF_REQUIRE_UI_THREAD ();
310292
311293 GtkButtonsType buttons = GTK_BUTTONS_NONE;
@@ -343,22 +325,16 @@ bool ClientDialogHandlerGtk::OnJSDialog(
343325 if (!window)
344326 return false ;
345327
346- gtk_dialog_ = gtk_message_dialog_new (GTK_WINDOW (window),
347- GTK_DIALOG_MODAL,
348- gtk_message_type,
349- buttons,
350- " %s" ,
328+ gtk_dialog_ = gtk_message_dialog_new (GTK_WINDOW (window), GTK_DIALOG_MODAL,
329+ gtk_message_type, buttons, " %s" ,
351330 message_text.ToString ().c_str ());
352- g_signal_connect (gtk_dialog_,
353- " delete-event" ,
354- G_CALLBACK (gtk_widget_hide_on_delete),
355- NULL );
331+ g_signal_connect (gtk_dialog_, " delete-event" ,
332+ G_CALLBACK (gtk_widget_hide_on_delete), NULL );
356333
357334 gtk_window_set_title (GTK_WINDOW (gtk_dialog_), title.c_str ());
358335
359336 GtkWidget* ok_button = gtk_dialog_add_button (GTK_DIALOG (gtk_dialog_),
360- GTK_STOCK_OK,
361- GTK_RESPONSE_OK);
337+ GTK_STOCK_OK, GTK_RESPONSE_OK);
362338
363339 if (dialog_type != JSDIALOGTYPE_PROMPT)
364340 gtk_widget_grab_focus (ok_button);
0 commit comments