OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "base/logging.h" | 5 #include "base/logging.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <io.h> | 8 #include <io.h> |
9 #include <windows.h> | 9 #include <windows.h> |
10 typedef HANDLE FileHandle; | 10 typedef HANDLE FileHandle; |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 log_message_handler = handler; | 318 log_message_handler = handler; |
319 } | 319 } |
320 | 320 |
321 | 321 |
322 // Displays a message box to the user with the error message in it. | 322 // Displays a message box to the user with the error message in it. |
323 // Used for fatal messages, where we close the app simultaneously. | 323 // Used for fatal messages, where we close the app simultaneously. |
324 void DisplayDebugMessageInDialog(const std::string& str) { | 324 void DisplayDebugMessageInDialog(const std::string& str) { |
325 if (str.empty()) | 325 if (str.empty()) |
326 return; | 326 return; |
327 | 327 |
| 328 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoErrorDialogs)) |
| 329 return; |
| 330 |
328 #if defined(OS_WIN) | 331 #if defined(OS_WIN) |
329 // For Windows programs, it's possible that the message loop is | 332 // For Windows programs, it's possible that the message loop is |
330 // messed up on a fatal error, and creating a MessageBox will cause | 333 // messed up on a fatal error, and creating a MessageBox will cause |
331 // that message loop to be run. Instead, we try to spawn another | 334 // that message loop to be run. Instead, we try to spawn another |
332 // process that displays its command line. We look for "Debug | 335 // process that displays its command line. We look for "Debug |
333 // Message.exe" in the same directory as the application. If it | 336 // Message.exe" in the same directory as the application. If it |
334 // exists, we use it, otherwise, we use a regular message box. | 337 // exists, we use it, otherwise, we use a regular message box. |
335 wchar_t prog_name[MAX_PATH]; | 338 wchar_t prog_name[MAX_PATH]; |
336 GetModuleFileNameW(NULL, prog_name, MAX_PATH); | 339 GetModuleFileNameW(NULL, prog_name, MAX_PATH); |
337 wchar_t* backslash = wcsrchr(prog_name, '\\'); | 340 wchar_t* backslash = wcsrchr(prog_name, '\\'); |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 | 724 |
722 if (level == LOG_FATAL) | 725 if (level == LOG_FATAL) |
723 DebugUtil::BreakDebugger(); | 726 DebugUtil::BreakDebugger(); |
724 } | 727 } |
725 | 728 |
726 } // namespace logging | 729 } // namespace logging |
727 | 730 |
728 std::ostream& operator<<(std::ostream& out, const wchar_t* wstr) { | 731 std::ostream& operator<<(std::ostream& out, const wchar_t* wstr) { |
729 return out << WideToUTF8(std::wstring(wstr)); | 732 return out << WideToUTF8(std::wstring(wstr)); |
730 } | 733 } |
OLD | NEW |