OLD | NEW |
1 // Copyright (c) 2011 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/message_box_win.h" | 5 #include "ui/base/win/message_box_win.h" |
6 | 6 |
7 #include <windows.h> | |
8 | |
9 #include "base/base_switches.h" | |
10 #include "base/command_line.h" | 7 #include "base/command_line.h" |
11 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
12 #include "base/string16.h" | 9 #include "ui/base/ui_base_switches.h" |
13 | 10 |
14 namespace ui { | 11 namespace ui { |
15 | 12 |
16 // 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 |
17 // 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 |
18 // adding the appropriate Unicode directionality marks. | 15 // adding the appropriate Unicode directionality marks. |
19 int MessageBox(HWND hwnd, | 16 int MessageBox(HWND hwnd, |
20 const string16& text, | 17 const string16& text, |
21 const string16& caption, | 18 const string16& caption, |
22 UINT flags) { | 19 UINT flags) { |
23 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoMessageBox)) | 20 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoMessageBox)) |
24 return IDOK; | 21 return IDOK; |
25 | 22 |
26 UINT actual_flags = flags; | 23 UINT actual_flags = flags; |
27 if (base::i18n::IsRTL()) | 24 if (base::i18n::IsRTL()) |
28 actual_flags |= MB_RIGHT | MB_RTLREADING; | 25 actual_flags |= MB_RIGHT | MB_RTLREADING; |
29 | 26 |
30 string16 localized_text = text; | 27 string16 localized_text = text; |
31 base::i18n::AdjustStringForLocaleDirection(&localized_text); | 28 base::i18n::AdjustStringForLocaleDirection(&localized_text); |
32 const wchar_t* text_ptr = localized_text.c_str(); | 29 const wchar_t* text_ptr = localized_text.c_str(); |
33 | 30 |
34 string16 localized_caption = caption; | 31 string16 localized_caption = caption; |
35 base::i18n::AdjustStringForLocaleDirection(&localized_caption); | 32 base::i18n::AdjustStringForLocaleDirection(&localized_caption); |
36 const wchar_t* caption_ptr = localized_caption.c_str(); | 33 const wchar_t* caption_ptr = localized_caption.c_str(); |
37 | 34 |
38 return ::MessageBox(hwnd, text_ptr, caption_ptr, actual_flags); | 35 return ::MessageBox(hwnd, text_ptr, caption_ptr, actual_flags); |
39 } | 36 } |
40 | 37 |
41 } // namespace ui | 38 } // namespace ui |
OLD | NEW |