blob: ba627bae6f0e7c2455e7d3c6e4ba43eb979d8984 [file] [log] [blame]
// Copyright 2013 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.
#ifndef CONTENT_SHELL_BROWSER_SHELL_JAVASCRIPT_DIALOG_MANAGER_H_
#define CONTENT_SHELL_BROWSER_SHELL_JAVASCRIPT_DIALOG_MANAGER_H_
#include <memory>
#include "base/callback_forward.h"
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "build/build_config.h"
#include "content/public/browser/javascript_dialog_manager.h"
namespace content {
class ShellJavaScriptDialog;
class ShellJavaScriptDialogManager : public JavaScriptDialogManager {
public:
ShellJavaScriptDialogManager();
~ShellJavaScriptDialogManager() override;
// JavaScriptDialogManager:
void RunJavaScriptDialog(WebContents* web_contents,
const GURL& origin_url,
JavaScriptDialogType dialog_type,
const base::string16& message_text,
const base::string16& default_prompt_text,
const DialogClosedCallback& callback,
bool* did_suppress_message) override;
void RunBeforeUnloadDialog(WebContents* web_contents,
bool is_reload,
const DialogClosedCallback& callback) override;
void CancelDialogs(WebContents* web_contents,
bool reset_state) override;
// Called by the ShellJavaScriptDialog when it closes.
void DialogClosed(ShellJavaScriptDialog* dialog);
// Used for content_browsertests.
void set_dialog_request_callback(const base::Closure& callback) {
dialog_request_callback_ = callback;
}
void set_should_proceed_on_beforeunload(bool proceed) {
should_proceed_on_beforeunload_ = proceed;
}
private:
#if defined(OS_MACOSX) || defined(OS_WIN)
// The dialog being shown. No queueing.
std::unique_ptr<ShellJavaScriptDialog> dialog_;
#else
// TODO: implement ShellJavaScriptDialog for other platforms, drop this #if
#endif
base::Closure dialog_request_callback_;
// Whether to automatically proceed when asked to display a BeforeUnload
// dialog.
bool should_proceed_on_beforeunload_;
DialogClosedCallback before_unload_callback_;
DISALLOW_COPY_AND_ASSIGN(ShellJavaScriptDialogManager);
};
} // namespace content
#endif // CONTENT_SHELL_BROWSER_SHELL_JAVASCRIPT_DIALOG_MANAGER_H_