summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-30 18:16:52 +0000
committerbauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-30 18:16:52 +0000
commitc6a5d82465a2039714fb346fa91d5a3ea77fed2f (patch)
treefdb4e7b26ca859b8949413505ea6db08dcfbf098
parent2a7a3f2cd5da2eca0944341d55fee1d7b899a181 (diff)
downloadchromium_src-c6a5d82465a2039714fb346fa91d5a3ea77fed2f.zip
chromium_src-c6a5d82465a2039714fb346fa91d5a3ea77fed2f.tar.gz
chromium_src-c6a5d82465a2039714fb346fa91d5a3ea77fed2f.tar.bz2
Make repost form warning tab-modal on Windows.
Also, add a type ConstrainedDialogDelegate that is used for constrained windows that show a dialog. In a future CL, Mac and Gtk will be changed to use that type. BUG=26271 TEST=Go to http://www.cs.unc.edu/~jbs/resources/perl/perl-cgi/programs/form1-POST.html, hit Submit, then refresh. The warning sheet should be tab-modal, not window-modal. Opening a login form (which is also tab-modal) while the warning is shown should not crash, neither should hitting the reload button again, or bringing up the warning while a login form is shown. Review URL: http://codereview.chromium.org/1138009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43112 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/login_prompt_win.cc2
-rw-r--r--chrome/browser/tab_contents/constrained_window.h5
-rw-r--r--chrome/browser/views/repost_form_warning_view.cc34
-rw-r--r--chrome/browser/views/repost_form_warning_view.h13
4 files changed, 41 insertions, 13 deletions
diff --git a/chrome/browser/login_prompt_win.cc b/chrome/browser/login_prompt_win.cc
index c059657..13e1664 100644
--- a/chrome/browser/login_prompt_win.cc
+++ b/chrome/browser/login_prompt_win.cc
@@ -29,7 +29,7 @@ using webkit_glue::PasswordForm;
// This class uses ref counting to ensure that it lives until all InvokeLaters
// have been called.
class LoginHandlerWin : public LoginHandler,
- public views::DialogDelegate {
+ public ConstrainedDialogDelegate {
public:
explicit LoginHandlerWin(URLRequest* request) : LoginHandler(request) {
}
diff --git a/chrome/browser/tab_contents/constrained_window.h b/chrome/browser/tab_contents/constrained_window.h
index be03a1c..3dc6592 100644
--- a/chrome/browser/tab_contents/constrained_window.h
+++ b/chrome/browser/tab_contents/constrained_window.h
@@ -12,14 +12,19 @@
#if defined(OS_WIN)
namespace views {
class WindowDelegate;
+class DialogDelegate;
}
typedef views::WindowDelegate ConstrainedWindowDelegate;
+typedef views::DialogDelegate ConstrainedDialogDelegate;
#elif defined(OS_MACOSX)
class ConstrainedWindowMacDelegate;
+class ConstrainedWindowMacDelegateSystemSheet;
typedef ConstrainedWindowMacDelegate ConstrainedWindowDelegate;
+typedef ConstrainedWindowMacDelegateSystemSheet ConstrainedDialogDelegate;
#elif defined(TOOLKIT_USES_GTK)
class ConstrainedWindowGtkDelegate;
typedef ConstrainedWindowGtkDelegate ConstrainedWindowDelegate;
+typedef ConstrainedWindowGtkDelegate ConstrainedDialogDelegate;
#endif
class TabContents;
diff --git a/chrome/browser/views/repost_form_warning_view.cc b/chrome/browser/views/repost_form_warning_view.cc
index 6e64d81..a2ef324 100644
--- a/chrome/browser/views/repost_form_warning_view.cc
+++ b/chrome/browser/views/repost_form_warning_view.cc
@@ -20,7 +20,7 @@ namespace browser {
// Declared in browser_dialogs.h so others don't have to depend on our header.
void ShowRepostFormWarningDialog(gfx::NativeWindow parent_window,
TabContents* tab_contents) {
- new RepostFormWarningView(parent_window, &tab_contents->controller());
+ new RepostFormWarningView(parent_window, tab_contents);
}
} // namespace browser
@@ -30,19 +30,21 @@ void ShowRepostFormWarningDialog(gfx::NativeWindow parent_window,
RepostFormWarningView::RepostFormWarningView(
gfx::NativeWindow parent_window,
- NavigationController* navigation_controller)
- : navigation_controller_(navigation_controller),
+ TabContents* tab_contents)
+ : navigation_controller_(&tab_contents->controller()),
message_box_view_(NULL) {
message_box_view_ = new MessageBoxView(
MessageBoxFlags::kIsConfirmMessageBox,
l10n_util::GetString(IDS_HTTP_POST_WARNING),
- L"");
- views::Window::CreateChromeWindow(parent_window, gfx::Rect(), this)->Show();
+ std::wstring());
+ dialog_ = tab_contents->CreateConstrainedDialog(this);
registrar_.Add(this, NotificationType::LOAD_START,
Source<NavigationController>(navigation_controller_));
registrar_.Add(this, NotificationType::TAB_CLOSING,
Source<NavigationController>(navigation_controller_));
+ registrar_.Add(this, NotificationType::RELOADING,
+ Source<NavigationController>(navigation_controller_));
}
RepostFormWarningView::~RepostFormWarningView() {
@@ -69,12 +71,18 @@ void RepostFormWarningView::DeleteDelegate() {
}
bool RepostFormWarningView::Cancel() {
+ if (navigation_controller_) {
+ navigation_controller_->CancelPendingReload();
+ Close();
+ }
return true;
}
bool RepostFormWarningView::Accept() {
- if (navigation_controller_)
- navigation_controller_->Reload(false);
+ if (navigation_controller_) {
+ navigation_controller_->ContinuePendingReload();
+ Close();
+ }
return true;
}
@@ -88,6 +96,13 @@ views::View* RepostFormWarningView::GetContentsView() {
///////////////////////////////////////////////////////////////////////////////
// RepostFormWarningView, private:
+void RepostFormWarningView::Close() {
+ navigation_controller_ = NULL;
+ if (dialog_) {
+ dialog_->CloseConstrainedWindow();
+ }
+}
+
void RepostFormWarningView::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
@@ -96,10 +111,11 @@ void RepostFormWarningView::Observe(NotificationType type,
// a navigation controller anymore.
if (window() && navigation_controller_ &&
(type == NotificationType::LOAD_START ||
- type == NotificationType::TAB_CLOSING)) {
+ type == NotificationType::TAB_CLOSING ||
+ type == NotificationType::RELOADING)) {
DCHECK_EQ(Source<NavigationController>(source).ptr(),
navigation_controller_);
navigation_controller_ = NULL;
- window()->Close();
+ Close();
}
}
diff --git a/chrome/browser/views/repost_form_warning_view.h b/chrome/browser/views/repost_form_warning_view.h
index 885ce54..b8a4a8c 100644
--- a/chrome/browser/views/repost_form_warning_view.h
+++ b/chrome/browser/views/repost_form_warning_view.h
@@ -5,12 +5,14 @@
#ifndef CHROME_BROWSER_VIEWS_REPOST_FORM_WARNING_VIEW_H_
#define CHROME_BROWSER_VIEWS_REPOST_FORM_WARNING_VIEW_H_
+#include "chrome/browser/tab_contents/constrained_window.h"
#include "chrome/common/notification_registrar.h"
#include "gfx/native_widget_types.h"
#include "views/window/dialog_delegate.h"
class MessageBoxView;
class NavigationController;
+class TabContents;
namespace views {
class Window;
}
@@ -19,12 +21,12 @@ class Window;
// To display the dialog, allocate this object on the heap. It will open the
// dialog from its constructor and then delete itself when the user dismisses
// the dialog.
-class RepostFormWarningView : public views::DialogDelegate,
+class RepostFormWarningView : public ConstrainedDialogDelegate,
public NotificationObserver {
public:
// Use BrowserWindow::ShowRepostFormWarningDialog to use.
RepostFormWarningView(gfx::NativeWindow parent_window,
- NavigationController* navigation_controller);
+ TabContents* tab_contents);
virtual ~RepostFormWarningView();
// views::DialogDelegate Methods:
@@ -36,7 +38,6 @@ class RepostFormWarningView : public views::DialogDelegate,
virtual bool Accept();
// views::WindowDelegate Methods:
- virtual bool IsModal() const { return true; }
virtual views::View* GetContentsView();
private:
@@ -47,11 +48,17 @@ class RepostFormWarningView : public views::DialogDelegate,
const NotificationSource& source,
const NotificationDetails& details);
+ // Close the ConstrainedWindow.
+ void Close();
+
NotificationRegistrar registrar_;
// The message box view whose commands we handle.
MessageBoxView* message_box_view_;
+ // The dialog shown.
+ ConstrainedWindow* dialog_;
+
// Navigation controller, used to continue the reload.
NavigationController* navigation_controller_;