Chromium Code Reviews

Side by Side Diff: app/win_util.cc

Issue 5154009: Cleanup AdjustStringForLocaleDirection() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: further fixes Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
« no previous file with comments | « no previous file | base/i18n/rtl.h » ('j') | base/i18n/rtl.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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>
(...skipping 515 matching lines...)
526 const std::wstring& text, 526 const std::wstring& text,
527 const std::wstring& caption, 527 const std::wstring& caption,
528 UINT flags) { 528 UINT flags) {
529 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoMessageBox)) 529 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoMessageBox))
530 return IDOK; 530 return IDOK;
531 531
532 UINT actual_flags = flags; 532 UINT actual_flags = flags;
533 if (base::i18n::IsRTL()) 533 if (base::i18n::IsRTL())
534 actual_flags |= MB_RIGHT | MB_RTLREADING; 534 actual_flags |= MB_RIGHT | MB_RTLREADING;
535 535
536 std::wstring localized_text; 536 std::wstring localized_text = text;
537 const wchar_t* text_ptr = text.c_str(); 537 base::i18n::AdjustStringForLocaleDirection(&localized_text);
538 if (base::i18n::AdjustStringForLocaleDirection(text, &localized_text)) 538 const wchar_t* text_ptr = localized_text.c_str();
539 text_ptr = localized_text.c_str();
540 539
541 std::wstring localized_caption; 540 std::wstring localized_caption = caption;
542 const wchar_t* caption_ptr = caption.c_str(); 541 base::i18n::AdjustStringForLocaleDirection(&localized_caption);
543 if (base::i18n::AdjustStringForLocaleDirection(caption, &localized_caption)) 542 const wchar_t* caption_ptr = localized_caption.c_str();
544 caption_ptr = localized_caption.c_str();
545 543
546 return ::MessageBox(hwnd, text_ptr, caption_ptr, actual_flags); 544 return ::MessageBox(hwnd, text_ptr, caption_ptr, actual_flags);
547 } 545 }
548 546
549 gfx::Font GetWindowTitleFont() { 547 gfx::Font GetWindowTitleFont() {
550 NONCLIENTMETRICS ncm; 548 NONCLIENTMETRICS ncm;
551 win_util::GetNonClientMetrics(&ncm); 549 win_util::GetNonClientMetrics(&ncm);
552 l10n_util::AdjustUIFont(&(ncm.lfCaptionFont)); 550 l10n_util::AdjustUIFont(&(ncm.lfCaptionFont));
553 ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont))); 551 ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont)));
554 return gfx::Font(caption_font); 552 return gfx::Font(caption_font);
(...skipping 31 matching lines...)
586 hwnd, __uuidof(*pps), reinterpret_cast<void**>(pps.Receive())); 584 hwnd, __uuidof(*pps), reinterpret_cast<void**>(pps.Receive()));
587 if (S_OK == result) { 585 if (S_OK == result) {
588 SetAppIdForPropertyStore(pps, app_id.c_str()); 586 SetAppIdForPropertyStore(pps, app_id.c_str());
589 } 587 }
590 588
591 // Cleanup. 589 // Cleanup.
592 base::UnloadNativeLibrary(shell32_library); 590 base::UnloadNativeLibrary(shell32_library);
593 } 591 }
594 592
595 } // namespace win_util 593 } // namespace win_util
OLDNEW
« no previous file with comments | « no previous file | base/i18n/rtl.h » ('j') | base/i18n/rtl.h » ('J')

Powered by Google App Engine