OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_PUBLIC_BROWSER_JAVASCRIPT_DIALOGS_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_JAVASCRIPT_DIALOGS_H_ |
6 #define CONTENT_PUBLIC_BROWSER_JAVASCRIPT_DIALOGS_H_ | 6 #define CONTENT_PUBLIC_BROWSER_JAVASCRIPT_DIALOGS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/string16.h" | 12 #include "base/string16.h" |
13 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
| 14 #include "content/public/common/javascript_message_type.h" |
14 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
15 #include "ui/base/javascript_message_type.h" | |
16 #include "ui/gfx/native_widget_types.h" | 16 #include "ui/gfx/native_widget_types.h" |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 | 19 |
20 class WebContents; | 20 class WebContents; |
21 | 21 |
22 // An interface consisting of methods that can be called to produce JavaScript | 22 // An interface consisting of methods that can be called to produce JavaScript |
23 // dialogs. | 23 // dialogs. |
24 class JavaScriptDialogCreator { | 24 class JavaScriptDialogCreator { |
25 public: | 25 public: |
26 typedef base::Callback<void(bool /* success */, | 26 typedef base::Callback<void(bool /* success */, |
27 const string16& /* user_input */)> | 27 const string16& /* user_input */)> |
28 DialogClosedCallback; | 28 DialogClosedCallback; |
29 | 29 |
30 // Displays a JavaScript dialog. |did_suppress_message| will not be nil; if | 30 // Displays a JavaScript dialog. |did_suppress_message| will not be nil; if |
31 // |true| is returned in it, the caller will handle faking the reply. | 31 // |true| is returned in it, the caller will handle faking the reply. |
32 virtual void RunJavaScriptDialog( | 32 virtual void RunJavaScriptDialog( |
33 WebContents* web_contents, | 33 WebContents* web_contents, |
34 const GURL& origin_url, | 34 const GURL& origin_url, |
35 const std::string& accept_lang, | 35 const std::string& accept_lang, |
36 ui::JavascriptMessageType javascript_message_type, | 36 JavaScriptMessageType javascript_message_type, |
37 const string16& message_text, | 37 const string16& message_text, |
38 const string16& default_prompt_text, | 38 const string16& default_prompt_text, |
39 const DialogClosedCallback& callback, | 39 const DialogClosedCallback& callback, |
40 bool* did_suppress_message) = 0; | 40 bool* did_suppress_message) = 0; |
41 | 41 |
42 // Displays a dialog asking the user if they want to leave a page. | 42 // Displays a dialog asking the user if they want to leave a page. |
43 virtual void RunBeforeUnloadDialog(WebContents* web_contents, | 43 virtual void RunBeforeUnloadDialog(WebContents* web_contents, |
44 const string16& message_text, | 44 const string16& message_text, |
45 bool is_reload, | 45 bool is_reload, |
46 const DialogClosedCallback& callback) = 0; | 46 const DialogClosedCallback& callback) = 0; |
47 | 47 |
48 // Cancels all pending dialogs and resets any saved JavaScript dialog state | 48 // Cancels all pending dialogs and resets any saved JavaScript dialog state |
49 // for the given WebContents. | 49 // for the given WebContents. |
50 virtual void ResetJavaScriptState(WebContents* web_contents) = 0; | 50 virtual void ResetJavaScriptState(WebContents* web_contents) = 0; |
51 | 51 |
52 virtual ~JavaScriptDialogCreator() {} | 52 virtual ~JavaScriptDialogCreator() {} |
53 }; | 53 }; |
54 | 54 |
55 } // namespace content | 55 } // namespace content |
56 | 56 |
57 #endif // CONTENT_PUBLIC_BROWSER_JAVASCRIPT_DIALOGS_H_ | 57 #endif // CONTENT_PUBLIC_BROWSER_JAVASCRIPT_DIALOGS_H_ |
OLD | NEW |