| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2006-2008 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_JSMESSAGE_BOX_HANDLER_WIN_H_ | |
| 6 #define CHROME_BROWSER_JSMESSAGE_BOX_HANDLER_WIN_H_ | |
| 7 | |
| 8 #include "chrome/browser/jsmessage_box_handler.h" | |
| 9 #include "chrome/common/ipc_message.h" | |
| 10 #include "chrome/common/notification_observer.h" | |
| 11 #include "chrome/common/notification_registrar.h" | |
| 12 #include "chrome/views/window/app_modal_dialog_delegate.h" | |
| 13 #include "googleurl/src/gurl.h" | |
| 14 | |
| 15 class MessageBoxView; | |
| 16 class WebContents; | |
| 17 namespace views { | |
| 18 class Window; | |
| 19 } | |
| 20 | |
| 21 class JavascriptMessageBoxHandler | |
| 22 : public views::AppModalDialogDelegate, | |
| 23 public NotificationObserver { | |
| 24 public: | |
| 25 // Cross-platform code should use RunJavaScriptMessageBox. | |
| 26 JavascriptMessageBoxHandler(WebContents* web_contents, | |
| 27 const GURL& frame_url, | |
| 28 int dialog_flags, | |
| 29 const std::wstring& message_text, | |
| 30 const std::wstring& default_prompt_text, | |
| 31 bool display_suppress_checkbox, | |
| 32 IPC::Message* reply_msg); | |
| 33 virtual ~JavascriptMessageBoxHandler(); | |
| 34 | |
| 35 // views::DialogDelegate Methods: | |
| 36 virtual int GetDialogButtons() const; | |
| 37 virtual std::wstring GetWindowTitle() const; | |
| 38 virtual void WindowClosing(); | |
| 39 virtual void DeleteDelegate(); | |
| 40 virtual bool Cancel(); | |
| 41 virtual bool Accept(); | |
| 42 | |
| 43 // views::AppModalDialogDelegate | |
| 44 virtual void ShowModalDialog(); | |
| 45 virtual void ActivateModalDialog(); | |
| 46 | |
| 47 // views::WindowDelegate Methods: | |
| 48 virtual bool IsModal() const { return true; } | |
| 49 virtual views::View* GetContentsView(); | |
| 50 virtual views::View* GetInitiallyFocusedView(); | |
| 51 | |
| 52 private: | |
| 53 // NotificationObserver implementation. | |
| 54 virtual void Observe(NotificationType type, | |
| 55 const NotificationSource& source, | |
| 56 const NotificationDetails& details); | |
| 57 | |
| 58 NotificationRegistrar registrar_; | |
| 59 | |
| 60 // The message box view whose commands we handle. | |
| 61 MessageBoxView* message_box_view_; | |
| 62 | |
| 63 // The IPC message used to reply to the renderer when the message box | |
| 64 // is dismissed. | |
| 65 IPC::Message* reply_msg_; | |
| 66 | |
| 67 // The associated WebContents. Used to send IPC messages to the renderer. | |
| 68 WebContents* web_contents_; | |
| 69 | |
| 70 // The URL of the frame originating the dialog. It is important we display | |
| 71 // this so the user doesn't blame the enclosing site if a subframe alert()s. | |
| 72 GURL frame_url_; | |
| 73 | |
| 74 // Stores flags defined in message_box_view.h which describe the dialog box. | |
| 75 int dialog_flags_; | |
| 76 | |
| 77 // The dialog if it is currently visible. | |
| 78 views::Window* dialog_; | |
| 79 | |
| 80 DISALLOW_COPY_AND_ASSIGN(JavascriptMessageBoxHandler); | |
| 81 }; | |
| 82 | |
| 83 #endif // CHROME_BROWSER_JSMESSAGE_BOX_HANDLER_WIN_H_ | |
| OLD | NEW |