2012-04-16 23:15:27 +02:00
|
|
|
// Copyright (c) 2012 The Chromium Embedded Framework Authors.
|
|
|
|
// Portions copyright (c) 2012 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2013-02-23 01:43:28 +01:00
|
|
|
#ifndef CEF_LIBCEF_BROWSER_JAVASCRIPT_DIALOG_MANAGER_H_
|
|
|
|
#define CEF_LIBCEF_BROWSER_JAVASCRIPT_DIALOG_MANAGER_H_
|
2012-04-16 23:15:27 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
2015-11-17 19:20:13 +01:00
|
|
|
#include "libcef/browser/javascript_dialog_runner.h"
|
|
|
|
|
2012-04-16 23:15:27 +02:00
|
|
|
#include "base/compiler_specific.h"
|
2015-11-17 19:20:13 +01:00
|
|
|
#include "base/memory/weak_ptr.h"
|
2013-02-23 01:43:28 +01:00
|
|
|
#include "content/public/browser/javascript_dialog_manager.h"
|
2012-04-16 23:15:27 +02:00
|
|
|
|
2020-09-22 21:54:02 +02:00
|
|
|
class AlloyBrowserHostImpl;
|
2012-04-16 23:15:27 +02:00
|
|
|
|
2013-02-23 01:43:28 +01:00
|
|
|
class CefJavaScriptDialogManager : public content::JavaScriptDialogManager {
|
2012-04-16 23:15:27 +02:00
|
|
|
public:
|
2015-11-17 19:20:13 +01:00
|
|
|
// |runner| may be NULL if the platform doesn't implement dialogs.
|
2020-09-22 21:54:02 +02:00
|
|
|
CefJavaScriptDialogManager(AlloyBrowserHostImpl* browser,
|
2017-05-17 11:29:28 +02:00
|
|
|
std::unique_ptr<CefJavaScriptDialogRunner> runner);
|
2014-11-12 20:25:15 +01:00
|
|
|
~CefJavaScriptDialogManager() override;
|
2012-04-16 23:15:27 +02:00
|
|
|
|
2015-11-17 19:20:13 +01:00
|
|
|
// Delete the runner to free any platform constructs.
|
|
|
|
void Destroy();
|
|
|
|
|
2013-02-23 01:43:28 +01:00
|
|
|
// JavaScriptDialogManager methods.
|
2017-05-17 11:29:28 +02:00
|
|
|
void RunJavaScriptDialog(content::WebContents* web_contents,
|
2018-03-20 21:15:08 +01:00
|
|
|
content::RenderFrameHost* render_frame_host,
|
2017-05-17 11:29:28 +02:00
|
|
|
content::JavaScriptDialogType message_type,
|
2021-04-21 00:52:34 +02:00
|
|
|
const std::u16string& message_text,
|
|
|
|
const std::u16string& default_prompt_text,
|
2017-10-20 19:45:20 +02:00
|
|
|
DialogClosedCallback callback,
|
2017-05-17 11:29:28 +02:00
|
|
|
bool* did_suppress_message) override;
|
|
|
|
void RunBeforeUnloadDialog(content::WebContents* web_contents,
|
2017-12-07 22:44:24 +01:00
|
|
|
content::RenderFrameHost* render_frame_host,
|
2017-05-17 11:29:28 +02:00
|
|
|
bool is_reload,
|
2017-10-20 19:45:20 +02:00
|
|
|
DialogClosedCallback callback) override;
|
2016-11-23 21:54:29 +01:00
|
|
|
void CancelDialogs(content::WebContents* web_contents,
|
|
|
|
bool reset_state) override;
|
2012-04-16 23:15:27 +02:00
|
|
|
|
|
|
|
private:
|
2015-11-17 19:20:13 +01:00
|
|
|
// Method executed by the callback passed to CefJavaScriptDialogRunner::Run.
|
2017-10-20 19:45:20 +02:00
|
|
|
void DialogClosed(DialogClosedCallback callback,
|
2015-11-17 19:20:13 +01:00
|
|
|
bool success,
|
2021-04-21 00:52:34 +02:00
|
|
|
const std::u16string& user_input);
|
2015-11-17 19:20:13 +01:00
|
|
|
|
2020-09-22 21:54:02 +02:00
|
|
|
// AlloyBrowserHostImpl pointer is guaranteed to outlive this object.
|
|
|
|
AlloyBrowserHostImpl* browser_;
|
2012-04-16 23:15:27 +02:00
|
|
|
|
2016-04-27 22:38:52 +02:00
|
|
|
std::unique_ptr<CefJavaScriptDialogRunner> runner_;
|
2015-11-17 19:20:13 +01:00
|
|
|
|
|
|
|
// True if a dialog is currently running.
|
|
|
|
bool dialog_running_;
|
|
|
|
|
|
|
|
// Must be the last member.
|
|
|
|
base::WeakPtrFactory<CefJavaScriptDialogManager> weak_ptr_factory_;
|
2012-04-16 23:15:27 +02:00
|
|
|
|
2013-02-23 01:43:28 +01:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(CefJavaScriptDialogManager);
|
2012-04-16 23:15:27 +02:00
|
|
|
};
|
|
|
|
|
2013-02-23 01:43:28 +01:00
|
|
|
#endif // CEF_LIBCEF_BROWSER_JAVASCRIPT_DIALOG_MANAGER_H_
|