OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/simple_message_box.h" | 5 #include "chrome/browser/ui/simple_message_box.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 namespace chrome { | 26 namespace chrome { |
27 | 27 |
28 namespace { | 28 namespace { |
29 | 29 |
30 // Multiple SimpleMessageBoxViews can show up at the same time. Each of these | 30 // Multiple SimpleMessageBoxViews can show up at the same time. Each of these |
31 // start a nested message-loop. However, these SimpleMessageBoxViews can be | 31 // start a nested message-loop. However, these SimpleMessageBoxViews can be |
32 // deleted in any order. This creates problems if a box in an inner-loop gets | 32 // deleted in any order. This creates problems if a box in an inner-loop gets |
33 // destroyed before a box in an outer-loop. So to avoid this, ref-counting is | 33 // destroyed before a box in an outer-loop. So to avoid this, ref-counting is |
34 // used so that the SimpleMessageBoxViews gets deleted at the right time. | 34 // used so that the SimpleMessageBoxViews gets deleted at the right time. |
35 class SimpleMessageBoxViews : public views::DialogDelegate, | 35 class SimpleMessageBoxViews : public views::DialogDelegate, |
36 public MessageLoop::Dispatcher, | 36 public base::MessageLoop::Dispatcher, |
37 public base::RefCounted<SimpleMessageBoxViews> { | 37 public base::RefCounted<SimpleMessageBoxViews> { |
38 public: | 38 public: |
39 SimpleMessageBoxViews(const string16& title, | 39 SimpleMessageBoxViews(const string16& title, |
40 const string16& message, | 40 const string16& message, |
41 MessageBoxType type); | 41 MessageBoxType type); |
42 | 42 |
43 MessageBoxResult result() const { return result_; } | 43 MessageBoxResult result() const { return result_; } |
44 | 44 |
45 // Overridden from views::DialogDelegate: | 45 // Overridden from views::DialogDelegate: |
46 virtual int GetDialogButtons() const OVERRIDE; | 46 virtual int GetDialogButtons() const OVERRIDE; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 #if defined(USE_AURA) | 184 #if defined(USE_AURA) |
185 // Use the widget's window itself so that the message loop | 185 // Use the widget's window itself so that the message loop |
186 // exists when the dialog is closed by some other means than | 186 // exists when the dialog is closed by some other means than |
187 // |Cancel| or |Accept|. | 187 // |Cancel| or |Accept|. |
188 aura::Window* anchor = parent ? | 188 aura::Window* anchor = parent ? |
189 parent : dialog->GetWidget()->GetNativeWindow(); | 189 parent : dialog->GetWidget()->GetNativeWindow(); |
190 aura::client::GetDispatcherClient(anchor->GetRootWindow())-> | 190 aura::client::GetDispatcherClient(anchor->GetRootWindow())-> |
191 RunWithDispatcher(dialog, anchor, true); | 191 RunWithDispatcher(dialog, anchor, true); |
192 #else | 192 #else |
193 { | 193 { |
194 MessageLoop::ScopedNestableTaskAllower allow(MessageLoopForUI::current()); | 194 base::MessageLoop::ScopedNestableTaskAllower allow( |
| 195 base::MessageLoopForUI::current()); |
195 base::RunLoop run_loop(dialog); | 196 base::RunLoop run_loop(dialog); |
196 run_loop.Run(); | 197 run_loop.Run(); |
197 } | 198 } |
198 #endif | 199 #endif |
199 return dialog->result(); | 200 return dialog->result(); |
200 } | 201 } |
201 | 202 |
202 } // namespace chrome | 203 } // namespace chrome |
OLD | NEW |