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

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

Powered by Google App Engine
This is Rietveld 408576698