Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Side by Side Diff: app/win_util.cc

Issue 149795: Add a command line argument to disable message boxes. This is useful to... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/base_switches.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-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 <atlbase.h> 7 #include <atlbase.h>
8 #include <atlapp.h> 8 #include <atlapp.h>
9 #include <commdlg.h> 9 #include <commdlg.h>
10 #include <dwmapi.h> 10 #include <dwmapi.h>
11 #include <shellapi.h> 11 #include <shellapi.h>
12 #include <shlobj.h> 12 #include <shlobj.h>
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"
17 #include "base/command_line.h"
16 #include "base/file_util.h" 18 #include "base/file_util.h"
17 #include "base/gfx/gdi_util.h" 19 #include "base/gfx/gdi_util.h"
18 #include "base/gfx/png_encoder.h" 20 #include "base/gfx/png_encoder.h"
19 #include "base/logging.h" 21 #include "base/logging.h"
20 #include "base/registry.h" 22 #include "base/registry.h"
21 #include "base/scoped_handle.h" 23 #include "base/scoped_handle.h"
22 #include "base/string_util.h" 24 #include "base/string_util.h"
23 #include "base/win_util.h" 25 #include "base/win_util.h"
24 #include "grit/app_strings.h" 26 #include "grit/app_strings.h"
25 #include "net/base/mime_util.h" 27 #include "net/base/mime_util.h"
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 return false; 790 return false;
789 } 791 }
790 792
791 // In addition to passing the RTL flags to ::MessageBox if we are running in an 793 // In addition to passing the RTL flags to ::MessageBox if we are running in an
792 // RTL locale, we need to make sure that LTR strings are rendered correctly by 794 // RTL locale, we need to make sure that LTR strings are rendered correctly by
793 // adding the appropriate Unicode directionality marks. 795 // adding the appropriate Unicode directionality marks.
794 int MessageBox(HWND hwnd, 796 int MessageBox(HWND hwnd,
795 const std::wstring& text, 797 const std::wstring& text,
796 const std::wstring& caption, 798 const std::wstring& caption,
797 UINT flags) { 799 UINT flags) {
800 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoMessageBox))
801 return IDOK;
802
798 UINT actual_flags = flags; 803 UINT actual_flags = flags;
799 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) 804 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT)
800 actual_flags |= MB_RIGHT | MB_RTLREADING; 805 actual_flags |= MB_RIGHT | MB_RTLREADING;
801 806
802 std::wstring localized_text; 807 std::wstring localized_text;
803 const wchar_t* text_ptr = text.c_str(); 808 const wchar_t* text_ptr = text.c_str();
804 if (l10n_util::AdjustStringForLocaleDirection(text, &localized_text)) 809 if (l10n_util::AdjustStringForLocaleDirection(text, &localized_text))
805 text_ptr = localized_text.c_str(); 810 text_ptr = localized_text.c_str();
806 811
807 std::wstring localized_caption; 812 std::wstring localized_caption;
808 const wchar_t* caption_ptr = caption.c_str(); 813 const wchar_t* caption_ptr = caption.c_str();
809 if (l10n_util::AdjustStringForLocaleDirection(caption, &localized_caption)) 814 if (l10n_util::AdjustStringForLocaleDirection(caption, &localized_caption))
810 caption_ptr = localized_caption.c_str(); 815 caption_ptr = localized_caption.c_str();
811 816
812 return ::MessageBox(hwnd, text_ptr, caption_ptr, actual_flags); 817 return ::MessageBox(hwnd, text_ptr, caption_ptr, actual_flags);
813 } 818 }
814 819
815 gfx::Font GetWindowTitleFont() { 820 gfx::Font GetWindowTitleFont() {
816 NONCLIENTMETRICS ncm; 821 NONCLIENTMETRICS ncm;
817 win_util::GetNonClientMetrics(&ncm); 822 win_util::GetNonClientMetrics(&ncm);
818 l10n_util::AdjustUIFont(&(ncm.lfCaptionFont)); 823 l10n_util::AdjustUIFont(&(ncm.lfCaptionFont));
819 ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont))); 824 ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont)));
820 return gfx::Font::CreateFont(caption_font); 825 return gfx::Font::CreateFont(caption_font);
821 } 826 }
822 827
823 } // namespace win_util 828 } // namespace win_util
OLDNEW
« no previous file with comments | « no previous file | base/base_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698