Chromium Code Reviews| 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> | |
| 9 | |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/weak_ptr.h" | |
| 12 #include "chrome/browser/ui/browser_list_observer.h" | |
| 9 #include "content/public/browser/javascript_dialog_manager.h" | 13 #include "content/public/browser/javascript_dialog_manager.h" |
| 10 #include "content/public/browser/web_contents_observer.h" | 14 #include "content/public/browser/web_contents_observer.h" |
| 11 #include "content/public/browser/web_contents_user_data.h" | 15 #include "content/public/browser/web_contents_user_data.h" |
| 12 | 16 |
| 17 class JavaScriptDialogViews; | |
| 18 | |
| 13 class JavaScriptDialogTabHelper | 19 class JavaScriptDialogTabHelper |
|
Peter Kasting
2016/10/17 20:16:05
Nit: While here: Would be nice to have an overview
Avi (use Gerrit)
2016/10/18 02:46:41
Done.
| |
| 14 : public content::WebContentsObserver, | 20 : public content::WebContentsObserver, |
| 21 public chrome::BrowserListObserver, | |
| 15 public content::JavaScriptDialogManager, | 22 public content::JavaScriptDialogManager, |
| 16 public content::WebContentsUserData<JavaScriptDialogTabHelper> { | 23 public content::WebContentsUserData<JavaScriptDialogTabHelper> { |
| 17 public: | 24 public: |
| 18 explicit JavaScriptDialogTabHelper(content::WebContents* web_contents); | 25 explicit JavaScriptDialogTabHelper(content::WebContents* web_contents); |
| 19 ~JavaScriptDialogTabHelper() override; | 26 ~JavaScriptDialogTabHelper() override; |
| 20 | 27 |
| 21 // JavaScriptDialogManager: | 28 // JavaScriptDialogManager: |
| 22 void RunJavaScriptDialog(content::WebContents* web_contents, | 29 void RunJavaScriptDialog(content::WebContents* web_contents, |
| 23 const GURL& origin_url, | 30 const GURL& origin_url, |
| 24 content::JavaScriptMessageType message_type, | 31 content::JavaScriptMessageType message_type, |
| 25 const base::string16& message_text, | 32 const base::string16& message_text, |
| 26 const base::string16& default_prompt_text, | 33 const base::string16& default_prompt_text, |
| 27 const DialogClosedCallback& callback, | 34 const DialogClosedCallback& callback, |
| 28 bool* did_suppress_message) override; | 35 bool* did_suppress_message) override; |
| 29 void RunBeforeUnloadDialog(content::WebContents* web_contents, | 36 void RunBeforeUnloadDialog(content::WebContents* web_contents, |
| 30 bool is_reload, | 37 bool is_reload, |
| 31 const DialogClosedCallback& callback) override; | 38 const DialogClosedCallback& callback) override; |
| 32 bool HandleJavaScriptDialog(content::WebContents* web_contents, | 39 bool HandleJavaScriptDialog(content::WebContents* web_contents, |
| 33 bool accept, | 40 bool accept, |
| 34 const base::string16* prompt_override) override; | 41 const base::string16* prompt_override) override; |
| 35 void CancelDialogs(content::WebContents* web_contents, | 42 void CancelDialogs(content::WebContents* web_contents, |
| 36 bool suppress_callbacks, | 43 bool suppress_callbacks, |
| 37 bool reset_state) override; | 44 bool reset_state) override; |
| 38 void WebContentsDestroyed() override; | 45 |
| 46 // WebContentsObserver: | |
|
Peter Kasting
2016/10/17 20:16:04
Nit: Keep blocks of overrides and superclass list
Avi (use Gerrit)
2016/10/18 02:46:41
Done.
| |
| 47 void WasHidden() override; | |
| 48 | |
| 49 // BrowserListObserver: | |
| 50 void OnBrowserSetLastActive(Browser* browser) override; | |
| 39 | 51 |
| 40 private: | 52 private: |
| 41 friend class content::WebContentsUserData<JavaScriptDialogTabHelper>; | 53 friend class content::WebContentsUserData<JavaScriptDialogTabHelper>; |
| 42 | 54 |
| 55 void CloseDialog(bool suppress_callback, | |
| 56 bool success, | |
| 57 const base::string16& user_input); | |
| 58 | |
| 59 // The dialog being displayed on the observed WebContents. | |
| 60 base::WeakPtr<JavaScriptDialogViews> dialog_; | |
| 61 | |
| 62 // The callback provided for when the dialog is closed. Usually the dialog | |
| 63 // itself calls it, but this class will do in some cases. | |
|
Peter Kasting
2016/10/17 20:16:05
Nit: "will do it" or "will do so". Would be nice
Avi (use Gerrit)
2016/10/18 02:46:41
Done.
| |
| 64 content::JavaScriptDialogManager::DialogClosedCallback dialog_callback_; | |
| 65 | |
| 43 DISALLOW_COPY_AND_ASSIGN(JavaScriptDialogTabHelper); | 66 DISALLOW_COPY_AND_ASSIGN(JavaScriptDialogTabHelper); |
| 44 }; | 67 }; |
| 45 | 68 |
| 46 #endif // CHROME_BROWSER_UI_JAVASCRIPT_DIALOGS_JAVASCRIPT_DIALOG_TAB_HELPER_H_ | 69 #endif // CHROME_BROWSER_UI_JAVASCRIPT_DIALOGS_JAVASCRIPT_DIALOG_TAB_HELPER_H_ |
| OLD | NEW |