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

Unified Diff: content/browser/javascript_dialogs.h

Issue 7283022: Make a clean interface for dialog callbacks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 9 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/javascript_dialogs.h
diff --git a/content/browser/javascript_dialogs.h b/content/browser/javascript_dialogs.h
index 20de44bbae42d0742d6082534ed1c623e8dbfc96..74297b45289ba0e0d4fa13c3ed0f5ccb5b1f8b93 100644
--- a/content/browser/javascript_dialogs.h
+++ b/content/browser/javascript_dialogs.h
@@ -20,33 +20,31 @@ class Message;
namespace content {
+class DialogDelegate {
+ public:
+ // Returns the root native window with which to associate the dialog.
+ virtual gfx::NativeWindow GetDialogRootWindow() = 0;
+
+ // Called right before the dialog is shown.
+ virtual void OnDialogShown() {}
+
+ protected:
+ virtual ~DialogDelegate() {}
+};
+
// A class that invokes a JavaScript dialog must implement this interface to
// allow the dialog implementation to get needed information and return results.
-class JavaScriptDialogDelegate {
+class JavaScriptDialogDelegate : public DialogDelegate {
public:
// This callback is invoked when the dialog is closed.
virtual void OnDialogClosed(IPC::Message* reply_msg,
bool success,
const string16& user_input) = 0;
- // Returns the root native window with which to associate the dialog.
- virtual gfx::NativeWindow GetDialogRootWindow() = 0;
-
- // Returns the TabContents implementing this delegate, or NULL if there is
- // none. TODO(avi): This breaks encapsulation and in general sucks; figure out
- // a better way of doing this.
- virtual TabContents* AsTabContents() = 0;
-
- // Returns the ExtensionHost implementing this delegate, or NULL if there is
- // none. TODO(avi): This is even suckier than AsTabContents above as it breaks
- // layering; figure out a better way of doing this. http://crbug.com/84604
- virtual ExtensionHost* AsExtensionHost() = 0;
-
protected:
virtual ~JavaScriptDialogDelegate() {}
};
-
// An interface consisting of methods that can be called to produce JavaScript
// dialogs.
class JavaScriptDialogCreator {
@@ -73,7 +71,8 @@ class JavaScriptDialogCreator {
const string16& message_text,
IPC::Message* reply_message) = 0;
- // Resets any saved JavaScript dialog state for the delegate.
+ // Cancels all pending dialogs and resets any saved JavaScript dialog state
+ // for the delegate.
virtual void ResetJavaScriptState(JavaScriptDialogDelegate* delegate) = 0;
protected:
« no previous file with comments | « chrome/browser/ui/app_modal_dialogs/message_box_handler.cc ('k') | content/browser/tab_contents/tab_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698