| 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 } | 168 } |
| 169 | 169 |
| 170 } // namespace | 170 } // namespace |
| 171 | 171 |
| 172 MessageBoxResult ShowMessageBox(gfx::NativeWindow parent, | 172 MessageBoxResult ShowMessageBox(gfx::NativeWindow parent, |
| 173 const string16& title, | 173 const string16& title, |
| 174 const string16& message, | 174 const string16& message, |
| 175 MessageBoxType type) { | 175 MessageBoxType type) { |
| 176 scoped_refptr<SimpleMessageBoxViews> dialog( | 176 scoped_refptr<SimpleMessageBoxViews> dialog( |
| 177 new SimpleMessageBoxViews(title, message, type)); | 177 new SimpleMessageBoxViews(title, message, type)); |
| 178 | 178 views::DialogDelegate::CreateDialogWidget(dialog, NULL, parent)->Show(); |
| 179 if (parent) | |
| 180 views::Widget::CreateWindowWithParent(dialog, parent)->Show(); | |
| 181 else | |
| 182 views::Widget::CreateWindow(dialog)->Show(); | |
| 183 | 179 |
| 184 #if defined(USE_AURA) | 180 #if defined(USE_AURA) |
| 185 // Use the widget's window itself so that the message loop | 181 // Use the widget's window itself so that the message loop |
| 186 // exists when the dialog is closed by some other means than | 182 // exists when the dialog is closed by some other means than |
| 187 // |Cancel| or |Accept|. | 183 // |Cancel| or |Accept|. |
| 188 aura::Window* anchor = parent ? | 184 aura::Window* anchor = parent ? |
| 189 parent : dialog->GetWidget()->GetNativeWindow(); | 185 parent : dialog->GetWidget()->GetNativeWindow(); |
| 190 aura::client::GetDispatcherClient(anchor->GetRootWindow())-> | 186 aura::client::GetDispatcherClient(anchor->GetRootWindow())-> |
| 191 RunWithDispatcher(dialog, anchor, true); | 187 RunWithDispatcher(dialog, anchor, true); |
| 192 #else | 188 #else |
| 193 { | 189 { |
| 194 base::MessageLoop::ScopedNestableTaskAllower allow( | 190 base::MessageLoop::ScopedNestableTaskAllower allow( |
| 195 base::MessageLoopForUI::current()); | 191 base::MessageLoopForUI::current()); |
| 196 base::RunLoop run_loop(dialog); | 192 base::RunLoop run_loop(dialog); |
| 197 run_loop.Run(); | 193 run_loop.Run(); |
| 198 } | 194 } |
| 199 #endif | 195 #endif |
| 200 return dialog->result(); | 196 return dialog->result(); |
| 201 } | 197 } |
| 202 | 198 |
| 203 } // namespace chrome | 199 } // namespace chrome |
| OLD | NEW |