Chromium Code Reviews| 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 a JavaScript dialog that automatically dismisses itself | |
| 20 // when the user switches away from interacting with the tab, used for | |
|
Peter Kasting
2016/10/18 16:59:55
Nit: switches away from interacting with the tab -
Avi (use Gerrit)
2016/10/18 17:06:07
Done.
| |
| 21 // WebContentses that are browser tabs. | |
| 22 class JavaScriptDialogViews : public views::DialogDelegate { | |
| 23 public: | |
| 24 ~JavaScriptDialogViews() override; | |
| 25 | |
| 26 static base::WeakPtr<JavaScriptDialogViews> Create( | |
| 27 content::WebContents* parent_web_contents, | |
| 28 content::WebContents* alerting_web_contents, | |
| 29 const base::string16& title, | |
| 30 content::JavaScriptMessageType message_type, | |
| 31 const base::string16& message_text, | |
| 32 const base::string16& default_prompt_text, | |
| 33 const content::JavaScriptDialogManager::DialogClosedCallback& | |
| 34 dialog_callback); | |
| 35 | |
| 36 // Closes the dialog without sending a callback. | |
| 37 void CloseJavaScriptDialog(); | |
| 38 | |
| 39 // views::DialogDelegate: | |
| 40 int GetDefaultDialogButton() const override; | |
| 41 int GetDialogButtons() const override; | |
| 42 base::string16 GetWindowTitle() const override; | |
| 43 bool Cancel() override; | |
| 44 bool Accept() override; | |
| 45 bool Close() override; | |
| 46 void DeleteDelegate() override; | |
| 47 | |
| 48 // views::WidgetDelegate: | |
| 49 views::View* GetContentsView() override; | |
| 50 views::View* GetInitiallyFocusedView() override; | |
| 51 views::Widget* GetWidget() override; | |
| 52 const views::Widget* GetWidget() const override; | |
| 53 ui::ModalType GetModalType() const override; | |
| 54 | |
| 55 private: | |
| 56 JavaScriptDialogViews( | |
| 57 content::WebContents* parent_web_contents, | |
| 58 content::WebContents* alerting_web_contents, | |
| 59 const base::string16& title, | |
| 60 content::JavaScriptMessageType message_type, | |
| 61 const base::string16& message_text, | |
| 62 const base::string16& default_prompt_text, | |
| 63 const content::JavaScriptDialogManager::DialogClosedCallback& | |
| 64 dialog_callback); | |
| 65 | |
| 66 base::string16 title_; | |
| 67 content::JavaScriptMessageType message_type_; | |
| 68 base::string16 message_text_; | |
| 69 base::string16 default_prompt_text_; | |
| 70 content::JavaScriptDialogManager::DialogClosedCallback dialog_callback_; | |
| 71 | |
| 72 // The message box view whose commands we handle. | |
| 73 views::MessageBoxView* message_box_view_; | |
| 74 | |
| 75 base::WeakPtrFactory<JavaScriptDialogViews> weak_factory_; | |
| 76 | |
| 77 DISALLOW_COPY_AND_ASSIGN(JavaScriptDialogViews); | |
| 78 }; | |
| 79 | |
| 80 #endif // CHROME_BROWSER_UI_JAVASCRIPT_DIALOGS_JAVASCRIPT_DIALOG_VIEWS_H_ | |
| OLD | NEW |