Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ui / base / win / message_box_win.cc
blob27277a213ea2b5998dfbcb0630bd75a10c23e70d
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
3 // found in the LICENSE file.
5 #include "ui/base/win/message_box_win.h"
7 #include "base/i18n/rtl.h"
9 namespace ui {
11 // In addition to passing the RTL flags to ::MessageBox if we are running in an
12 // RTL locale, we need to make sure that LTR strings are rendered correctly by
13 // adding the appropriate Unicode directionality marks.
14 int MessageBox(HWND hwnd,
15 const base::string16& text,
16 const base::string16& caption,
17 UINT flags) {
18 UINT actual_flags = flags;
19 if (base::i18n::IsRTL())
20 actual_flags |= MB_RIGHT | MB_RTLREADING;
22 base::string16 localized_text = text;
23 base::i18n::AdjustStringForLocaleDirection(&localized_text);
24 const wchar_t* text_ptr = localized_text.c_str();
26 base::string16 localized_caption = caption;
27 base::i18n::AdjustStringForLocaleDirection(&localized_caption);
28 const wchar_t* caption_ptr = localized_caption.c_str();
30 return ::MessageBox(hwnd, text_ptr, caption_ptr, actual_flags);
33 } // namespace ui