| 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" |
| 11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/ui/views/constrained_window_views.h" |
| 13 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
| 15 #include "ui/gfx/native_widget_types.h" | 16 #include "ui/gfx/native_widget_types.h" |
| 16 #include "ui/views/controls/message_box_view.h" | 17 #include "ui/views/controls/message_box_view.h" |
| 17 #include "ui/views/widget/widget.h" | 18 #include "ui/views/widget/widget.h" |
| 18 #include "ui/views/window/dialog_delegate.h" | 19 #include "ui/views/window/dialog_delegate.h" |
| 19 | 20 |
| 20 #if defined(USE_AURA) | 21 #if defined(USE_AURA) |
| 21 #include "ui/aura/client/dispatcher_client.h" | 22 #include "ui/aura/client/dispatcher_client.h" |
| 22 #include "ui/aura/env.h" | 23 #include "ui/aura/env.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 } | 169 } |
| 169 | 170 |
| 170 } // namespace | 171 } // namespace |
| 171 | 172 |
| 172 MessageBoxResult ShowMessageBox(gfx::NativeWindow parent, | 173 MessageBoxResult ShowMessageBox(gfx::NativeWindow parent, |
| 173 const string16& title, | 174 const string16& title, |
| 174 const string16& message, | 175 const string16& message, |
| 175 MessageBoxType type) { | 176 MessageBoxType type) { |
| 176 scoped_refptr<SimpleMessageBoxViews> dialog( | 177 scoped_refptr<SimpleMessageBoxViews> dialog( |
| 177 new SimpleMessageBoxViews(title, message, type)); | 178 new SimpleMessageBoxViews(title, message, type)); |
| 178 views::DialogDelegate::CreateDialogWidget(dialog, NULL, parent)->Show(); | 179 CreateBrowserModalDialogViews(dialog, parent)->Show(); |
| 179 | 180 |
| 180 #if defined(USE_AURA) | 181 #if defined(USE_AURA) |
| 181 // Use the widget's window itself so that the message loop | 182 // Use the widget's window itself so that the message loop |
| 182 // exists when the dialog is closed by some other means than | 183 // exists when the dialog is closed by some other means than |
| 183 // |Cancel| or |Accept|. | 184 // |Cancel| or |Accept|. |
| 184 aura::Window* anchor = parent ? | 185 aura::Window* anchor = parent ? |
| 185 parent : dialog->GetWidget()->GetNativeWindow(); | 186 parent : dialog->GetWidget()->GetNativeWindow(); |
| 186 aura::client::GetDispatcherClient(anchor->GetRootWindow())-> | 187 aura::client::GetDispatcherClient(anchor->GetRootWindow())-> |
| 187 RunWithDispatcher(dialog, anchor, true); | 188 RunWithDispatcher(dialog, anchor, true); |
| 188 #else | 189 #else |
| 189 { | 190 { |
| 190 base::MessageLoop::ScopedNestableTaskAllower allow( | 191 base::MessageLoop::ScopedNestableTaskAllower allow( |
| 191 base::MessageLoopForUI::current()); | 192 base::MessageLoopForUI::current()); |
| 192 base::RunLoop run_loop(dialog); | 193 base::RunLoop run_loop(dialog); |
| 193 run_loop.Run(); | 194 run_loop.Run(); |
| 194 } | 195 } |
| 195 #endif | 196 #endif |
| 196 return dialog->result(); | 197 return dialog->result(); |
| 197 } | 198 } |
| 198 | 199 |
| 199 } // namespace chrome | 200 } // namespace chrome |
| OLD | NEW |