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