OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "app/win_util.h" | 5 #include "app/win_util.h" |
6 | 6 |
7 #include <commdlg.h> | 7 #include <commdlg.h> |
8 #include <dwmapi.h> | 8 #include <dwmapi.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #include <shlobj.h> | 10 #include <shlobj.h> |
11 | 11 |
12 #include <algorithm> | 12 #include <algorithm> |
13 | 13 |
14 #include "app/l10n_util.h" | 14 #include "app/l10n_util.h" |
15 #include "app/l10n_util_win.h" | 15 #include "app/l10n_util_win.h" |
16 #include "base/base_switches.h" | 16 #include "base/base_switches.h" |
17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
18 #include "base/file_util.h" | 18 #include "base/file_util.h" |
| 19 #include "base/i18n/rtl.h" |
19 #include "base/logging.h" | 20 #include "base/logging.h" |
20 #include "base/native_library.h" | 21 #include "base/native_library.h" |
21 #include "base/registry.h" | 22 #include "base/registry.h" |
22 #include "base/scoped_comptr_win.h" | 23 #include "base/scoped_comptr_win.h" |
23 #include "base/scoped_handle.h" | 24 #include "base/scoped_handle.h" |
24 #include "base/scoped_handle_win.h" | 25 #include "base/scoped_handle_win.h" |
25 #include "base/string_util.h" | 26 #include "base/string_util.h" |
26 #include "base/win_util.h" | 27 #include "base/win_util.h" |
27 #include "gfx/codec/png_codec.h" | 28 #include "gfx/codec/png_codec.h" |
28 #include "gfx/gdi_util.h" | 29 #include "gfx/gdi_util.h" |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 // RTL locale, we need to make sure that LTR strings are rendered correctly by | 513 // RTL locale, we need to make sure that LTR strings are rendered correctly by |
513 // adding the appropriate Unicode directionality marks. | 514 // adding the appropriate Unicode directionality marks. |
514 int MessageBox(HWND hwnd, | 515 int MessageBox(HWND hwnd, |
515 const std::wstring& text, | 516 const std::wstring& text, |
516 const std::wstring& caption, | 517 const std::wstring& caption, |
517 UINT flags) { | 518 UINT flags) { |
518 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoMessageBox)) | 519 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoMessageBox)) |
519 return IDOK; | 520 return IDOK; |
520 | 521 |
521 UINT actual_flags = flags; | 522 UINT actual_flags = flags; |
522 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) | 523 if (base::i18n::IsRTL()) |
523 actual_flags |= MB_RIGHT | MB_RTLREADING; | 524 actual_flags |= MB_RIGHT | MB_RTLREADING; |
524 | 525 |
525 std::wstring localized_text; | 526 std::wstring localized_text; |
526 const wchar_t* text_ptr = text.c_str(); | 527 const wchar_t* text_ptr = text.c_str(); |
527 if (l10n_util::AdjustStringForLocaleDirection(text, &localized_text)) | 528 if (base::i18n::AdjustStringForLocaleDirection(text, &localized_text)) |
528 text_ptr = localized_text.c_str(); | 529 text_ptr = localized_text.c_str(); |
529 | 530 |
530 std::wstring localized_caption; | 531 std::wstring localized_caption; |
531 const wchar_t* caption_ptr = caption.c_str(); | 532 const wchar_t* caption_ptr = caption.c_str(); |
532 if (l10n_util::AdjustStringForLocaleDirection(caption, &localized_caption)) | 533 if (base::i18n::AdjustStringForLocaleDirection(caption, &localized_caption)) |
533 caption_ptr = localized_caption.c_str(); | 534 caption_ptr = localized_caption.c_str(); |
534 | 535 |
535 return ::MessageBox(hwnd, text_ptr, caption_ptr, actual_flags); | 536 return ::MessageBox(hwnd, text_ptr, caption_ptr, actual_flags); |
536 } | 537 } |
537 | 538 |
538 gfx::Font GetWindowTitleFont() { | 539 gfx::Font GetWindowTitleFont() { |
539 NONCLIENTMETRICS ncm; | 540 NONCLIENTMETRICS ncm; |
540 win_util::GetNonClientMetrics(&ncm); | 541 win_util::GetNonClientMetrics(&ncm); |
541 l10n_util::AdjustUIFont(&(ncm.lfCaptionFont)); | 542 l10n_util::AdjustUIFont(&(ncm.lfCaptionFont)); |
542 ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont))); | 543 ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont))); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 hwnd, __uuidof(*pps), reinterpret_cast<void**>(pps.Receive())); | 576 hwnd, __uuidof(*pps), reinterpret_cast<void**>(pps.Receive())); |
576 if (S_OK == result) { | 577 if (S_OK == result) { |
577 SetAppIdForPropertyStore(pps, app_id.c_str()); | 578 SetAppIdForPropertyStore(pps, app_id.c_str()); |
578 } | 579 } |
579 | 580 |
580 // Cleanup. | 581 // Cleanup. |
581 base::UnloadNativeLibrary(shell32_library); | 582 base::UnloadNativeLibrary(shell32_library); |
582 } | 583 } |
583 | 584 |
584 } // namespace win_util | 585 } // namespace win_util |
OLD | NEW |