[content shell] implement testRunner.overridePreference
[chromium-blink-merge.git] / content / shell / shell_javascript_dialog_creator.h
blob55fd548fc1607c5ccef0fa8e62079c57f1577708
1 // Copyright (c) 2012 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_SHELL_SHELL_JAVASCRIPT_DIALOG_CREATOR_H_
6 #define CONTENT_SHELL_SHELL_JAVASCRIPT_DIALOG_CREATOR_H_
8 #include "base/compiler_specific.h"
9 #include "base/callback_forward.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "content/public/browser/javascript_dialogs.h"
13 namespace content {
15 class ShellJavaScriptDialog;
17 class ShellJavaScriptDialogCreator : public JavaScriptDialogCreator {
18 public:
19 ShellJavaScriptDialogCreator();
20 virtual ~ShellJavaScriptDialogCreator();
22 // JavaScriptDialogCreator:
23 virtual void RunJavaScriptDialog(
24 WebContents* web_contents,
25 const GURL& origin_url,
26 const std::string& accept_lang,
27 JavaScriptMessageType javascript_message_type,
28 const string16& message_text,
29 const string16& default_prompt_text,
30 const DialogClosedCallback& callback,
31 bool* did_suppress_message) OVERRIDE;
33 virtual void RunBeforeUnloadDialog(
34 WebContents* web_contents,
35 const string16& message_text,
36 bool is_reload,
37 const DialogClosedCallback& callback) OVERRIDE;
39 virtual void ResetJavaScriptState(WebContents* web_contents) OVERRIDE;
41 // Called by the ShellJavaScriptDialog when it closes.
42 void DialogClosed(ShellJavaScriptDialog* dialog);
44 // Used for content_browsertests.
45 void set_dialog_request_callback(const base::Closure& callback) {
46 dialog_request_callback_ = callback;
49 private:
50 #if defined(OS_MACOSX) || defined(OS_WIN) || defined(TOOLKIT_GTK)
51 // The dialog being shown. No queueing.
52 scoped_ptr<ShellJavaScriptDialog> dialog_;
53 #else
54 // TODO: implement ShellJavaScriptDialog for other platforms, drop this #if
55 #endif
57 base::Closure dialog_request_callback_;
59 DISALLOW_COPY_AND_ASSIGN(ShellJavaScriptDialogCreator);
62 } // namespace content
64 #endif // CONTENT_SHELL_SHELL_JAVASCRIPT_DIALOG_CREATOR_H_