summaryrefslogtreecommitdiffstats
path: root/content/browser
diff options
context:
space:
mode:
Diffstat (limited to 'content/browser')
-rw-r--r--content/browser/javascript_dialogs.h31
-rw-r--r--content/browser/tab_contents/tab_contents.cc8
-rw-r--r--content/browser/tab_contents/tab_contents.h3
3 files changed, 18 insertions, 24 deletions
diff --git a/content/browser/javascript_dialogs.h b/content/browser/javascript_dialogs.h
index 20de44b..74297b4 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:
diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc
index 792a7eb..b043686 100644
--- a/content/browser/tab_contents/tab_contents.cc
+++ b/content/browser/tab_contents/tab_contents.cc
@@ -1834,12 +1834,8 @@ gfx::NativeWindow TabContents::GetDialogRootWindow() {
return view_->GetTopLevelNativeWindow();
}
-TabContents* TabContents::AsTabContents() {
- return this;
-}
-
-ExtensionHost* TabContents::AsExtensionHost() {
- return NULL;
+void TabContents::OnDialogShown() {
+ Activate();
}
void TabContents::set_encoding(const std::string& encoding) {
diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h
index ebda7a4..bc2bdd3 100644
--- a/content/browser/tab_contents/tab_contents.h
+++ b/content/browser/tab_contents/tab_contents.h
@@ -444,8 +444,7 @@ class TabContents : public PageNavigator,
bool success,
const string16& user_input) OVERRIDE;
virtual gfx::NativeWindow GetDialogRootWindow() OVERRIDE;
- virtual TabContents* AsTabContents() OVERRIDE;
- virtual ExtensionHost* AsExtensionHost() OVERRIDE;
+ virtual void OnDialogShown() OVERRIDE;
// The BookmarkDragDelegate is used to forward bookmark drag and drop events
// to extensions.