Chromium Code Reviews| 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 | 160 |
| 161 } // namespace | 161 } // namespace |
| 162 | 162 |
| 163 MessageBoxResult ShowMessageBox(gfx::NativeWindow parent, | 163 MessageBoxResult ShowMessageBox(gfx::NativeWindow parent, |
| 164 const string16& title, | 164 const string16& title, |
| 165 const string16& message, | 165 const string16& message, |
| 166 MessageBoxType type) { | 166 MessageBoxType type) { |
| 167 scoped_refptr<SimpleMessageBoxViews> dialog( | 167 scoped_refptr<SimpleMessageBoxViews> dialog( |
| 168 new SimpleMessageBoxViews(title, message, type)); | 168 new SimpleMessageBoxViews(title, message, type)); |
| 169 | 169 |
| 170 views::Widget::CreateWindowWithParent(dialog, parent)->Show(); | 170 if (parent) |
| 171 views::Widget::CreateWindowWithParent(dialog, parent)->Show(); | |
| 172 else | |
| 173 views::Widget::CreateWindow(dialog)->Show(); | |
|
Elliot Glaysher
2013/01/14 23:15:19
This is a common thing that I've found: an interfa
Ben Goodger (Google)
2013/01/15 18:19:52
Yeah see my comment on the earlier file.
| |
| 171 | 174 |
| 172 #if defined(USE_AURA) | 175 #if defined(USE_AURA) |
| 173 // Use the widget's window itself so that the message loop | 176 // Use the widget's window itself so that the message loop |
| 174 // exists when the dialog is closed by some other means than | 177 // exists when the dialog is closed by some other means than |
| 175 // |Cancel| or |Accept|. | 178 // |Cancel| or |Accept|. |
| 176 aura::Window* anchor = parent ? | 179 aura::Window* anchor = parent ? |
| 177 parent : dialog->GetWidget()->GetNativeWindow(); | 180 parent : dialog->GetWidget()->GetNativeWindow(); |
| 178 aura::client::GetDispatcherClient(anchor->GetRootWindow())-> | 181 aura::client::GetDispatcherClient(anchor->GetRootWindow())-> |
| 179 RunWithDispatcher(dialog, anchor, true); | 182 RunWithDispatcher(dialog, anchor, true); |
| 180 #else | 183 #else |
| 181 { | 184 { |
| 182 MessageLoop::ScopedNestableTaskAllower allow(MessageLoopForUI::current()); | 185 MessageLoop::ScopedNestableTaskAllower allow(MessageLoopForUI::current()); |
| 183 base::RunLoop run_loop(dialog); | 186 base::RunLoop run_loop(dialog); |
| 184 run_loop.Run(); | 187 run_loop.Run(); |
| 185 } | 188 } |
| 186 #endif | 189 #endif |
| 187 return dialog->result(); | 190 return dialog->result(); |
| 188 } | 191 } |
| 189 | 192 |
| 190 } // namespace chrome | 193 } // namespace chrome |
| OLD | NEW |