diff options
author | mattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-28 22:47:11 +0000 |
---|---|---|
committer | mattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-28 22:47:11 +0000 |
commit | 0bb17f3457fc494b9711ce6580571c1bc7dacf57 (patch) | |
tree | f5ce47ae31942fce886a45d36ede9b5de357c14e /chrome/browser/views | |
parent | 02525bc37fe1722c8b38af1d6087bf286e075bf9 (diff) | |
download | chromium_src-0bb17f3457fc494b9711ce6580571c1bc7dacf57.zip chromium_src-0bb17f3457fc494b9711ce6580571c1bc7dacf57.tar.gz chromium_src-0bb17f3457fc494b9711ce6580571c1bc7dacf57.tar.bz2 |
Gtk confirm form resubmission dialog.
Refactor so that the dialog is shown by calling BrowserWindow::ShowRepostFormWarningDialog
BUG=19761
TEST=see bug
Review URL: http://codereview.chromium.org/174294
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24826 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r-- | chrome/browser/views/frame/browser_view.cc | 5 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.h | 1 | ||||
-rw-r--r-- | chrome/browser/views/repost_form_warning_view.cc | 26 | ||||
-rw-r--r-- | chrome/browser/views/repost_form_warning_view.h | 6 |
4 files changed, 17 insertions, 21 deletions
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index 6dc9adf..f9a627b 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -35,6 +35,7 @@ #include "chrome/browser/views/frame/browser_frame.h" #include "chrome/browser/views/fullscreen_exit_bubble.h" #include "chrome/browser/views/infobars/infobar_container.h" +#include "chrome/browser/views/repost_form_warning_view.h" #include "chrome/browser/views/status_bubble_views.h" #include "chrome/browser/views/tab_contents/tab_contents_container.h" #include "chrome/browser/views/tabs/browser_tab_strip.h" @@ -929,6 +930,10 @@ void BrowserView::ShowNewProfileDialog() { browser::ShowNewProfileDialog(); } +void BrowserView::ShowRepostFormWarningDialog(TabContents* tab_contents) { + new RepostFormWarningView(GetNativeHandle(), &tab_contents->controller()); +} + void BrowserView::ConfirmBrowserCloseWithPendingDownloads() { DownloadInProgressConfirmDialogDelegate* delegate = new DownloadInProgressConfirmDialogDelegate(browser_.get()); diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h index d978c51..e59c8aa 100644 --- a/chrome/browser/views/frame/browser_view.h +++ b/chrome/browser/views/frame/browser_view.h @@ -243,6 +243,7 @@ class BrowserView : public BrowserWindow, virtual void ShowPasswordManager(); virtual void ShowSelectProfileDialog(); virtual void ShowNewProfileDialog(); + virtual void ShowRepostFormWarningDialog(TabContents* tab_contents); virtual void ConfirmBrowserCloseWithPendingDownloads(); virtual void ShowHTMLDialog(HtmlDialogUIDelegate* delegate, gfx::NativeWindow parent_window); diff --git a/chrome/browser/views/repost_form_warning_view.cc b/chrome/browser/views/repost_form_warning_view.cc index c9ef167..074850d7 100644 --- a/chrome/browser/views/repost_form_warning_view.cc +++ b/chrome/browser/views/repost_form_warning_view.cc @@ -14,14 +14,8 @@ #include "views/controls/message_box_view.h" #include "views/window/window.h" -// Implementation of function declared in -// browser/tab_contents/repost_form_warning.h -void RunRepostFormWarningDialog(NavigationController* navigation_controller) { - RepostFormWarningView* dialog = - new RepostFormWarningView(navigation_controller); -} - RepostFormWarningView::RepostFormWarningView( + gfx::NativeWindow parent_window, NavigationController* navigation_controller) : navigation_controller_(navigation_controller), message_box_view_(NULL) { @@ -29,19 +23,12 @@ RepostFormWarningView::RepostFormWarningView( MessageBoxFlags::kIsConfirmMessageBox, l10n_util::GetString(IDS_HTTP_POST_WARNING), L""); - // TODO(beng): fix this - this dialog box should be shown by a method on the - // Browser. - HWND root_hwnd = NULL; - if (BrowserList::GetLastActive()) { - root_hwnd = reinterpret_cast<HWND>(BrowserList::GetLastActive()-> - window()->GetNativeHandle()); - } - views::Window::CreateChromeWindow(root_hwnd, gfx::Rect(), this)->Show(); + views::Window::CreateChromeWindow(parent_window, gfx::Rect(), this)->Show(); registrar_.Add(this, NotificationType::LOAD_START, - NotificationService::AllSources()); + Source<NavigationController>(navigation_controller_)); registrar_.Add(this, NotificationType::TAB_CLOSING, - NotificationService::AllSources()); + Source<NavigationController>(navigation_controller_)); } RepostFormWarningView::~RepostFormWarningView() { @@ -95,8 +82,9 @@ void RepostFormWarningView::Observe(NotificationType type, // a navigation controller anymore. if (window() && navigation_controller_ && (type == NotificationType::LOAD_START || - type == NotificationType::TAB_CLOSING) && - Source<NavigationController>(source).ptr() == navigation_controller_) { + type == NotificationType::TAB_CLOSING)) { + DCHECK_EQ(Source<NavigationController>(source).ptr(), + navigation_controller_); navigation_controller_ = NULL; window()->Close(); } diff --git a/chrome/browser/views/repost_form_warning_view.h b/chrome/browser/views/repost_form_warning_view.h index 40db8ac..3c8538b 100644 --- a/chrome/browser/views/repost_form_warning_view.h +++ b/chrome/browser/views/repost_form_warning_view.h @@ -5,6 +5,7 @@ #ifndef CHROME_BROWSER_VIEWS_REPOST_FORM_WARNING_VIEW_H_ #define CHROME_BROWSER_VIEWS_REPOST_FORM_WARNING_VIEW_H_ +#include "base/gfx/native_widget_types.h" #include "chrome/common/notification_registrar.h" #include "views/window/dialog_delegate.h" @@ -17,8 +18,9 @@ class Window; class RepostFormWarningView : public views::DialogDelegate, public NotificationObserver { public: - // Use RunRepostFormWarningDialog (declared in repost_form_warning.h) to use. - RepostFormWarningView(NavigationController* navigation_controller); + // Use BrowserWindow::ShowRepostFormWarningDialog to use. + RepostFormWarningView(gfx::NativeWindow parent_window, + NavigationController* navigation_controller); virtual ~RepostFormWarningView(); // views::DialogDelegate Methods: |