OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 CHROME_BROWSER_UI_JAVASCRIPT_DIALOGS_JAVASCRIPT_DIALOG_TAB_HELPER_H_ | 5 #ifndef CHROME_BROWSER_UI_JAVASCRIPT_DIALOGS_JAVASCRIPT_DIALOG_TAB_HELPER_H_ |
6 #define CHROME_BROWSER_UI_JAVASCRIPT_DIALOGS_JAVASCRIPT_DIALOG_TAB_HELPER_H_ | 6 #define CHROME_BROWSER_UI_JAVASCRIPT_DIALOGS_JAVASCRIPT_DIALOG_TAB_HELPER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
| 10 #include "base/callback_forward.h" |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
12 #include "chrome/browser/ui/browser_list_observer.h" | 13 #include "chrome/browser/ui/browser_list_observer.h" |
13 #include "chrome/browser/ui/javascript_dialogs/javascript_dialog.h" | 14 #include "chrome/browser/ui/javascript_dialogs/javascript_dialog.h" |
14 #include "content/public/browser/javascript_dialog_manager.h" | 15 #include "content/public/browser/javascript_dialog_manager.h" |
15 #include "content/public/browser/web_contents_observer.h" | 16 #include "content/public/browser/web_contents_observer.h" |
16 #include "content/public/browser/web_contents_user_data.h" | 17 #include "content/public/browser/web_contents_user_data.h" |
17 | 18 |
18 class JavaScriptDialogViews; | 19 class JavaScriptDialogViews; |
19 | 20 |
(...skipping 10 matching lines...) Expand all Loading... |
30 // one of that design is implemented. | 31 // one of that design is implemented. |
31 class JavaScriptDialogTabHelper | 32 class JavaScriptDialogTabHelper |
32 : public content::JavaScriptDialogManager, | 33 : public content::JavaScriptDialogManager, |
33 public content::WebContentsObserver, | 34 public content::WebContentsObserver, |
34 public chrome::BrowserListObserver, | 35 public chrome::BrowserListObserver, |
35 public content::WebContentsUserData<JavaScriptDialogTabHelper> { | 36 public content::WebContentsUserData<JavaScriptDialogTabHelper> { |
36 public: | 37 public: |
37 explicit JavaScriptDialogTabHelper(content::WebContents* web_contents); | 38 explicit JavaScriptDialogTabHelper(content::WebContents* web_contents); |
38 ~JavaScriptDialogTabHelper() override; | 39 ~JavaScriptDialogTabHelper() override; |
39 | 40 |
| 41 void SetDialogShownCallbackForTesting(base::Closure callback); |
| 42 |
40 // JavaScriptDialogManager: | 43 // JavaScriptDialogManager: |
41 void RunJavaScriptDialog(content::WebContents* web_contents, | 44 void RunJavaScriptDialog(content::WebContents* web_contents, |
42 const GURL& origin_url, | 45 const GURL& origin_url, |
43 content::JavaScriptMessageType message_type, | 46 content::JavaScriptMessageType message_type, |
44 const base::string16& message_text, | 47 const base::string16& message_text, |
45 const base::string16& default_prompt_text, | 48 const base::string16& default_prompt_text, |
46 const DialogClosedCallback& callback, | 49 const DialogClosedCallback& callback, |
47 bool* did_suppress_message) override; | 50 bool* did_suppress_message) override; |
48 void RunBeforeUnloadDialog(content::WebContents* web_contents, | 51 void RunBeforeUnloadDialog(content::WebContents* web_contents, |
49 bool is_reload, | 52 bool is_reload, |
(...skipping 19 matching lines...) Expand all Loading... |
69 const base::string16& user_input); | 72 const base::string16& user_input); |
70 | 73 |
71 // The dialog being displayed on the observed WebContents. | 74 // The dialog being displayed on the observed WebContents. |
72 base::WeakPtr<JavaScriptDialog> dialog_; | 75 base::WeakPtr<JavaScriptDialog> dialog_; |
73 | 76 |
74 // The callback provided for when the dialog is closed. Usually the dialog | 77 // The callback provided for when the dialog is closed. Usually the dialog |
75 // itself calls it, but in the cases where the dialog is closed not by the | 78 // itself calls it, but in the cases where the dialog is closed not by the |
76 // user's input but by a call to |CloseDialog|, this class will call it. | 79 // user's input but by a call to |CloseDialog|, this class will call it. |
77 content::JavaScriptDialogManager::DialogClosedCallback dialog_callback_; | 80 content::JavaScriptDialogManager::DialogClosedCallback dialog_callback_; |
78 | 81 |
| 82 base::Closure dialog_shown_; |
| 83 |
79 DISALLOW_COPY_AND_ASSIGN(JavaScriptDialogTabHelper); | 84 DISALLOW_COPY_AND_ASSIGN(JavaScriptDialogTabHelper); |
80 }; | 85 }; |
81 | 86 |
82 #endif // CHROME_BROWSER_UI_JAVASCRIPT_DIALOGS_JAVASCRIPT_DIALOG_TAB_HELPER_H_ | 87 #endif // CHROME_BROWSER_UI_JAVASCRIPT_DIALOGS_JAVASCRIPT_DIALOG_TAB_HELPER_H_ |
OLD | NEW |