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

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

Issue 560030: Refactored out JS specific part of modal dialog stack into its own class, exp... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/extensions/extension_host.cc ('k') | chrome/browser/js_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')
Property Changes:
Name: svn:eol-style
+ LF
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_JS_MODAL_DIALOG_H_
6 #define CHROME_BROWSER_JS_MODAL_DIALOG_H_
7
8 #include <string>
9
10 #include "build/build_config.h"
11 #include "chrome/browser/app_modal_dialog.h"
12 #include "chrome/common/notification_observer.h"
13 #include "chrome/common/notification_registrar.h"
14 #include "net/base/cookie_monster.h"
15
16 class ExtensionHost;
17 class JavaScriptMessageBoxClient;
18
19 // A controller+model class for JavaScript alert, confirm, prompt, and
20 // onbeforeunload dialog boxes.
21 class JavaScriptAppModalDialog : public AppModalDialog,
22 public NotificationObserver {
23 public:
24 // A union of data necessary to determine the type of message box to
25 // show. |dialog_flags| is a MessageBox flag.
26 JavaScriptAppModalDialog(JavaScriptMessageBoxClient* client,
27 const std::wstring& title,
28 int dialog_flags,
29 const std::wstring& message_text,
30 const std::wstring& default_prompt_text,
31 bool display_suppress_checkbox,
32 bool is_before_unload_dialog,
33 IPC::Message* reply_msg);
34 virtual ~JavaScriptAppModalDialog();
35
36 // AppModalDialog overrides.
37 #if defined(OS_LINUX) || defined(OS_MACOSX)
38 virtual void CreateAndShowDialog();
39 #endif
40 #if defined(OS_LINUX)
41 virtual void HandleDialogResponse(GtkDialog* dialog, gint response_id);
42 #endif
43 virtual int GetDialogButtons();
44 virtual void AcceptWindow();
45 virtual void CancelWindow();
46
47 /////////////////////////////////////////////////////////////////////////////
48 // Getters so NativeDialog can get information about the message box.
49 JavaScriptMessageBoxClient* client() {
50 return client_;
51 }
52 int dialog_flags() {
53 return dialog_flags_;
54 }
55 bool is_before_unload_dialog() {
56 return is_before_unload_dialog_;
57 }
58
59 // Callbacks from NativeDialog when the user accepts or cancels the dialog.
60 void OnCancel();
61 void OnAccept(const std::wstring& prompt_text, bool suppress_js_messages);
62 void OnClose();
63
64 protected:
65 // AppModalDialog overrides.
66 virtual void Cleanup();
67 virtual NativeDialog CreateNativeDialog();
68
69 private:
70 // NotificationObserver implementation.
71 virtual void Observe(NotificationType type,
72 const NotificationSource& source,
73 const NotificationDetails& details);
74
75 // Initializes for notifications to listen.
76 void InitNotifications();
77
78 NotificationRegistrar registrar_;
79
80 // An implementation of the client interface to provide supporting methods
81 // and receive results.
82 JavaScriptMessageBoxClient* client_;
83
84 // The client_ as an ExtensionHost, cached for use during notifications that
85 // may arrive after the client has entered its destructor (and is thus
86 // treated as a base JavaScriptMessageBoxClient). This will be NULL if the
87 // client is not an ExtensionHost.
88 ExtensionHost* extension_host_;
89
90 // Information about the message box is held in the following variables.
91 int dialog_flags_;
92 std::wstring message_text_;
93 std::wstring default_prompt_text_;
94 bool display_suppress_checkbox_;
95 bool is_before_unload_dialog_;
96 IPC::Message* reply_msg_;
97
98 DISALLOW_COPY_AND_ASSIGN(JavaScriptAppModalDialog);
99 };
100
101 #endif // CHROME_BROWSER_JS_MODAL_DIALOG_H_
102
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_host.cc ('k') | chrome/browser/js_modal_dialog.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698