OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/base/message_box_win.h" |
| 6 |
| 7 #include <windows.h> |
| 8 |
| 9 #include "base/base_switches.h" |
| 10 #include "base/command_line.h" |
| 11 #include "base/i18n/rtl.h" |
| 12 #include "base/string16.h" |
| 13 |
| 14 namespace ui { |
| 15 |
| 16 // In addition to passing the RTL flags to ::MessageBox if we are running in an |
| 17 // RTL locale, we need to make sure that LTR strings are rendered correctly by |
| 18 // adding the appropriate Unicode directionality marks. |
| 19 int MessageBox(HWND hwnd, |
| 20 const string16& text, |
| 21 const string16& caption, |
| 22 UINT flags) { |
| 23 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoMessageBox)) |
| 24 return IDOK; |
| 25 |
| 26 UINT actual_flags = flags; |
| 27 if (base::i18n::IsRTL()) |
| 28 actual_flags |= MB_RIGHT | MB_RTLREADING; |
| 29 |
| 30 string16 localized_text = text; |
| 31 base::i18n::AdjustStringForLocaleDirection(&localized_text); |
| 32 const wchar_t* text_ptr = localized_text.c_str(); |
| 33 |
| 34 string16 localized_caption = caption; |
| 35 base::i18n::AdjustStringForLocaleDirection(&localized_caption); |
| 36 const wchar_t* caption_ptr = localized_caption.c_str(); |
| 37 |
| 38 return ::MessageBox(hwnd, text_ptr, caption_ptr, actual_flags); |
| 39 } |
| 40 |
| 41 } // namespace ui |
OLD | NEW |