From 357a7fbaac184205e7016076d120ec369006e107 Mon Sep 17 00:00:00 2001 From: cztomczak Date: Mon, 11 Jun 2018 18:38:53 +0200 Subject: [PATCH] Update dialog_handler_gtk files with changes from upstream (#403). Generate a patch file with changes. --- src/cef_v59..v66_changes.txt | 10 +- src/client_handler/dialog_handler_gtk.cpp | 72 ++++------- src/client_handler/dialog_handler_gtk.h | 16 ++- src/client_handler/dialog_handler_gtk.patch | 127 ++++++++++++++++++++ 4 files changed, 163 insertions(+), 62 deletions(-) create mode 100644 src/client_handler/dialog_handler_gtk.patch diff --git a/src/cef_v59..v66_changes.txt b/src/cef_v59..v66_changes.txt index 4b57eba2..36ce50d5 100644 --- a/src/cef_v59..v66_changes.txt +++ b/src/cef_v59..v66_changes.txt @@ -60,12 +60,12 @@ internal/cef_types.h - + Remove: UR_FLAG_ALLOW_CACHED_CREDENTIALS -TODO +MISC ---- -1. Compare src/handler/dialog_handler_gtk.cpp (and .h) with upstream - cefclient files -2. In subprocess/print_handler_gtk.cpp use GetWindow implementation - from x11.cpp ++ Compare src/client_handler/dialog_handler_gtk.cpp (and .h) with upstream + cefclient files +- In subprocess/print_handler_gtk.cpp use GetWindow implementation + from x11.cpp NEW FEATURES ------------ diff --git a/src/client_handler/dialog_handler_gtk.cpp b/src/client_handler/dialog_handler_gtk.cpp index 6c119910..ce5a4d4e 100644 --- a/src/client_handler/dialog_handler_gtk.cpp +++ b/src/client_handler/dialog_handler_gtk.cpp @@ -1,8 +1,5 @@ -// Default dialog handler implementation on Linux. -// Copied from upstream cefclient with changes: -// - Rewrote GetWindow() func -// - Removed "client" namespace -// - Changed titles of JS alerts, removed URL and "Javascript" word +// COPIED from upstream "cef/tests/cefclient/browser/" directory +// with minor modifications. See the .patch file in current directory. // Copyright (c) 2015 The Chromium Embedded Framework Authors. All rights // reserved. Use of this source code is governed by a BSD-style license that @@ -10,16 +7,12 @@ #include #include -#include -#include -#include #include "include/cef_browser.h" #include "include/cef_parser.h" #include "include/wrapper/cef_helpers.h" #include "include/base/cef_logging.h" - #include "dialog_handler_gtk.h" #include "x11.h" @@ -43,10 +36,10 @@ std::string GetDescriptionFromMimeType(const std::string& mime_type) { const char* mime_type; const char* label; } kWildCardMimeTypes[] = { - { "audio", "Audio Files" }, - { "image", "Image Files" }, - { "text", "Text Files" }, - { "video", "Video Files" }, + {"audio", "Audio Files"}, + {"image", "Image Files"}, + {"text", "Text Files"}, + {"video", "Video Files"}, }; for (size_t i = 0; @@ -140,11 +133,7 @@ void AddFilters(GtkFileChooser* chooser, } // namespace - - -ClientDialogHandlerGtk::ClientDialogHandlerGtk() - : gtk_dialog_(NULL) { -} +ClientDialogHandlerGtk::ClientDialogHandlerGtk() : gtk_dialog_(NULL) {} bool ClientDialogHandlerGtk::OnFileDialog( CefRefPtr browser, @@ -161,7 +150,7 @@ bool ClientDialogHandlerGtk::OnFileDialog( // Remove any modifier flags. FileDialogMode mode_type = - static_cast(mode & FILE_DIALOG_TYPE_MASK); + static_cast(mode & FILE_DIALOG_TYPE_MASK); if (mode_type == FILE_DIALOG_OPEN || mode_type == FILE_DIALOG_OPEN_MULTIPLE) { action = GTK_FILE_CHOOSER_ACTION_OPEN; @@ -204,20 +193,15 @@ bool ClientDialogHandlerGtk::OnFileDialog( return false; GtkWidget* dialog = gtk_file_chooser_dialog_new( - title_str.c_str(), - GTK_WINDOW(window), - action, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - accept_button, GTK_RESPONSE_ACCEPT, - NULL); + title_str.c_str(), GTK_WINDOW(window), action, GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL, accept_button, GTK_RESPONSE_ACCEPT, NULL); if (mode_type == FILE_DIALOG_OPEN_MULTIPLE) gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), TRUE); if (mode_type == FILE_DIALOG_SAVE) { gtk_file_chooser_set_do_overwrite_confirmation( - GTK_FILE_CHOOSER(dialog), - !!(mode & FILE_DIALOG_OVERWRITEPROMPT_FLAG)); + GTK_FILE_CHOOSER(dialog), !!(mode & FILE_DIALOG_OVERWRITEPROMPT_FLAG)); } gtk_file_chooser_set_show_hidden(GTK_FILE_CHOOSER(dialog), @@ -230,8 +214,7 @@ bool ClientDialogHandlerGtk::OnFileDialog( struct stat sb; if (stat(file_path.c_str(), &sb) == 0 && S_ISREG(sb.st_mode)) { // Use the directory and name of the existing file. - gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), - file_path.data()); + gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), file_path.data()); exists = true; } @@ -298,14 +281,13 @@ bool ClientDialogHandlerGtk::OnFileDialog( return true; } -bool ClientDialogHandlerGtk::OnJSDialog( - CefRefPtr browser, - const CefString& origin_url, - JSDialogType dialog_type, - const CefString& message_text, - const CefString& default_prompt_text, - CefRefPtr callback, - bool& suppress_message) { +bool ClientDialogHandlerGtk::OnJSDialog(CefRefPtr browser, + const CefString& origin_url, + JSDialogType dialog_type, + const CefString& message_text, + const CefString& default_prompt_text, + CefRefPtr callback, + bool& suppress_message) { CEF_REQUIRE_UI_THREAD(); GtkButtonsType buttons = GTK_BUTTONS_NONE; @@ -343,22 +325,16 @@ bool ClientDialogHandlerGtk::OnJSDialog( if (!window) return false; - gtk_dialog_ = gtk_message_dialog_new(GTK_WINDOW(window), - GTK_DIALOG_MODAL, - gtk_message_type, - buttons, - "%s", + gtk_dialog_ = gtk_message_dialog_new(GTK_WINDOW(window), GTK_DIALOG_MODAL, + gtk_message_type, buttons, "%s", message_text.ToString().c_str()); - g_signal_connect(gtk_dialog_, - "delete-event", - G_CALLBACK(gtk_widget_hide_on_delete), - NULL); + g_signal_connect(gtk_dialog_, "delete-event", + G_CALLBACK(gtk_widget_hide_on_delete), NULL); gtk_window_set_title(GTK_WINDOW(gtk_dialog_), title.c_str()); GtkWidget* ok_button = gtk_dialog_add_button(GTK_DIALOG(gtk_dialog_), - GTK_STOCK_OK, - GTK_RESPONSE_OK); + GTK_STOCK_OK, GTK_RESPONSE_OK); if (dialog_type != JSDIALOGTYPE_PROMPT) gtk_widget_grab_focus(ok_button); diff --git a/src/client_handler/dialog_handler_gtk.h b/src/client_handler/dialog_handler_gtk.h index aba4857a..59f65eda 100644 --- a/src/client_handler/dialog_handler_gtk.h +++ b/src/client_handler/dialog_handler_gtk.h @@ -1,6 +1,5 @@ -// Default dialog handler implementation on Linux. -// Copied from upstream cefclient with changes: -// - Removed "client" namespace +// COPIED from upstream "cef/tests/cefclient/browser/" directory +// with minor modifications. See the .patch file in current directory. // Copyright (c) 2015 The Chromium Embedded Framework Authors. All rights // reserved. Use of this source code is governed by a BSD-style license that @@ -37,15 +36,14 @@ class ClientDialogHandlerGtk : public CefDialogHandler, const CefString& default_prompt_text, CefRefPtr callback, bool& suppress_message) OVERRIDE; - bool OnBeforeUnloadDialog( - CefRefPtr browser, - const CefString& message_text, - bool is_reload, - CefRefPtr callback) OVERRIDE; + bool OnBeforeUnloadDialog(CefRefPtr browser, + const CefString& message_text, + bool is_reload, + CefRefPtr callback) OVERRIDE; void OnResetDialogState(CefRefPtr browser) OVERRIDE; private: - static void OnDialogResponse(GtkDialog *dialog, + static void OnDialogResponse(GtkDialog* dialog, gint response_id, ClientDialogHandlerGtk* handler); diff --git a/src/client_handler/dialog_handler_gtk.patch b/src/client_handler/dialog_handler_gtk.patch new file mode 100644 index 00000000..78492921 --- /dev/null +++ b/src/client_handler/dialog_handler_gtk.patch @@ -0,0 +1,127 @@ +diff --git dialog_handler_gtk.cc dialog_handler_gtk.cc +index 042be2ca..ce5a4d4e 100644 +--- dialog_handler_gtk.cc ++++ dialog_handler_gtk.cc +@@ -1,18 +1,20 @@ ++// COPIED from upstream "cef/tests/cefclient/browser/" directory ++// with minor modifications. See the .patch file in current directory. ++ + // Copyright (c) 2015 The Chromium Embedded Framework Authors. All rights + // reserved. Use of this source code is governed by a BSD-style license that + // can be found in the LICENSE file. + +-#include "tests/cefclient/browser/dialog_handler_gtk.h" +- + #include + #include + + #include "include/cef_browser.h" + #include "include/cef_parser.h" + #include "include/wrapper/cef_helpers.h" +-#include "tests/cefclient/browser/root_window.h" + +-namespace client { ++#include "include/base/cef_logging.h" ++#include "dialog_handler_gtk.h" ++#include "x11.h" + + namespace { + +@@ -129,18 +131,6 @@ void AddFilters(GtkFileChooser* chooser, + } + } + +-GtkWindow* GetWindow(CefRefPtr browser) { +- scoped_refptr root_window = +- RootWindow::GetForBrowser(browser->GetIdentifier()); +- if (root_window) { +- GtkWindow* window = GTK_WINDOW(root_window->GetWindowHandle()); +- if (!window) +- LOG(ERROR) << "No GtkWindow for browser"; +- return window; +- } +- return NULL; +-} +- + } // namespace + + ClientDialogHandlerGtk::ClientDialogHandlerGtk() : gtk_dialog_(NULL) {} +@@ -198,7 +188,7 @@ bool ClientDialogHandlerGtk::OnFileDialog( + } + } + +- GtkWindow* window = GetWindow(browser); ++ GtkWindow* window = CefBrowser_GetGtkWindow(browser); + if (!window) + return false; + +@@ -308,30 +298,30 @@ bool ClientDialogHandlerGtk::OnJSDialog(CefRefPtr browser, + case JSDIALOGTYPE_ALERT: + buttons = GTK_BUTTONS_NONE; + gtk_message_type = GTK_MESSAGE_WARNING; +- title = "JavaScript Alert"; ++ title = "Alert"; + break; + + case JSDIALOGTYPE_CONFIRM: + buttons = GTK_BUTTONS_CANCEL; + gtk_message_type = GTK_MESSAGE_QUESTION; +- title = "JavaScript Confirm"; ++ title = "Confirm"; + break; + + case JSDIALOGTYPE_PROMPT: + buttons = GTK_BUTTONS_CANCEL; + gtk_message_type = GTK_MESSAGE_QUESTION; +- title = "JavaScript Prompt"; ++ title = "Prompt"; + break; + } + + js_dialog_callback_ = callback; + + if (!origin_url.empty()) { +- title += " - "; +- title += CefFormatUrlForSecurityDisplay(origin_url).ToString(); ++ // title += " - "; ++ // title += CefFormatUrlForSecurityDisplay(origin_url).ToString(); + } + +- GtkWindow* window = GetWindow(browser); ++ GtkWindow* window = CefBrowser_GetGtkWindow(browser); + if (!window) + return false; + +@@ -413,5 +403,3 @@ void ClientDialogHandlerGtk::OnDialogResponse(GtkDialog* dialog, + + handler->OnResetDialogState(NULL); + } +- +-} // namespace client +diff --git dialog_handler_gtk.h dialog_handler_gtk.h +index 163d0a35..59f65eda 100644 +--- dialog_handler_gtk.h ++++ dialog_handler_gtk.h +@@ -1,3 +1,6 @@ ++// COPIED from upstream "cef/tests/cefclient/browser/" directory ++// with minor modifications. See the .patch file in current directory. ++ + // Copyright (c) 2015 The Chromium Embedded Framework Authors. All rights + // reserved. Use of this source code is governed by a BSD-style license that + // can be found in the LICENSE file. +@@ -11,8 +14,6 @@ + #include "include/cef_dialog_handler.h" + #include "include/cef_jsdialog_handler.h" + +-namespace client { +- + class ClientDialogHandlerGtk : public CefDialogHandler, + public CefJSDialogHandler { + public: +@@ -53,6 +54,4 @@ class ClientDialogHandlerGtk : public CefDialogHandler, + DISALLOW_COPY_AND_ASSIGN(ClientDialogHandlerGtk); + }; + +-} // namespace client +- + #endif // CEF_TESTS_CEFCLIENT_BROWSER_DIALOG_HANDLER_GTK_H_