Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: chrome/browser/repost_form_warning_dialog.cc

Issue 20066: Move resource_message_filter and resource_request_details to the renderer_hos... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/repost_form_warning_dialog.h"
6
7 #include "chrome/browser/browser_list.h"
8 #include "chrome/browser/tab_contents/navigation_controller.h"
9 #include "chrome/common/l10n_util.h"
10 #include "chrome/common/notification_service.h"
11 #include "chrome/views/message_box_view.h"
12 #include "chrome/views/window.h"
13
14 #include "generated_resources.h"
15
16 ///////////////////////////////////////////////////////////////////////////////
17 // RepostFormWarningDialog, public:
18
19 // static
20 void RepostFormWarningDialog::RunRepostFormWarningDialog(
21 NavigationController* navigation_controller) {
22 RepostFormWarningDialog* dialog =
23 new RepostFormWarningDialog(navigation_controller);
24 }
25
26 RepostFormWarningDialog::~RepostFormWarningDialog() {
27 NotificationService::current()->RemoveObserver(
28 this, NotificationType::LOAD_START, NotificationService::AllSources());
29 NotificationService::current()->RemoveObserver(
30 this, NotificationType::TAB_CLOSING, NotificationService::AllSources());
31 }
32
33 //////////////////////////////////////////////////////////////////////////////
34 // RepostFormWarningDialog, views::DialogDelegate implementation:
35
36 std::wstring RepostFormWarningDialog::GetWindowTitle() const {
37 return l10n_util::GetString(IDS_HTTP_POST_WARNING_TITLE);
38 }
39
40 std::wstring RepostFormWarningDialog::GetDialogButtonLabel(
41 DialogButton button) const {
42 if (button == DialogDelegate::DIALOGBUTTON_OK)
43 return l10n_util::GetString(IDS_HTTP_POST_WARNING_RESEND);
44 if (button == DialogDelegate::DIALOGBUTTON_CANCEL)
45 return l10n_util::GetString(IDS_HTTP_POST_WARNING_CANCEL);
46 return L"";
47 }
48
49 void RepostFormWarningDialog::WindowClosing() {
50 delete this;
51 }
52
53 bool RepostFormWarningDialog::Cancel() {
54 return true;
55 }
56
57 bool RepostFormWarningDialog::Accept() {
58 if (navigation_controller_)
59 navigation_controller_->Reload(false);
60 return true;
61 }
62
63 ///////////////////////////////////////////////////////////////////////////////
64 // RepostFormWarningDialog, views::WindowDelegate implementation:
65
66 views::View* RepostFormWarningDialog::GetContentsView() {
67 return message_box_view_;
68 }
69
70 ///////////////////////////////////////////////////////////////////////////////
71 // RepostFormWarningDialog, private:
72
73 RepostFormWarningDialog::RepostFormWarningDialog(
74 NavigationController* navigation_controller)
75 : navigation_controller_(navigation_controller),
76 message_box_view_(NULL) {
77 message_box_view_ = new MessageBoxView(
78 MessageBoxView::kIsConfirmMessageBox,
79 l10n_util::GetString(IDS_HTTP_POST_WARNING),
80 L"");
81 // TODO(beng): fix this - this dialog box should be shown by a method on the
82 // Browser.
83 HWND root_hwnd = NULL;
84 if (BrowserList::GetLastActive()) {
85 root_hwnd = reinterpret_cast<HWND>(BrowserList::GetLastActive()->
86 window()->GetNativeHandle());
87 }
88 views::Window::CreateChromeWindow(root_hwnd, gfx::Rect(), this)->Show();
89 NotificationService::current()->AddObserver(
90 this, NotificationType::LOAD_START, NotificationService::AllSources());
91 NotificationService::current()->AddObserver(
92 this, NotificationType::TAB_CLOSING, NotificationService::AllSources());
93 }
94
95 void RepostFormWarningDialog::Observe(NotificationType type,
96 const NotificationSource& source,
97 const NotificationDetails& details) {
98 // Close the dialog if we load a page (because reloading might not apply to
99 // the same page anymore) or if the tab is closed, because then we won't have
100 // a navigation controller anymore.
101 if (window() && navigation_controller_ &&
102 (type == NotificationType::LOAD_START ||
103 type == NotificationType::TAB_CLOSING) &&
104 Source<NavigationController>(source).ptr() == navigation_controller_) {
105 navigation_controller_ = NULL;
106 window()->Close();
107 }
108 }
109
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698