2015-01-23 21:03:47 +01:00
|
|
|
// 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.
|
|
|
|
|
2015-01-31 01:55:56 +01:00
|
|
|
#ifndef CEF_TESTS_CEFCLIENT_BROWSER_DIALOG_HANDLER_GTK_H_
|
|
|
|
#define CEF_TESTS_CEFCLIENT_BROWSER_DIALOG_HANDLER_GTK_H_
|
2015-01-23 21:03:47 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2018-09-20 15:00:14 +02:00
|
|
|
#include "include/base/cef_callback_forward.h"
|
2015-01-23 21:03:47 +01:00
|
|
|
#include "include/cef_dialog_handler.h"
|
|
|
|
#include "include/cef_jsdialog_handler.h"
|
|
|
|
|
|
|
|
namespace client {
|
|
|
|
|
|
|
|
class ClientDialogHandlerGtk : public CefDialogHandler,
|
|
|
|
public CefJSDialogHandler {
|
|
|
|
public:
|
|
|
|
ClientDialogHandlerGtk();
|
|
|
|
|
|
|
|
// CefDialogHandler methods.
|
|
|
|
bool OnFileDialog(CefRefPtr<CefBrowser> browser,
|
|
|
|
FileDialogMode mode,
|
|
|
|
const CefString& title,
|
|
|
|
const CefString& default_file_path,
|
|
|
|
const std::vector<CefString>& accept_filters,
|
2024-05-29 22:38:00 +02:00
|
|
|
const std::vector<CefString>& accept_extensions,
|
|
|
|
const std::vector<CefString>& accept_descriptions,
|
2021-06-17 21:43:06 +02:00
|
|
|
CefRefPtr<CefFileDialogCallback> callback) override;
|
2015-01-23 21:03:47 +01:00
|
|
|
|
|
|
|
// CefJSDialogHandler methods.
|
|
|
|
bool OnJSDialog(CefRefPtr<CefBrowser> browser,
|
|
|
|
const CefString& origin_url,
|
|
|
|
JSDialogType dialog_type,
|
|
|
|
const CefString& message_text,
|
|
|
|
const CefString& default_prompt_text,
|
|
|
|
CefRefPtr<CefJSDialogCallback> callback,
|
2021-06-17 21:43:06 +02:00
|
|
|
bool& suppress_message) override;
|
2017-05-17 11:29:28 +02:00
|
|
|
bool OnBeforeUnloadDialog(CefRefPtr<CefBrowser> browser,
|
|
|
|
const CefString& message_text,
|
|
|
|
bool is_reload,
|
2021-06-17 21:43:06 +02:00
|
|
|
CefRefPtr<CefJSDialogCallback> callback) override;
|
|
|
|
void OnResetDialogState(CefRefPtr<CefBrowser> browser) override;
|
2015-01-23 21:03:47 +01:00
|
|
|
|
|
|
|
private:
|
2018-09-20 15:00:14 +02:00
|
|
|
struct OnFileDialogParams {
|
|
|
|
CefRefPtr<CefBrowser> browser;
|
|
|
|
FileDialogMode mode;
|
|
|
|
CefString title;
|
|
|
|
CefString default_file_path;
|
|
|
|
std::vector<CefString> accept_filters;
|
2024-05-29 22:38:00 +02:00
|
|
|
std::vector<CefString> accept_extensions;
|
|
|
|
std::vector<CefString> accept_descriptions;
|
2018-09-20 15:00:14 +02:00
|
|
|
CefRefPtr<CefFileDialogCallback> callback;
|
|
|
|
};
|
2022-04-15 21:55:23 +02:00
|
|
|
void OnFileDialogContinue(const OnFileDialogParams& params,
|
|
|
|
GtkWindow* window);
|
2018-09-20 15:00:14 +02:00
|
|
|
|
|
|
|
struct OnJSDialogParams {
|
|
|
|
CefRefPtr<CefBrowser> browser;
|
|
|
|
CefString origin_url;
|
|
|
|
JSDialogType dialog_type;
|
|
|
|
CefString message_text;
|
|
|
|
CefString default_prompt_text;
|
|
|
|
CefRefPtr<CefJSDialogCallback> callback;
|
|
|
|
};
|
2022-04-15 21:55:23 +02:00
|
|
|
void OnJSDialogContinue(const OnJSDialogParams& params, GtkWindow* window);
|
2018-09-20 15:00:14 +02:00
|
|
|
|
|
|
|
void GetWindowAndContinue(CefRefPtr<CefBrowser> browser,
|
2021-06-19 21:54:45 +02:00
|
|
|
base::OnceCallback<void(GtkWindow*)> callback);
|
2018-09-20 15:00:14 +02:00
|
|
|
|
2017-05-17 11:29:28 +02:00
|
|
|
static void OnDialogResponse(GtkDialog* dialog,
|
2015-01-23 21:03:47 +01:00
|
|
|
gint response_id,
|
|
|
|
ClientDialogHandlerGtk* handler);
|
|
|
|
|
|
|
|
GtkWidget* gtk_dialog_;
|
|
|
|
CefRefPtr<CefJSDialogCallback> js_dialog_callback_;
|
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(ClientDialogHandlerGtk);
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(ClientDialogHandlerGtk);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace client
|
|
|
|
|
2015-01-31 01:55:56 +01:00
|
|
|
#endif // CEF_TESTS_CEFCLIENT_BROWSER_DIALOG_HANDLER_GTK_H_
|