Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: chrome/browser/app_modal_dialog.h

Issue 63033: Refactor AppModalDialogQueue and move JS Alert boxes into a MVC. (Closed)
Patch Set: whitespace Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/app_modal_dialog.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2009 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_APP_MODAL_DIALOG_H_
6 #define CHROME_BROWSER_APP_MODAL_DIALOG_H_
7
8 #include <string>
9
10 #include "build/build_config.h"
11 #include "chrome/common/notification_observer.h"
12 #include "chrome/common/notification_registrar.h"
13
14 #if defined(OS_WIN)
15 class JavascriptMessageBoxDialog;
16 typedef JavascriptMessageBoxDialog* NativeDialog;
17 #elif defined(OS_LINUX)
18 typedef void* NativeDialog;
19 #elif defined(OS_MACOSX)
20 typedef void* NativeDialog;
21 #endif
22
23 class WebContents;
24 namespace IPC {
25 class Message;
26 }
27
28 // A controller+model class for javascript alert, confirm, prompt, and
29 // onbeforeunload dialog boxes. |NativeDialog| is a platform specific
30 // view.
31 class AppModalDialog : public NotificationObserver {
32 public:
33 // A union of data necessary to determine the type of message box to
34 // show. |dialog_flags| is a MessageBox flag.
35 AppModalDialog(WebContents* web_contents,
36 const std::wstring& title,
37 int dialog_flags,
38 const std::wstring& message_text,
39 const std::wstring& default_prompt_text,
40 bool display_suppress_checkbox,
41 bool is_before_unload_dialog,
42 IPC::Message* reply_msg);
43 ~AppModalDialog();
44
45 // Called by the app modal window queue when it is time to show this window.
46 void ShowModalDialog();
47
48 /////////////////////////////////////////////////////////////////////////////
49 // The following methods are platform specific and should be implemented in
50 // the platform specific .cc files.
51 // Create the platform specific NativeDialog and display it.
52 void CreateAndShowDialog();
53
54 // Close the dialog if it is showing.
55 void CloseModalDialog();
56
57 // Called by the app modal window queue to activate the window.
58 void ActivateModalDialog();
59
60 /////////////////////////////////////////////////////////////////////////////
61 // Getters so NativeDialog can get information about the message box.
62 WebContents* web_contents() {
63 return web_contents_;
64 }
65 int dialog_flags() {
66 return dialog_flags_;
67 }
68 std::wstring title() {
69 return title_;
70 }
71 bool is_before_unload_dialog() {
72 return is_before_unload_dialog_;
73 }
74
75 // Callbacks from NativeDialog when the user accepts or cancels the dialog.
76 void OnCancel();
77 void OnAccept(const std::wstring& prompt_text, bool suppress_js_messages);
78
79 // Helper methods used to query or control the dialog. This is used by
80 // automation.
81 int GetDialogButtons();
82 void AcceptWindow();
83 void CancelWindow();
84
85 private:
86 void InitNotifications();
87
88 // NotificationObserver implementation.
89 virtual void Observe(NotificationType type,
90 const NotificationSource& source,
91 const NotificationDetails& details);
92
93 NotificationRegistrar registrar_;
94
95 // A reference to the platform native dialog box.
96 NativeDialog dialog_;
97
98 // Information about the message box is held in the following variables.
99 WebContents* web_contents_;
100 std::wstring title_;
101 int dialog_flags_;
102 std::wstring message_text_;
103 std::wstring default_prompt_text_;
104 bool display_suppress_checkbox_;
105 bool is_before_unload_dialog_;
106 IPC::Message* reply_msg_;
107 };
108
109 #endif // #ifndef CHROME_BROWSER_APP_MODAL_DIALOG_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/app_modal_dialog.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698