From 3ab9cb81731759c6e11f8c5296c1b75a7d2dadf1 Mon Sep 17 00:00:00 2001 From: "avi@chromium.org" Date: Fri, 3 Jun 2011 18:02:07 +0000 Subject: Remove JS dialog dependency from content. BUG=71097 TEST=all types of javascript dialogs work, onbeforeunload dialogs work too Review URL: http://codereview.chromium.org/7096016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87806 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/tab_contents/background_contents.cc | 18 +++++++++++------- chrome/browser/tab_contents/background_contents.h | 20 ++++++++++---------- .../browser/tab_contents/tab_contents_ssl_helper.cc | 2 +- 3 files changed, 22 insertions(+), 18 deletions(-) (limited to 'chrome/browser/tab_contents') diff --git a/chrome/browser/tab_contents/background_contents.cc b/chrome/browser/tab_contents/background_contents.cc index cae94e8..6bad66f 100644 --- a/chrome/browser/tab_contents/background_contents.cc +++ b/chrome/browser/tab_contents/background_contents.cc @@ -109,8 +109,12 @@ void BackgroundContents::RunJavaScriptMessage( const int flags, IPC::Message* reply_msg, bool* did_suppress_message) { - // TODO(rafaelw): Implement, The JavaScriptModalDialog needs to learn about - // BackgroundContents. + // TODO(rafaelw): Implement. + + // Since we are suppressing messages, just reply as if the user immediately + // pressed "Cancel". + OnDialogClosed(reply_msg, false, string16()); + *did_suppress_message = true; } @@ -137,15 +141,15 @@ void BackgroundContents::Observe(NotificationType type, } } -void BackgroundContents::OnMessageBoxClosed(IPC::Message* reply_msg, - bool success, - const std::wstring& user_input) { +void BackgroundContents::OnDialogClosed(IPC::Message* reply_msg, + bool success, + const string16& user_input) { render_view_host()->JavaScriptDialogClosed(reply_msg, success, - WideToUTF16Hack(user_input)); + user_input); } -gfx::NativeWindow BackgroundContents::GetMessageBoxRootWindow() { +gfx::NativeWindow BackgroundContents::GetDialogRootWindow() { NOTIMPLEMENTED(); return NULL; } diff --git a/chrome/browser/tab_contents/background_contents.h b/chrome/browser/tab_contents/background_contents.h index b368766..93e1b43 100644 --- a/chrome/browser/tab_contents/background_contents.h +++ b/chrome/browser/tab_contents/background_contents.h @@ -11,8 +11,9 @@ #include "base/scoped_ptr.h" #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" -#include "chrome/browser/ui/app_modal_dialogs/js_modal_dialog.h" +#include "content/browser/javascript_dialogs.h" #include "content/browser/renderer_host/render_view_host_delegate.h" +#include "content/common/notification_observer.h" #include "content/common/notification_registrar.h" #include "content/common/window_container_type.h" #include "webkit/glue/window_open_disposition.h" @@ -32,7 +33,7 @@ class Rect; class BackgroundContents : public RenderViewHostDelegate, public RenderViewHostDelegate::View, public NotificationObserver, - public JavaScriptAppModalDialogDelegate { + public content::JavaScriptDialogDelegate { public: class Delegate { public: @@ -124,14 +125,13 @@ class BackgroundContents : public RenderViewHostDelegate, const NotificationSource& source, const NotificationDetails& details); - // Overridden from JavaScriptAppModalDialogDelegate: - virtual void OnMessageBoxClosed(IPC::Message* reply_msg, - bool success, - const std::wstring& user_input); - virtual void SetSuppressMessageBoxes(bool suppress_message_boxes) {} - virtual gfx::NativeWindow GetMessageBoxRootWindow(); - virtual TabContents* AsTabContents(); - virtual ExtensionHost* AsExtensionHost(); + // Overridden from JavaScriptDialogDelegate: + virtual void OnDialogClosed(IPC::Message* reply_msg, + bool success, + const string16& user_input) OVERRIDE; + virtual gfx::NativeWindow GetDialogRootWindow() OVERRIDE; + virtual TabContents* AsTabContents() OVERRIDE; + virtual ExtensionHost* AsExtensionHost() OVERRIDE; virtual void UpdateInspectorSetting(const std::string& key, const std::string& value); diff --git a/chrome/browser/tab_contents/tab_contents_ssl_helper.cc b/chrome/browser/tab_contents/tab_contents_ssl_helper.cc index f7a25c8..a1811f1 100644 --- a/chrome/browser/tab_contents/tab_contents_ssl_helper.cc +++ b/chrome/browser/tab_contents/tab_contents_ssl_helper.cc @@ -89,7 +89,7 @@ string16 SSLCertAddedInfoBarDelegate::GetButtonLabel( } bool SSLCertAddedInfoBarDelegate::Accept() { - ShowCertificateViewer(tab_contents_->GetMessageBoxRootWindow(), cert_); + ShowCertificateViewer(tab_contents_->GetDialogRootWindow(), cert_); return false; // Hiding the infobar just as the dialog opens looks weird. } -- cgit v1.1