OLD | NEW |
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> |
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/i18n/rtl.h" |
20 #include "base/logging.h" | 20 #include "base/logging.h" |
21 #include "base/native_library.h" | 21 #include "base/native_library.h" |
22 #include "base/scoped_comptr_win.h" | 22 #include "base/scoped_comptr_win.h" |
23 #include "base/scoped_handle.h" | 23 #include "base/scoped_handle.h" |
24 #include "base/scoped_handle_win.h" | 24 #include "base/scoped_handle_win.h" |
25 #include "base/string_util.h" | 25 #include "base/string_util.h" |
26 #include "base/win_util.h" | 26 #include "base/win_util.h" |
| 27 #include "base/win/scoped_gdi_object.h" |
27 #include "base/win/windows_version.h" | 28 #include "base/win/windows_version.h" |
28 #include "gfx/codec/png_codec.h" | 29 #include "gfx/codec/png_codec.h" |
29 #include "gfx/gdi_util.h" | 30 #include "gfx/gdi_util.h" |
30 | 31 |
31 // Ensure that we pick up this link library. | 32 // Ensure that we pick up this link library. |
32 #pragma comment(lib, "dwmapi.lib") | 33 #pragma comment(lib, "dwmapi.lib") |
33 | 34 |
34 namespace win_util { | 35 namespace win_util { |
35 | 36 |
36 const int kAutoHideTaskbarThicknessPx = 2; | 37 const int kAutoHideTaskbarThicknessPx = 2; |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 base::i18n::AdjustStringForLocaleDirection(&localized_caption); | 542 base::i18n::AdjustStringForLocaleDirection(&localized_caption); |
542 const wchar_t* caption_ptr = localized_caption.c_str(); | 543 const wchar_t* caption_ptr = localized_caption.c_str(); |
543 | 544 |
544 return ::MessageBox(hwnd, text_ptr, caption_ptr, actual_flags); | 545 return ::MessageBox(hwnd, text_ptr, caption_ptr, actual_flags); |
545 } | 546 } |
546 | 547 |
547 gfx::Font GetWindowTitleFont() { | 548 gfx::Font GetWindowTitleFont() { |
548 NONCLIENTMETRICS ncm; | 549 NONCLIENTMETRICS ncm; |
549 win_util::GetNonClientMetrics(&ncm); | 550 win_util::GetNonClientMetrics(&ncm); |
550 l10n_util::AdjustUIFont(&(ncm.lfCaptionFont)); | 551 l10n_util::AdjustUIFont(&(ncm.lfCaptionFont)); |
551 ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont))); | 552 base::win::ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont))); |
552 return gfx::Font(caption_font); | 553 return gfx::Font(caption_font); |
553 } | 554 } |
554 | 555 |
555 void SetAppIdForWindow(const std::wstring& app_id, HWND hwnd) { | 556 void SetAppIdForWindow(const std::wstring& app_id, HWND hwnd) { |
556 // This functionality is only available on Win7+. | 557 // This functionality is only available on Win7+. |
557 if (base::win::GetVersion() < base::win::VERSION_WIN7) | 558 if (base::win::GetVersion() < base::win::VERSION_WIN7) |
558 return; | 559 return; |
559 | 560 |
560 // Load Shell32.dll into memory. | 561 // Load Shell32.dll into memory. |
561 // TODO(brg): Remove this mechanism when the Win7 SDK is available in trunk. | 562 // TODO(brg): Remove this mechanism when the Win7 SDK is available in trunk. |
(...skipping 22 matching lines...) Expand all Loading... |
584 hwnd, __uuidof(*pps), reinterpret_cast<void**>(pps.Receive())); | 585 hwnd, __uuidof(*pps), reinterpret_cast<void**>(pps.Receive())); |
585 if (S_OK == result) { | 586 if (S_OK == result) { |
586 SetAppIdForPropertyStore(pps, app_id.c_str()); | 587 SetAppIdForPropertyStore(pps, app_id.c_str()); |
587 } | 588 } |
588 | 589 |
589 // Cleanup. | 590 // Cleanup. |
590 base::UnloadNativeLibrary(shell32_library); | 591 base::UnloadNativeLibrary(shell32_library); |
591 } | 592 } |
592 | 593 |
593 } // namespace win_util | 594 } // namespace win_util |
OLD | NEW |