X Tutup
Skip to content

Commit 357a7fb

Browse files
committed
Update dialog_handler_gtk files with changes from upstream (cztomczak#403).
Generate a patch file with changes.
1 parent da2c2ee commit 357a7fb

File tree

4 files changed

+163
-62
lines changed

4 files changed

+163
-62
lines changed

src/cef_v59..v66_changes.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ internal/cef_types.h
6060
- + Remove: UR_FLAG_ALLOW_CACHED_CREDENTIALS
6161

6262

63-
TODO
63+
MISC
6464
----
65-
1. Compare src/handler/dialog_handler_gtk.cpp (and .h) with upstream
66-
cefclient files
67-
2. In subprocess/print_handler_gtk.cpp use GetWindow implementation
68-
from x11.cpp
65+
+ Compare src/client_handler/dialog_handler_gtk.cpp (and .h) with upstream
66+
cefclient files
67+
- In subprocess/print_handler_gtk.cpp use GetWindow implementation
68+
from x11.cpp
6969

7070
NEW FEATURES
7171
------------

src/client_handler/dialog_handler_gtk.cpp

Lines changed: 24 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,18 @@
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

149138
bool 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);

src/client_handler/dialog_handler_gtk.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
// Default dialog handler implementation on Linux.
2-
// Copied from upstream cefclient with changes:
3-
// - Removed "client" namespace
1+
// COPIED from upstream "cef/tests/cefclient/browser/" directory
2+
// with minor modifications. See the .patch file in current directory.
43

54
// Copyright (c) 2015 The Chromium Embedded Framework Authors. All rights
65
// reserved. Use of this source code is governed by a BSD-style license that
@@ -37,15 +36,14 @@ class ClientDialogHandlerGtk : public CefDialogHandler,
3736
const CefString& default_prompt_text,
3837
CefRefPtr<CefJSDialogCallback> callback,
3938
bool& suppress_message) OVERRIDE;
40-
bool OnBeforeUnloadDialog(
41-
CefRefPtr<CefBrowser> browser,
42-
const CefString& message_text,
43-
bool is_reload,
44-
CefRefPtr<CefJSDialogCallback> callback) OVERRIDE;
39+
bool OnBeforeUnloadDialog(CefRefPtr<CefBrowser> browser,
40+
const CefString& message_text,
41+
bool is_reload,
42+
CefRefPtr<CefJSDialogCallback> callback) OVERRIDE;
4543
void OnResetDialogState(CefRefPtr<CefBrowser> browser) OVERRIDE;
4644

