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

Unified Diff: chrome/browser/ui/views/simple_message_box_views.cc

Issue 182753002: Revert of Use the default dispatcher where possible for nested message loops. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/first_run_dialog.cc ('k') | ui/aura/client/dispatcher_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/simple_message_box_views.cc
diff --git a/chrome/browser/ui/views/simple_message_box_views.cc b/chrome/browser/ui/views/simple_message_box_views.cc
index fbed7d9068997964eca32f356caa67c21baa4981..8deeebc76fac75a1d1cf8f6a64aaa267f072d795 100644
--- a/chrome/browser/ui/views/simple_message_box_views.cc
+++ b/chrome/browser/ui/views/simple_message_box_views.cc
@@ -37,6 +37,7 @@
// destroyed before a box in an outer-loop. So to avoid this, ref-counting is
// used so that the SimpleMessageBoxViews gets deleted at the right time.
class SimpleMessageBoxViews : public views::DialogDelegate,
+ public base::MessagePumpDispatcher,
public base::RefCounted<SimpleMessageBoxViews> {
public:
SimpleMessageBoxViews(const base::string16& title,
@@ -62,12 +63,12 @@
virtual views::Widget* GetWidget() OVERRIDE;
virtual const views::Widget* GetWidget() const OVERRIDE;
+ // Overridden from MessagePumpDispatcher:
+ virtual uint32_t Dispatch(const base::NativeEvent& event) OVERRIDE;
+
private:
friend class base::RefCounted<SimpleMessageBoxViews>;
virtual ~SimpleMessageBoxViews();
-
- // This terminates the nested message-loop.
- void Done();
const base::string16 window_title_;
const MessageBoxType type_;
@@ -75,6 +76,10 @@
base::string16 no_text_;
MessageBoxResult result_;
views::MessageBoxView* message_box_view_;
+
+ // Set to false as soon as the user clicks a dialog button; this tells the
+ // dispatcher we're done.
+ bool should_show_dialog_;
DISALLOW_COPY_AND_ASSIGN(SimpleMessageBoxViews);
};
@@ -93,7 +98,8 @@
no_text_(no_text),
result_(MESSAGE_BOX_RESULT_NO),
message_box_view_(new views::MessageBoxView(
- views::MessageBoxView::InitParams(message))) {
+ views::MessageBoxView::InitParams(message))),
+ should_show_dialog_(true) {
AddRef();
if (yes_text_.empty()) {
@@ -132,14 +138,14 @@
}
bool SimpleMessageBoxViews::Cancel() {
+ should_show_dialog_= false;
result_ = MESSAGE_BOX_RESULT_NO;
- Done();
return true;
}
bool SimpleMessageBoxViews::Accept() {
+ should_show_dialog_ = false;
result_ = MESSAGE_BOX_RESULT_YES;
- Done();
return true;
}
@@ -165,6 +171,13 @@
const views::Widget* SimpleMessageBoxViews::GetWidget() const {
return message_box_view_->GetWidget();
+}
+
+uint32_t SimpleMessageBoxViews::Dispatch(const base::NativeEvent& event) {
+ uint32_t action = POST_DISPATCH_PERFORM_DEFAULT;
+ if (!should_show_dialog_)
+ action |= POST_DISPATCH_QUIT_LOOP;
+ return action;
}
////////////////////////////////////////////////////////////////////////////////
@@ -190,13 +203,6 @@
return flags | MB_OK | MB_ICONWARNING;
}
#endif
-
-void SimpleMessageBoxViews::Done() {
- aura::Window* window = GetWidget()->GetNativeView();
- aura::client::DispatcherClient* client =
- aura::client::GetDispatcherClient(window->GetRootWindow());
- client->QuitNestedMessageLoop();
-}
MessageBoxResult ShowMessageBoxImpl(gfx::NativeWindow parent,
const base::string16& title,
@@ -228,7 +234,7 @@
anchor = dialog->GetWidget()->GetNativeWindow();
client = aura::client::GetDispatcherClient(anchor->GetRootWindow());
}
- client->RunWithDispatcher(NULL, anchor);
+ client->RunWithDispatcher(dialog.get(), anchor);
return dialog->result();
}
« no previous file with comments | « chrome/browser/ui/views/first_run_dialog.cc ('k') | ui/aura/client/dispatcher_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698