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
|
|
|
|
|
|
|
class CefBrowserHostImpl;
|
|
|
|
|
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.
|
|
|
|
CefJavaScriptDialogManager(
|
|
|
|
CefBrowserHostImpl* browser,
|
2016-04-27 22:38:52 +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.
|
2014-11-12 20:25:15 +01:00
|
|
|
void RunJavaScriptDialog(
|
2012-04-16 23:15:27 +02:00
|
|
|
content::WebContents* web_contents,
|
|
|
|
const GURL& origin_url,
|
2017-03-03 23:37:23 +01:00
|
|
|
content::JavaScriptDialogType message_type,
|
2013-12-17 23:04:35 +01:00
|
|
|
const base::string16& message_text,
|
|
|
|
const base::string16& default_prompt_text,
|
2012-04-16 23:15:27 +02:00
|
|
|
const DialogClosedCallback& callback,
|
2014-11-12 20:25:15 +01:00
|
|
|
bool* did_suppress_message) override;
|
|
|
|
void RunBeforeUnloadDialog(
|
2012-04-16 23:15:27 +02:00
|
|
|
content::WebContents* web_contents,
|
|
|
|
bool is_reload,
|
2014-11-12 20:25:15 +01:00
|
|
|
const 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.
|
|
|
|
void DialogClosed(const DialogClosedCallback& callback,
|
|
|
|
bool success,
|
|
|
|
const base::string16& user_input);
|
|
|
|
|
|
|
|
// CefBrowserHostImpl pointer is guaranteed to outlive this object.
|
2012-04-16 23:15:27 +02:00
|
|
|
CefBrowserHostImpl* browser_;
|
|
|
|
|
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_
|