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