1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_JAVASCRIPT_DIALOG_DELEGATE_H_
6 #define CONTENT_BROWSER_JAVASCRIPT_DIALOG_DELEGATE_H_
9 #include "base/string16.h"
10 #include "ui/gfx/native_widget_types.h"
21 class DialogDelegate
{
23 // Returns the root native window with which to associate the dialog.
24 virtual gfx::NativeWindow
GetDialogRootWindow() = 0;
26 // Called right before the dialog is shown.
27 virtual void OnDialogShown() {}
30 virtual ~DialogDelegate() {}
33 // A class that invokes a JavaScript dialog must implement this interface to
34 // allow the dialog implementation to get needed information and return results.
35 class JavaScriptDialogDelegate
: public DialogDelegate
{
37 // This callback is invoked when the dialog is closed.
38 virtual void OnDialogClosed(IPC::Message
* reply_msg
,
40 const string16
& user_input
) = 0;
43 virtual ~JavaScriptDialogDelegate() {}
46 // An interface consisting of methods that can be called to produce JavaScript
48 class JavaScriptDialogCreator
{
52 DIALOG_TITLE_PLAIN_STRING
,
53 DIALOG_TITLE_FORMATTED_URL
56 // Displays a JavaScript dialog. |did_suppress_message| will not be nil; if
57 // |true| is returned in it, the caller will handle faking the reply.
58 virtual void RunJavaScriptDialog(JavaScriptDialogDelegate
* delegate
,
60 const string16
& title
,
62 const string16
& message_text
,
63 const string16
& default_prompt_text
,
64 IPC::Message
* reply_message
,
65 bool* did_suppress_message
) = 0;
67 // Displays a dialog asking the user if they want to leave a page.
68 virtual void RunBeforeUnloadDialog(JavaScriptDialogDelegate
* delegate
,
69 const string16
& message_text
,
70 IPC::Message
* reply_message
) = 0;
72 // Cancels all pending dialogs and resets any saved JavaScript dialog state
74 virtual void ResetJavaScriptState(JavaScriptDialogDelegate
* delegate
) = 0;
77 virtual ~JavaScriptDialogCreator() {}
80 } // namespace content
82 #endif // CONTENT_BROWSER_JAVASCRIPT_DIALOG_DELEGATE_H_