Chromium Code Reviews| 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 COMPONENTS_APP_MODAL_JAVASCRIPT_DIALOG_MANAGER_H_ | 5 #ifndef COMPONENTS_APP_MODAL_JAVASCRIPT_DIALOG_MANAGER_H_ |
| 6 #define COMPONENTS_APP_MODAL_JAVASCRIPT_DIALOG_MANAGER_H_ | 6 #define COMPONENTS_APP_MODAL_JAVASCRIPT_DIALOG_MANAGER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 // dialog window instances. | 30 // dialog window instances. |
| 31 void SetNativeDialogFactory( | 31 void SetNativeDialogFactory( |
| 32 std::unique_ptr<JavaScriptNativeDialogFactory> factory); | 32 std::unique_ptr<JavaScriptNativeDialogFactory> factory); |
| 33 | 33 |
| 34 // JavaScript dialogs may be opened by an extensions/app, thus they need | 34 // JavaScript dialogs may be opened by an extensions/app, thus they need |
| 35 // access to extensions functionality. This sets a client interface to | 35 // access to extensions functionality. This sets a client interface to |
| 36 // access //extensions. | 36 // access //extensions. |
| 37 void SetExtensionsClient( | 37 void SetExtensionsClient( |
| 38 std::unique_ptr<JavaScriptDialogExtensionsClient> extensions_client); | 38 std::unique_ptr<JavaScriptDialogExtensionsClient> extensions_client); |
| 39 | 39 |
| 40 private: | 40 // Gets the title for a dialog. |
| 41 friend struct base::DefaultSingletonTraits<JavaScriptDialogManager>; | 41 base::string16 GetTitle(content::WebContents* web_contents, |
| 42 | 42 const GURL& origin_url); |
|
Peter Kasting
2016/10/17 20:16:05
Nit: Move definition order in .cc to match
Avi (use Gerrit)
2016/10/18 02:46:42
Done.
| |
| 43 JavaScriptDialogManager(); | |
| 44 ~JavaScriptDialogManager() override; | |
| 45 | 43 |
| 46 // JavaScriptDialogManager: | 44 // JavaScriptDialogManager: |
| 47 void RunJavaScriptDialog(content::WebContents* web_contents, | 45 void RunJavaScriptDialog(content::WebContents* web_contents, |
| 48 const GURL& origin_url, | 46 const GURL& origin_url, |
| 49 content::JavaScriptMessageType message_type, | 47 content::JavaScriptMessageType message_type, |
| 50 const base::string16& message_text, | 48 const base::string16& message_text, |
| 51 const base::string16& default_prompt_text, | 49 const base::string16& default_prompt_text, |
| 52 const DialogClosedCallback& callback, | 50 const DialogClosedCallback& callback, |
| 53 bool* did_suppress_message) override; | 51 bool* did_suppress_message) override; |
| 54 void RunBeforeUnloadDialog(content::WebContents* web_contents, | 52 void RunBeforeUnloadDialog(content::WebContents* web_contents, |
| 55 bool is_reload, | 53 bool is_reload, |
| 56 const DialogClosedCallback& callback) override; | 54 const DialogClosedCallback& callback) override; |
| 57 bool HandleJavaScriptDialog(content::WebContents* web_contents, | 55 bool HandleJavaScriptDialog(content::WebContents* web_contents, |
| 58 bool accept, | 56 bool accept, |
| 59 const base::string16* prompt_override) override; | 57 const base::string16* prompt_override) override; |
| 60 void CancelDialogs(content::WebContents* web_contents, | 58 void CancelDialogs(content::WebContents* web_contents, |
| 61 bool suppress_callbacks, | 59 bool suppress_callbacks, |
| 62 bool reset_state) override; | 60 bool reset_state) override; |
| 63 | 61 |
| 64 base::string16 GetTitle(content::WebContents* web_contents, | 62 private: |
| 65 const GURL& origin_url, | 63 friend struct base::DefaultSingletonTraits<JavaScriptDialogManager>; |
| 66 bool is_alert); | 64 |
| 65 JavaScriptDialogManager(); | |
| 66 ~JavaScriptDialogManager() override; | |
| 67 | 67 |
| 68 // Wrapper around OnDialogClosed; logs UMA stats before continuing on. | 68 // Wrapper around OnDialogClosed; logs UMA stats before continuing on. |
| 69 void OnBeforeUnloadDialogClosed(content::WebContents* web_contents, | 69 void OnBeforeUnloadDialogClosed(content::WebContents* web_contents, |
| 70 DialogClosedCallback callback, | 70 DialogClosedCallback callback, |
| 71 bool success, | 71 bool success, |
| 72 const base::string16& user_input); | 72 const base::string16& user_input); |
| 73 | 73 |
| 74 // Wrapper around a DialogClosedCallback so that we can intercept it before | 74 // Wrapper around a DialogClosedCallback so that we can intercept it before |
| 75 // passing it onto the original callback. | 75 // passing it onto the original callback. |
| 76 void OnDialogClosed(content::WebContents* web_contents, | 76 void OnDialogClosed(content::WebContents* web_contents, |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 89 // dialogs. (Since Javascript dialogs are modal, this is even accurate!) | 89 // dialogs. (Since Javascript dialogs are modal, this is even accurate!) |
| 90 base::TimeTicks last_close_time_; | 90 base::TimeTicks last_close_time_; |
| 91 base::TimeTicks last_creation_time_; | 91 base::TimeTicks last_creation_time_; |
| 92 | 92 |
| 93 DISALLOW_COPY_AND_ASSIGN(JavaScriptDialogManager); | 93 DISALLOW_COPY_AND_ASSIGN(JavaScriptDialogManager); |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 } // namespace app_modal | 96 } // namespace app_modal |
| 97 | 97 |
| 98 #endif // COMPONENTS_APP_MODAL_JAVASCRIPT_DIALOG_MANAGER_H_ | 98 #endif // COMPONENTS_APP_MODAL_JAVASCRIPT_DIALOG_MANAGER_H_ |
| OLD | NEW |