4745
private:
48-
static void OnDialogResponse(GtkDialog *dialog,
46+
static void OnDialogResponse(GtkDialog* dialog,
4947
gint response_id,
5048
ClientDialogHandlerGtk* handler);
5149

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
diff --git dialog_handler_gtk.cc dialog_handler_gtk.cc
2+
index 042be2ca..ce5a4d4e 100644
3+
--- dialog_handler_gtk.cc
4+
+++ dialog_handler_gtk.cc
5+
@@ -1,18 +1,20 @@
6+
+// COPIED from upstream "cef/tests/cefclient/browser/" directory
7+
+// with minor modifications. See the .patch file in current directory.
8+
+
9+
// Copyright (c) 2015 The Chromium Embedded Framework Authors. All rights
10+
// reserved. Use of this source code is governed by a BSD-style license that
11+
// can be found in the LICENSE file.
12+
13+
-#include "tests/cefclient/browser/dialog_handler_gtk.h"
14+
-
15+
#include <libgen.h>
16+
#include <sys/stat.h>
17+
18+
#include "include/cef_browser.h"
19+
#include "include/cef_parser.h"
20+
#include "include/wrapper/cef_helpers.h"
21+
-#include "tests/cefclient/browser/root_window.h"
22+
23+
-namespace client {
24+
+#include "include/base/cef_logging.h"
25+
+#include "dialog_handler_gtk.h"
26+
+#include "x11.h"
27+
28+
namespace {
29+
30+
@@ -129,18 +131,6 @@ void AddFilters(GtkFileChooser* chooser,
31+
}
32+
}
33+
34+
-GtkWindow* GetWindow(CefRefPtr<CefBrowser> browser) {
35+
- scoped_refptr<RootWindow> root_window =
36+
- RootWindow::GetForBrowser(browser->GetIdentifier());
37+
- if (root_window) {
38+
- GtkWindow* window = GTK_WINDOW(root_window->GetWindowHandle());
39+
- if (!window)
40+
- LOG(ERROR) << "No GtkWindow for browser";
41+
- return window;
42+
- }
43+
- return NULL;
44+
-}
45+
-
46+
} // namespace
47+
48+
ClientDialogHandlerGtk::ClientDialogHandlerGtk() : gtk_dialog_(NULL) {}
49+
@@ -198,7 +188,7 @@ bool ClientDialogHandlerGtk::OnFileDialog(
50+
}
51+
}
52+
53+
- GtkWindow* window = GetWindow(browser);
54+
+ GtkWindow* window = CefBrowser_GetGtkWindow(browser);
55+
if (!window)
56+
return false;
57+
58+
@@ -308,30 +298,30 @@ bool ClientDialogHandlerGtk::OnJSDialog(CefRefPtr<CefBrowser> browser,
59+
case JSDIALOGTYPE_ALERT:
60+
buttons = GTK_BUTTONS_NONE;
61+
gtk_message_type = GTK_MESSAGE_WARNING;
62+
- title = "JavaScript Alert";
63+
+ title = "Alert";
64+
break;
65+
66+
case JSDIALOGTYPE_CONFIRM:
67+
buttons = GTK_BUTTONS_CANCEL;
68+
gtk_message_type = GTK_MESSAGE_QUESTION;
69+
- title = "JavaScript Confirm";
70+
+ title = "Confirm";
71+
break;
72+
73+
case JSDIALOGTYPE_PROMPT:
74+
buttons = GTK_BUTTONS_CANCEL;
75+
gtk_message_type = GTK_MESSAGE_QUESTION;
76+
- title = "JavaScript Prompt";
77+
+ title = "Prompt";
78+
break;
79+
}
80+
81+
js_dialog_callback_ = callback;
82+
83+
if (!origin_url.empty()) {
84+
- title += " - ";
85+
- title += CefFormatUrlForSecurityDisplay(origin_url).ToString();
86+
+ // title += " - ";
87+
+ // title += CefFormatUrlForSecurityDisplay(origin_url).ToString();
88+
}
89+
90+
- GtkWindow* window = GetWindow(browser);
91+
+ GtkWindow* window = CefBrowser_GetGtkWindow(browser);
92+
if (!window)
93+
return false;
94+
95+
@@ -413,5 +403,3 @@ void ClientDialogHandlerGtk::OnDialogResponse(GtkDialog* dialog,
96+
97+
handler->OnResetDialogState(NULL);
98+
}
99+
-
100+
-} // namespace client
101+
diff --git dialog_handler_gtk.h dialog_handler_gtk.h
102+
index 163d0a35..59f65eda 100644
103+
--- dialog_handler_gtk.h
104+
+++ dialog_handler_gtk.h
105+
@@ -1,3 +1,6 @@
106+
+// COPIED from upstream "cef/tests/cefclient/browser/" directory
107+
+// with minor modifications. See the .patch file in current directory.
108+
+
109+
// Copyright (c) 2015 The Chromium Embedded Framework Authors. All rights
110+
// reserved. Use of this source code is governed by a BSD-style license that
111+
// can be found in the LICENSE file.
112+
@@ -11,8 +14,6 @@
113+
#include "include/cef_dialog_handler.h"
114+
#include "include/cef_jsdialog_handler.h"
115+
116+
-namespace client {
117+
-
118+
class ClientDialogHandlerGtk : public CefDialogHandler,
119+
public CefJSDialogHandler {
120+
public:
121+
@@ -53,6 +54,4 @@ class ClientDialogHandlerGtk : public CefDialogHandler,
122+
DISALLOW_COPY_AND_ASSIGN(ClientDialogHandlerGtk);
123+
};
124+
125+
-} // namespace client
126+
-
127+
#endif // CEF_TESTS_CEFCLIENT_BROWSER_DIALOG_HANDLER_GTK_H_

0 commit comments

Comments
 (0)
X Tutup