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_VIEWS_H_ | 5 #ifndef CHROME_BROWSER_UI_JAVASCRIPT_DIALOGS_JAVASCRIPT_DIALOG_VIEWS_H_ |
6 #define CHROME_BROWSER_UI_JAVASCRIPT_DIALOGS_JAVASCRIPT_DIALOG_VIEWS_H_ | 6 #define CHROME_BROWSER_UI_JAVASCRIPT_DIALOGS_JAVASCRIPT_DIALOG_VIEWS_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "chrome/browser/ui/javascript_dialogs/javascript_dialog.h" |
12 #include "content/public/browser/javascript_dialog_manager.h" | 12 #include "content/public/browser/javascript_dialog_manager.h" |
13 #include "ui/views/window/dialog_delegate.h" | 13 #include "ui/views/window/dialog_delegate.h" |
14 | 14 |
15 namespace views { | 15 namespace views { |
16 class MessageBoxView; | 16 class MessageBoxView; |
17 } | 17 } |
18 | 18 |
19 // A Views version of a JavaScript dialog that automatically dismisses itself | 19 // A Views version of a JavaScript dialog that automatically dismisses itself |
20 // when the user switches away to a different tab, used for WebContentses that | 20 // when the user switches away to a different tab, used for WebContentses that |
21 // are browser tabs. | 21 // are browser tabs. |
22 class JavaScriptDialogViews : public views::DialogDelegate { | 22 class JavaScriptDialogViews : public JavaScriptDialog, |
| 23 public views::DialogDelegate { |
23 public: | 24 public: |
24 ~JavaScriptDialogViews() override; | 25 ~JavaScriptDialogViews() override; |
25 | 26 |
26 static base::WeakPtr<JavaScriptDialogViews> Create( | 27 static base::WeakPtr<JavaScriptDialogViews> Create( |
27 content::WebContents* parent_web_contents, | 28 content::WebContents* parent_web_contents, |
28 content::WebContents* alerting_web_contents, | 29 content::WebContents* alerting_web_contents, |
29 const base::string16& title, | 30 const base::string16& title, |
30 content::JavaScriptMessageType message_type, | 31 content::JavaScriptMessageType message_type, |
31 const base::string16& message_text, | 32 const base::string16& message_text, |
32 const base::string16& default_prompt_text, | 33 const base::string16& default_prompt_text, |
33 const content::JavaScriptDialogManager::DialogClosedCallback& | 34 const content::JavaScriptDialogManager::DialogClosedCallback& |
34 dialog_callback); | 35 dialog_callback); |
35 | 36 |
36 // Closes the dialog without sending a callback. This is useful when the | 37 // JavaScriptDialog: |
37 // JavaScriptDialogTabHelper needs to make this dialog go away so that it can | 38 void CloseDialogWithoutCallback() override; |
38 // respond to a call that requires it to make no callback or make a customized | |
39 // one. | |
40 void CloseDialogWithoutCallback(); | |
41 | 39 |
42 // views::DialogDelegate: | 40 // views::DialogDelegate: |
43 int GetDefaultDialogButton() const override; | 41 int GetDefaultDialogButton() const override; |
44 int GetDialogButtons() const override; | 42 int GetDialogButtons() const override; |
45 base::string16 GetWindowTitle() const override; | 43 base::string16 GetWindowTitle() const override; |
46 bool Cancel() override; | 44 bool Cancel() override; |
47 bool Accept() override; | 45 bool Accept() override; |
48 bool Close() override; | 46 bool Close() override; |
49 void DeleteDelegate() override; | 47 void DeleteDelegate() override; |
50 | 48 |
(...skipping 23 matching lines...) Expand all Loading... |
74 | 72 |
75 // The message box view whose commands we handle. | 73 // The message box view whose commands we handle. |
76 views::MessageBoxView* message_box_view_; | 74 views::MessageBoxView* message_box_view_; |
77 | 75 |
78 base::WeakPtrFactory<JavaScriptDialogViews> weak_factory_; | 76 base::WeakPtrFactory<JavaScriptDialogViews> weak_factory_; |
79 | 77 |
80 DISALLOW_COPY_AND_ASSIGN(JavaScriptDialogViews); | 78 DISALLOW_COPY_AND_ASSIGN(JavaScriptDialogViews); |
81 }; | 79 }; |
82 | 80 |
83 #endif // CHROME_BROWSER_UI_JAVASCRIPT_DIALOGS_JAVASCRIPT_DIALOG_VIEWS_H_ | 81 #endif // CHROME_BROWSER_UI_JAVASCRIPT_DIALOGS_JAVASCRIPT_DIALOG_VIEWS_H_ |
OLD | NEW |