mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Add support for JavaScript alert, confirm, prompt and onbeforeunload dialogs (issue #507).
- Add CefJSDialogHandler and CefJSDialogCallback interfaces. - Add default dialog implementations for Windows and Mac OS-X. - Add "JavaScript Dialogs" example to cefclient. - Change TestHandler::AddResource to ignore the query component when matching URLs. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@594 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
61
libcef/browser/javascript_dialog_creator.h
Normal file
61
libcef/browser/javascript_dialog_creator.h
Normal file
@ -0,0 +1,61 @@
|
||||
// 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.
|
||||
|
||||
#ifndef CEF_LIBCEF_BROWSER_JAVASCRIPT_DIALOG_CREATOR_H_
|
||||
#define CEF_LIBCEF_BROWSER_JAVASCRIPT_DIALOG_CREATOR_H_
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "content/public/browser/javascript_dialogs.h"
|
||||
|
||||
class CefBrowserHostImpl;
|
||||
class CefJavaScriptDialog;
|
||||
|
||||
class CefJavaScriptDialogCreator : public content::JavaScriptDialogCreator {
|
||||
public:
|
||||
explicit CefJavaScriptDialogCreator(CefBrowserHostImpl* browser);
|
||||
virtual ~CefJavaScriptDialogCreator();
|
||||
|
||||
// JavaScriptDialogCreator methods.
|
||||
virtual void RunJavaScriptDialog(
|
||||
content::WebContents* web_contents,
|
||||
const GURL& origin_url,
|
||||
const std::string& accept_lang,
|
||||
ui::JavascriptMessageType javascript_message_type,
|
||||
const string16& message_text,
|
||||
const string16& default_prompt_text,
|
||||
const DialogClosedCallback& callback,
|
||||
bool* did_suppress_message) OVERRIDE;
|
||||
|
||||
virtual void RunBeforeUnloadDialog(
|
||||
content::WebContents* web_contents,
|
||||
const string16& message_text,
|
||||
bool is_reload,
|
||||
const DialogClosedCallback& callback) OVERRIDE;
|
||||
|
||||
virtual void ResetJavaScriptState(
|
||||
content::WebContents* web_contents) OVERRIDE;
|
||||
|
||||
// Called by the CefJavaScriptDialog when it closes.
|
||||
void DialogClosed(CefJavaScriptDialog* dialog);
|
||||
|
||||
CefBrowserHostImpl* browser() const { return browser_; }
|
||||
|
||||
private:
|
||||
// This pointer is guaranteed to outlive the CefJavaScriptDialogCreator.
|
||||
CefBrowserHostImpl* browser_;
|
||||
|
||||
#if defined(OS_MACOSX) || defined(OS_WIN)
|
||||
// The dialog being shown. No queueing.
|
||||
scoped_ptr<CefJavaScriptDialog> dialog_;
|
||||
#endif
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CefJavaScriptDialogCreator);
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_JAVASCRIPT_DIALOG_CREATOR_H_
|
Reference in New Issue
Block a user