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.
|
|
|
|
|
|
|
|
#ifndef CEF_LIBCEF_BROWSER_JAVASCRIPT_DIALOG_H_
|
|
|
|
#define CEF_LIBCEF_BROWSER_JAVASCRIPT_DIALOG_H_
|
|
|
|
#pragma once
|
|
|
|
|
2013-02-23 01:43:28 +01:00
|
|
|
#include "content/public/browser/javascript_dialog_manager.h"
|
2012-04-16 23:15:27 +02:00
|
|
|
|
|
|
|
#if defined(OS_MACOSX)
|
|
|
|
#if __OBJC__
|
|
|
|
@class CefJavaScriptDialogHelper;
|
|
|
|
#else
|
|
|
|
class CefJavaScriptDialogHelper;
|
|
|
|
#endif // __OBJC__
|
|
|
|
#endif // defined(OS_MACOSX)
|
|
|
|
|
2013-02-23 01:43:28 +01:00
|
|
|
class CefJavaScriptDialogManager;
|
2012-04-16 23:15:27 +02:00
|
|
|
|
|
|
|
class CefJavaScriptDialog {
|
|
|
|
public:
|
|
|
|
CefJavaScriptDialog(
|
2013-02-23 01:43:28 +01:00
|
|
|
CefJavaScriptDialogManager* creator,
|
2012-05-31 17:19:33 +02:00
|
|
|
content::JavaScriptMessageType message_type,
|
2013-12-17 23:04:35 +01:00
|
|
|
const base::string16& display_url,
|
|
|
|
const base::string16& message_text,
|
|
|
|
const base::string16& default_prompt_text,
|
2013-02-23 01:43:28 +01:00
|
|
|
const content::JavaScriptDialogManager::DialogClosedCallback& callback);
|
2012-04-16 23:15:27 +02:00
|
|
|
~CefJavaScriptDialog();
|
|
|
|
|
|
|
|
// Called to cancel a dialog mid-flight.
|
|
|
|
void Cancel();
|
|
|
|
|
|
|
|
// Activate the dialog.
|
|
|
|
void Activate();
|
|
|
|
|
|
|
|
private:
|
2013-02-23 01:43:28 +01:00
|
|
|
CefJavaScriptDialogManager* creator_;
|
|
|
|
content::JavaScriptDialogManager::DialogClosedCallback callback_;
|
2012-04-16 23:15:27 +02:00
|
|
|
|
|
|
|
#if defined(OS_MACOSX)
|
|
|
|
CefJavaScriptDialogHelper* helper_; // owned
|
|
|
|
#elif defined(OS_WIN)
|
2012-05-31 17:19:33 +02:00
|
|
|
content::JavaScriptMessageType message_type_;
|
2012-04-16 23:15:27 +02:00
|
|
|
HWND dialog_win_;
|
|
|
|
HWND parent_win_;
|
2013-12-17 23:04:35 +01:00
|
|
|
base::string16 message_text_;
|
|
|
|
base::string16 default_prompt_text_;
|
2012-04-16 23:15:27 +02:00
|
|
|
static INT_PTR CALLBACK DialogProc(HWND dialog, UINT message, WPARAM wparam,
|
|
|
|
LPARAM lparam);
|
|
|
|
|
|
|
|
// Since the message loop we expect to run in isn't going to be nicely
|
|
|
|
// calling IsDialogMessage(), we need to hook the wnd proc and call it
|
|
|
|
// ourselves. See http://support.microsoft.com/kb/q187988/
|
|
|
|
static bool InstallMessageHook();
|
|
|
|
static bool UninstallMessageHook();
|
|
|
|
static LRESULT CALLBACK GetMsgProc(int code, WPARAM wparam, LPARAM lparam);
|
|
|
|
static HHOOK msg_hook_;
|
2012-05-29 20:06:22 +02:00
|
|
|
static int msg_hook_user_count_;
|
2012-04-16 23:15:27 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(CefJavaScriptDialog);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_BROWSER_JAVASCRIPT_DIALOG_H_
|