summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authordhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-24 17:02:15 +0000
committerdhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-24 17:02:15 +0000
commitc8f6e4a7e4f5c9cebccdeeefcd22fe947449215f (patch)
tree6ad0547f8287472c2cf47ed622763a69dc1cd42b /chrome
parent1d6247d4ecb0714dca4d505b318d4b7c2a674598 (diff)
downloadchromium_src-c8f6e4a7e4f5c9cebccdeeefcd22fe947449215f.zip
chromium_src-c8f6e4a7e4f5c9cebccdeeefcd22fe947449215f.tar.gz
chromium_src-c8f6e4a7e4f5c9cebccdeeefcd22fe947449215f.tar.bz2
Revert 42474 - Make repost form warning tabmodal on Gtk.
This is the Gtk version of http://codereview.chromium.org/969003. BUG=26271 TEST=Go to http://www.cs.unc.edu/~jbs/resources/perl/perlcgi/programs/form1POST.html, hit Submit, then refresh. The warning sheet should be tabmodal, not windowmodal. Opening a login form (which is also tabmodal) while the warning is shown should not crash, neither should bringing up the warning while a login form is shown. Review URL: http://codereview.chromium.org/660434 TBR=bauerb@chromium.org Review URL: http://codereview.chromium.org/1247004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42479 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/gtk/browser_window_gtk.cc2
-rw-r--r--chrome/browser/gtk/repost_form_warning_gtk.cc117
-rw-r--r--chrome/browser/gtk/repost_form_warning_gtk.h29
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc6
4 files changed, 50 insertions, 104 deletions
diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc
index 59873fe..39e6348 100644
--- a/chrome/browser/gtk/browser_window_gtk.cc
+++ b/chrome/browser/gtk/browser_window_gtk.cc
@@ -874,7 +874,7 @@ void BrowserWindowGtk::ShowNewProfileDialog() {
void BrowserWindowGtk::ShowRepostFormWarningDialog(
TabContents* tab_contents) {
- new RepostFormWarningGtk(GetNativeHandle(), tab_contents);
+ new RepostFormWarningGtk(GetNativeHandle(), &tab_contents->controller());
}
void BrowserWindowGtk::ShowContentSettingsWindow(
diff --git a/chrome/browser/gtk/repost_form_warning_gtk.cc b/chrome/browser/gtk/repost_form_warning_gtk.cc
index a3f4681..53d1ca1 100644
--- a/chrome/browser/gtk/repost_form_warning_gtk.cc
+++ b/chrome/browser/gtk/repost_form_warning_gtk.cc
@@ -9,75 +9,45 @@
#include "base/message_loop.h"
#include "chrome/browser/gtk/gtk_util.h"
#include "chrome/browser/tab_contents/navigation_controller.h"
-#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/common/notification_service.h"
#include "grit/generated_resources.h"
-RepostFormWarningGtk::RepostFormWarningGtk(GtkWindow* parent,
- TabContents* tab_contents)
- : navigation_controller_(&tab_contents->controller()) {
- dialog_ = gtk_vbox_new(NULL, gtk_util::kContentAreaBorder);
- gtk_box_set_spacing(GTK_BOX(dialog_), gtk_util::kContentAreaSpacing);
- GtkWidget* label = gtk_label_new(
+RepostFormWarningGtk::RepostFormWarningGtk(
+ GtkWindow* parent,
+ NavigationController* navigation_controller)
+ : navigation_controller_(navigation_controller) {
+ dialog_ = gtk_message_dialog_new(
+ parent,
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_NONE,
+ "%s",
l10n_util::GetStringUTF8(IDS_HTTP_POST_WARNING).c_str());
- GtkWidget* image = gtk_image_new_from_stock(GTK_STOCK_DIALOG_QUESTION,
- GTK_ICON_SIZE_DIALOG);
- gtk_misc_set_alignment(GTK_MISC(image), 0.5, 0.0);
-
- gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
- gtk_label_set_selectable(GTK_LABEL(label), TRUE);
-
- GtkWidget *hbox = gtk_hbox_new(FALSE, gtk_util::kControlSpacing);
-
- gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
-
- gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
-
- gtk_box_pack_start(GTK_BOX(dialog_), hbox, FALSE, FALSE, 0);
-
- GtkWidget* buttonBox = gtk_hbutton_box_new();
- gtk_button_box_set_layout(GTK_BUTTON_BOX(buttonBox), GTK_BUTTONBOX_END);
- gtk_box_set_spacing(GTK_BOX(buttonBox), gtk_util::kControlSpacing);
- gtk_box_pack_end(GTK_BOX(dialog_), buttonBox, FALSE, TRUE, 0);
-
- cancel_ = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
- gtk_button_set_label(GTK_BUTTON(cancel_),
- l10n_util::GetStringUTF8(IDS_CANCEL).c_str());
- g_signal_connect(cancel_, "clicked", G_CALLBACK(OnCancelThunk), this);
- gtk_box_pack_end(GTK_BOX(buttonBox), cancel_, FALSE, TRUE, 0);
-
- ok_ = gtk_button_new_from_stock(GTK_STOCK_REFRESH);
- gtk_button_set_label(
- GTK_BUTTON(ok_),
- l10n_util::GetStringUTF8(IDS_HTTP_POST_WARNING_RESEND).c_str());
- g_signal_connect(ok_, "clicked", G_CALLBACK(OnRefreshThunk), this);
- gtk_box_pack_end(GTK_BOX(buttonBox), ok_, FALSE, TRUE, 0);
-
- g_signal_connect(cancel_, "hierarchy-changed",
- G_CALLBACK(OnHierarchyChangedThunk), this);
-
- window_ = tab_contents->CreateConstrainedDialog(this);
+ gtk_util::ApplyMessageDialogQuirks(dialog_);
+ gtk_window_set_title(GTK_WINDOW(dialog_),
+ l10n_util::GetStringUTF8(IDS_HTTP_POST_WARNING_TITLE).c_str());
+ gtk_util::AddButtonToDialog(dialog_,
+ l10n_util::GetStringUTF8(IDS_CANCEL).c_str(),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
+ gtk_util::AddButtonToDialog(dialog_,
+ l10n_util::GetStringUTF8(IDS_HTTP_POST_WARNING_RESEND).c_str(),
+ GTK_STOCK_REFRESH, GTK_RESPONSE_OK);
+ gtk_util::SetWindowIcon(GTK_WINDOW(dialog_));
+
+ g_signal_connect(dialog_, "response", G_CALLBACK(OnResponse), this);
+ g_signal_connect(dialog_, "destroy", G_CALLBACK(OnWindowDestroy), this);
+
+ gtk_widget_show_all(dialog_);
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_));
-
}
RepostFormWarningGtk::~RepostFormWarningGtk() {
}
-GtkWidget* RepostFormWarningGtk::GetWidgetRoot() {
- return dialog_;
-}
-
-void RepostFormWarningGtk::DeleteDelegate() {
- MessageLoop::current()->DeleteSoon(FROM_HERE, this);
-}
-
void RepostFormWarningGtk::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
@@ -86,11 +56,11 @@ void RepostFormWarningGtk::Observe(NotificationType type,
// a navigation controller anymore.
if (dialog_ && navigation_controller_ &&
(type == NotificationType::LOAD_START ||
- type == NotificationType::TAB_CLOSING ||
- type == NotificationType::RELOADING)) {
+ type == NotificationType::TAB_CLOSING)) {
DCHECK_EQ(Source<NavigationController>(source).ptr(),
navigation_controller_);
- OnCancel(dialog_);
+ navigation_controller_ = NULL;
+ Destroy();
}
}
@@ -99,29 +69,20 @@ void RepostFormWarningGtk::Destroy() {
gtk_widget_destroy(dialog_);
dialog_ = NULL;
}
- window_->CloseConstrainedWindow();
}
-void RepostFormWarningGtk::OnRefresh(GtkWidget* widget) {
- if (navigation_controller_) {
- navigation_controller_->ContinuePendingReload();
- // reloading the page will close the dialog.
+// static
+void RepostFormWarningGtk::OnResponse(GtkWidget* widget, int response,
+ RepostFormWarningGtk* dialog) {
+ dialog->Destroy();
+ if (response == GTK_RESPONSE_OK) {
+ if (dialog->navigation_controller_)
+ dialog->navigation_controller_->Reload(false);
}
}
-void RepostFormWarningGtk::OnCancel(GtkWidget* widget) {
- if (navigation_controller_) {
- navigation_controller_->CancelPendingReload();
- }
- Destroy();
+// static
+void RepostFormWarningGtk::OnWindowDestroy(GtkWidget* widget,
+ RepostFormWarningGtk* dialog) {
+ MessageLoop::current()->DeleteSoon(FROM_HERE, dialog);
}
-
-void RepostFormWarningGtk::OnHierarchyChanged(GtkWidget* root,
- GtkWidget* previous_toplevel) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
- if (!GTK_WIDGET_TOPLEVEL(gtk_widget_get_toplevel(cancel_))) {
- return;
- }
- gtk_widget_grab_focus(cancel_);
-}
-
diff --git a/chrome/browser/gtk/repost_form_warning_gtk.h b/chrome/browser/gtk/repost_form_warning_gtk.h
index 4382fbc..268b98e 100644
--- a/chrome/browser/gtk/repost_form_warning_gtk.h
+++ b/chrome/browser/gtk/repost_form_warning_gtk.h
@@ -8,26 +8,19 @@
#include <gtk/gtk.h>
#include "chrome/common/notification_registrar.h"
-#include "chrome/browser/gtk/constrained_window_gtk.h"
-#include "app/gtk_signal.h"
class NavigationController;
-class TabContents;
// Displays a dialog that warns the user that they are about to resubmit a form.
// 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 RepostFormWarningGtk : public NotificationObserver,
- ConstrainedWindowGtkDelegate {
+class RepostFormWarningGtk : public NotificationObserver {
public:
- RepostFormWarningGtk(GtkWindow* parent, TabContents* tab_contents);
+ RepostFormWarningGtk(GtkWindow* parent,
+ NavigationController* navigation_controller);
virtual ~RepostFormWarningGtk();
- virtual GtkWidget* GetWidgetRoot();
-
- virtual void DeleteDelegate();
-
private:
// NotificationObserver implementation.
// Watch for a new load or a closed tab and dismiss the dialog if they occur.
@@ -36,15 +29,13 @@ class RepostFormWarningGtk : public NotificationObserver,
const NotificationDetails& details);
// Tell Gtk to destroy the dialog window. This will only be done once, even
- // if Destroy is called multiple times.
+ // if Destroy is called multiple times (eg, from both OnResponse and Observe.)
void Destroy();
- CHROMEGTK_CALLBACK_0(RepostFormWarningGtk, void, OnRefresh);
- CHROMEGTK_CALLBACK_0(RepostFormWarningGtk, void, OnCancel);
- CHROMEGTK_CALLBACK_1(RepostFormWarningGtk,
- void,
- OnHierarchyChanged,
- GtkWidget*);
+ static void OnResponse(GtkWidget* widget,
+ int response,
+ RepostFormWarningGtk* dialog);
+ static void OnWindowDestroy(GtkWidget* widget, RepostFormWarningGtk* dialog);
NotificationRegistrar registrar_;
@@ -52,10 +43,6 @@ class RepostFormWarningGtk : public NotificationObserver,
NavigationController* navigation_controller_;
GtkWidget* dialog_;
- GtkWidget* ok_;
- GtkWidget* cancel_;
-
- ConstrainedWindow* window_;
DISALLOW_COPY_AND_ASSIGN(RepostFormWarningGtk);
};
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 21f78da..c8d3e95 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -1091,10 +1091,8 @@ void TabContents::WillClose(ConstrainedWindow* window) {
bool removed_topmost_window = it == child_windows_.begin();
if (it != child_windows_.end())
child_windows_.erase(it);
- if (child_windows_.size() > 0) {
- if (removed_topmost_window) {
- child_windows_[0]->ShowConstrainedWindow();
- }
+ if (removed_topmost_window && child_windows_.size() > 0) {
+ child_windows_[0]->ShowConstrainedWindow();
BlockTabContent(true);
} else {
BlockTabContent(false);