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

Side by Side Diff: chrome/browser/ui/views/simple_message_box_views.cc

Issue 2818533003: Make nesting/running states a RunLoop rather than a MessageLoop concept. (Closed)
Patch Set: fix compile and add RunLoopTests Created 3 years, 8 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 unified diff | Download patch
OLDNEW
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/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 const base::string16& no_text, 215 const base::string16& no_text,
216 const base::string16& checkbox_text) { 216 const base::string16& checkbox_text) {
217 startup_metric_utils::SetNonBrowserUIDisplayed(); 217 startup_metric_utils::SetNonBrowserUIDisplayed();
218 if (internal::g_should_skip_message_box_for_test) 218 if (internal::g_should_skip_message_box_for_test)
219 return MESSAGE_BOX_RESULT_YES; 219 return MESSAGE_BOX_RESULT_YES;
220 220
221 // Views dialogs cannot be shown outside the UI thread message loop or if the 221 // Views dialogs cannot be shown outside the UI thread message loop or if the
222 // ResourceBundle is not initialized yet. 222 // ResourceBundle is not initialized yet.
223 // Fallback to logging with a default response or a Windows MessageBox. 223 // Fallback to logging with a default response or a Windows MessageBox.
224 #if defined(OS_WIN) 224 #if defined(OS_WIN)
225 if (!base::MessageLoopForUI::IsCurrent() || 225 if (!base::RunLoop::IsRunningOnCurrentThread() ||
226 !base::MessageLoopForUI::current()->is_running() ||
227 !ResourceBundle::HasSharedInstance()) { 226 !ResourceBundle::HasSharedInstance()) {
228 LOG_IF(ERROR, !checkbox_text.empty()) << "Dialog checkbox won't be shown"; 227 LOG_IF(ERROR, !checkbox_text.empty()) << "Dialog checkbox won't be shown";
229 int result = ui::MessageBox(views::HWNDForNativeWindow(parent), message, 228 int result = ui::MessageBox(views::HWNDForNativeWindow(parent), message,
230 title, GetMessageBoxFlagsFromType(type)); 229 title, GetMessageBoxFlagsFromType(type));
231 return (result == IDYES || result == IDOK) ? 230 return (result == IDYES || result == IDOK) ?
232 MESSAGE_BOX_RESULT_YES : MESSAGE_BOX_RESULT_NO; 231 MESSAGE_BOX_RESULT_YES : MESSAGE_BOX_RESULT_NO;
233 } 232 }
234 #else 233 #else
235 if (!base::MessageLoopForUI::IsCurrent() || 234 if (!base::MessageLoopForUI::IsCurrent() ||
236 !ResourceBundle::HasSharedInstance()) { 235 !ResourceBundle::HasSharedInstance()) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 MessageBoxResult ShowMessageBoxWithButtonText(gfx::NativeWindow parent, 289 MessageBoxResult ShowMessageBoxWithButtonText(gfx::NativeWindow parent,
291 const base::string16& title, 290 const base::string16& title,
292 const base::string16& message, 291 const base::string16& message,
293 const base::string16& yes_text, 292 const base::string16& yes_text,
294 const base::string16& no_text) { 293 const base::string16& no_text) {
295 return ShowMessageBoxImpl(parent, title, message, MESSAGE_BOX_TYPE_QUESTION, 294 return ShowMessageBoxImpl(parent, title, message, MESSAGE_BOX_TYPE_QUESTION,
296 yes_text, no_text, base::string16()); 295 yes_text, no_text, base::string16());
297 } 296 }
298 297
299 } // namespace chrome 298 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698