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

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

Issue 113932: Clean-up of the app modal dialog queue (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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
« no previous file with comments | « no previous file | chrome/browser/app_modal_dialog_queue.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/app_modal_dialog.h" 5 #include "chrome/browser/app_modal_dialog.h"
6 6
7 #include "chrome/browser/app_modal_dialog_queue.h" 7 #include "chrome/browser/app_modal_dialog_queue.h"
8 #include "chrome/browser/tab_contents/tab_contents.h" 8 #include "chrome/browser/tab_contents/tab_contents.h"
9 #include "chrome/common/notification_service.h" 9 #include "chrome/common/notification_service.h"
10 #include "chrome/common/notification_type.h" 10 #include "chrome/common/notification_type.h"
11 #include "chrome/common/ipc_message.h" 11 #include "chrome/common/ipc_message.h"
12 12
13 AppModalDialog::AppModalDialog(TabContents* tab_contents, 13 AppModalDialog::AppModalDialog(TabContents* tab_contents,
14 const std::wstring& title, 14 const std::wstring& title,
15 int dialog_flags, 15 int dialog_flags,
16 const std::wstring& message_text, 16 const std::wstring& message_text,
17 const std::wstring& default_prompt_text, 17 const std::wstring& default_prompt_text,
18 bool display_suppress_checkbox, 18 bool display_suppress_checkbox,
19 bool is_before_unload_dialog, 19 bool is_before_unload_dialog,
20 IPC::Message* reply_msg) 20 IPC::Message* reply_msg)
21 : tab_contents_(tab_contents), 21 : dialog_(NULL),
22 tab_contents_(tab_contents),
22 title_(title), 23 title_(title),
23 dialog_flags_(dialog_flags), 24 dialog_flags_(dialog_flags),
24 message_text_(message_text), 25 message_text_(message_text),
25 default_prompt_text_(default_prompt_text), 26 default_prompt_text_(default_prompt_text),
26 display_suppress_checkbox_(display_suppress_checkbox), 27 display_suppress_checkbox_(display_suppress_checkbox),
27 is_before_unload_dialog_(is_before_unload_dialog), 28 is_before_unload_dialog_(is_before_unload_dialog),
28 reply_msg_(reply_msg) { 29 reply_msg_(reply_msg) {
29 InitNotifications(); 30 InitNotifications();
30 } 31 }
31 32
(...skipping 23 matching lines...) Expand all
55 registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED, 56 registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED,
56 NotificationService::AllSources()); 57 NotificationService::AllSources());
57 registrar_.Add(this, NotificationType::TAB_CONTENTS_DESTROYED, 58 registrar_.Add(this, NotificationType::TAB_CONTENTS_DESTROYED,
58 NotificationService::AllSources()); 59 NotificationService::AllSources());
59 } 60 }
60 61
61 void AppModalDialog::ShowModalDialog() { 62 void AppModalDialog::ShowModalDialog() {
62 // If the TabContents that created this dialog navigated away before this 63 // If the TabContents that created this dialog navigated away before this
63 // dialog became visible, simply show the next dialog if any. 64 // dialog became visible, simply show the next dialog if any.
64 if (!tab_contents_) { 65 if (!tab_contents_) {
65 AppModalDialogQueue::ShowNextDialog(); 66 Singleton<AppModalDialogQueue>()->ShowNextDialog();
66 delete this; 67 delete this;
67 return; 68 return;
68 } 69 }
69 70
70 tab_contents_->Activate(); 71 tab_contents_->Activate();
71 CreateAndShowDialog(); 72 CreateAndShowDialog();
72 } 73 }
73 74
74 void AppModalDialog::OnCancel() { 75 void AppModalDialog::OnCancel() {
75 // We need to do this before WM_DESTROY (WindowClosing()) as any parent frame 76 // We need to do this before WM_DESTROY (WindowClosing()) as any parent frame
76 // will receive it's activation messages before this dialog receives 77 // will receive it's activation messages before this dialog receives
77 // WM_DESTROY. The parent frame would then try to activate any modal dialogs 78 // WM_DESTROY. The parent frame would then try to activate any modal dialogs
78 // that were still open in the ModalDialogQueue, which would send activation 79 // that were still open in the ModalDialogQueue, which would send activation
79 // back to this one. The framework should be improved to handle this, so this 80 // back to this one. The framework should be improved to handle this, so this
80 // is a temporary workaround. 81 // is a temporary workaround.
81 AppModalDialogQueue::ShowNextDialog(); 82 Singleton<AppModalDialogQueue>()->ShowNextDialog();
82 83
83 if (tab_contents_) { 84 if (tab_contents_) {
84 tab_contents_->OnJavaScriptMessageBoxClosed(reply_msg_, false, 85 tab_contents_->OnJavaScriptMessageBoxClosed(reply_msg_, false,
85 std::wstring()); 86 std::wstring());
86 } 87 }
87 } 88 }
88 89
89 void AppModalDialog::OnAccept(const std::wstring& prompt_text, 90 void AppModalDialog::OnAccept(const std::wstring& prompt_text,
90 bool suppress_js_messages) { 91 bool suppress_js_messages) {
91 AppModalDialogQueue::ShowNextDialog(); 92 Singleton<AppModalDialogQueue>()->ShowNextDialog();
92 93
93 if (tab_contents_) { 94 if (tab_contents_) {
94 tab_contents_->OnJavaScriptMessageBoxClosed(reply_msg_, true, 95 tab_contents_->OnJavaScriptMessageBoxClosed(reply_msg_, true,
95 prompt_text); 96 prompt_text);
96 97
97 if (suppress_js_messages) 98 if (suppress_js_messages)
98 tab_contents()->set_suppress_javascript_messages(true); 99 tab_contents()->set_suppress_javascript_messages(true);
99 } 100 }
100 } 101 }
101 102
102 void AppModalDialog::OnClose() { 103 void AppModalDialog::OnClose() {
103 if (tab_contents_) { 104 if (tab_contents_) {
104 tab_contents_->OnJavaScriptMessageBoxWindowDestroyed(); 105 tab_contents_->OnJavaScriptMessageBoxWindowDestroyed();
105 } 106 }
106 } 107 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/app_modal_dialog_queue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698