OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_UI_JAVASCRIPT_DIALOGS_JAVASCRIPT_DIALOG_VIEWS_H_ | |
6 #define CHROME_BROWSER_UI_JAVASCRIPT_DIALOGS_JAVASCRIPT_DIALOG_VIEWS_H_ | |
7 | |
8 #include <memory> | |
9 | |
10 #include "base/macros.h" | |
11 #include "base/memory/weak_ptr.h" | |
12 #include "content/public/browser/javascript_dialog_manager.h" | |
13 #include "ui/views/window/dialog_delegate.h" | |
14 | |
15 namespace views { | |
16 class MessageBoxView; | |
17 } | |
18 | |
19 // A Views version of auto-dismissing JavaScript dialogs, used for WebContentses | |
20 // that are browser tabs. | |
Peter Kasting
2016/10/18 04:31:03
Nit: Maybe describe/link to what an "auto-dismissi
Avi (use Gerrit)
2016/10/18 16:31:49
Done.
| |
21 class JavaScriptDialogViews : public views::DialogDelegate { | |
22 public: | |
23 ~JavaScriptDialogViews() override; | |
24 | |
25 static base::WeakPtr<JavaScriptDialogViews> Create( | |
26 content::WebContents* parent_web_contents, | |
27 content::WebContents* alerting_web_contents, | |
28 const base::string16& title, | |
29 content::JavaScriptMessageType message_type, | |
30 const base::string16& message_text, | |
31 const base::string16& default_prompt_text, | |
32 const content::JavaScriptDialogManager::DialogClosedCallback& | |
33 dialog_callback); | |
34 | |
35 // Close the dialog without sending a callback. | |
Peter Kasting
2016/10/18 04:31:03
Nit: Close -> Closes (see the "imperative" bit in
Avi (use Gerrit)
2016/10/18 16:31:49
Done.
| |
36 void CloseJavaScriptDialog(); | |
37 | |
38 // views::DialogDelegate: | |
39 int GetDefaultDialogButton() const override; | |
40 int GetDialogButtons() const override; | |
41 base::string16 GetWindowTitle() const override; | |
42 bool Cancel() override; | |
43 bool Accept() override; | |
44 bool Close() override; | |
45 void DeleteDelegate() override; | |
46 | |
47 // views::WidgetDelegate: | |
48 views::View* GetContentsView() override; | |
49 views::View* GetInitiallyFocusedView() override; | |
50 views::Widget* GetWidget() override; | |
51 const views::Widget* GetWidget() const override; | |
52 ui::ModalType GetModalType() const override; | |
53 | |
54 private: | |
55 JavaScriptDialogViews( | |
56 content::WebContents* parent_web_contents, | |
57 content::WebContents* alerting_web_contents, | |
58 const base::string16& title, | |
59 content::JavaScriptMessageType message_type, | |
60 const base::string16& message_text, | |
61 const base::string16& default_prompt_text, | |
62 const content::JavaScriptDialogManager::DialogClosedCallback& | |
63 dialog_callback); | |
64 | |
65 base::string16 title_; | |
66 content::JavaScriptMessageType message_type_; | |
67 base::string16 message_text_; | |
68 base::string16 default_prompt_text_; | |
69 content::JavaScriptDialogManager::DialogClosedCallback dialog_callback_; | |
70 | |
71 // The message box view whose commands we handle. | |
72 views::MessageBoxView* message_box_view_; | |
73 | |
74 base::WeakPtrFactory<JavaScriptDialogViews> weak_factory_; | |
75 | |
76 DISALLOW_COPY_AND_ASSIGN(JavaScriptDialogViews); | |
77 }; | |
78 | |
79 #endif // CHROME_BROWSER_UI_JAVASCRIPT_DIALOGS_JAVASCRIPT_DIALOG_VIEWS_H_ | |
OLD | NEW |