| 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 "ui/base/win/message_box_win.h" | 5 #include "ui/base/win/message_box_win.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
| 9 #include "ui/base/ui_base_switches.h" | 9 #include "ui/base/ui_base_switches.h" |
| 10 | 10 |
| 11 namespace ui { | 11 namespace ui { |
| 12 | 12 |
| 13 // In addition to passing the RTL flags to ::MessageBox if we are running in an | 13 // In addition to passing the RTL flags to ::MessageBox if we are running in an |
| 14 // RTL locale, we need to make sure that LTR strings are rendered correctly by | 14 // RTL locale, we need to make sure that LTR strings are rendered correctly by |
| 15 // adding the appropriate Unicode directionality marks. | 15 // adding the appropriate Unicode directionality marks. |
| 16 int MessageBox(HWND hwnd, | 16 int MessageBox(HWND hwnd, |
| 17 const string16& text, | 17 const base::string16& text, |
| 18 const string16& caption, | 18 const base::string16& caption, |
| 19 UINT flags) { | 19 UINT flags) { |
| 20 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoMessageBox)) | 20 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoMessageBox)) |
| 21 return IDOK; | 21 return IDOK; |
| 22 | 22 |
| 23 UINT actual_flags = flags; | 23 UINT actual_flags = flags; |
| 24 if (base::i18n::IsRTL()) | 24 if (base::i18n::IsRTL()) |
| 25 actual_flags |= MB_RIGHT | MB_RTLREADING; | 25 actual_flags |= MB_RIGHT | MB_RTLREADING; |
| 26 | 26 |
| 27 string16 localized_text = text; | 27 base::string16 localized_text = text; |
| 28 base::i18n::AdjustStringForLocaleDirection(&localized_text); | 28 base::i18n::AdjustStringForLocaleDirection(&localized_text); |
| 29 const wchar_t* text_ptr = localized_text.c_str(); | 29 const wchar_t* text_ptr = localized_text.c_str(); |
| 30 | 30 |
| 31 string16 localized_caption = caption; | 31 base::string16 localized_caption = caption; |
| 32 base::i18n::AdjustStringForLocaleDirection(&localized_caption); | 32 base::i18n::AdjustStringForLocaleDirection(&localized_caption); |
| 33 const wchar_t* caption_ptr = localized_caption.c_str(); | 33 const wchar_t* caption_ptr = localized_caption.c_str(); |
| 34 | 34 |
| 35 return ::MessageBox(hwnd, text_ptr, caption_ptr, actual_flags); | 35 return ::MessageBox(hwnd, text_ptr, caption_ptr, actual_flags); |
| 36 } | 36 } |
| 37 | 37 |
| 38 } // namespace ui | 38 } // namespace ui |
| OLD | NEW |