OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #ifndef BASE_WIN_UTIL_H__ | 5 #ifndef BASE_WIN_UTIL_H__ |
6 #define BASE_WIN_UTIL_H__ | 6 #define BASE_WIN_UTIL_H__ |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <aclapi.h> | 9 #include <aclapi.h> |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 | 12 |
| 13 #include "base/tracked.h" |
| 14 |
13 namespace win_util { | 15 namespace win_util { |
14 | 16 |
15 // NOTE: Keep these in order so callers can do things like | 17 // NOTE: Keep these in order so callers can do things like |
16 // "if (GetWinVersion() > WINVERSION_2000) ...". It's OK to change the values, | 18 // "if (GetWinVersion() > WINVERSION_2000) ...". It's OK to change the values, |
17 // though. | 19 // though. |
18 enum WinVersion { | 20 enum WinVersion { |
19 WINVERSION_PRE_2000 = 0, // Not supported | 21 WINVERSION_PRE_2000 = 0, // Not supported |
20 WINVERSION_2000 = 1, | 22 WINVERSION_2000 = 1, |
21 WINVERSION_XP = 2, | 23 WINVERSION_XP = 2, |
22 WINVERSION_SERVER_2003 = 3, | 24 WINVERSION_SERVER_2003 = 3, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 // if the OS is Vista. | 97 // if the OS is Vista. |
96 bool UserAccountControlIsEnabled(); | 98 bool UserAccountControlIsEnabled(); |
97 | 99 |
98 // Use the Win32 API FormatMessage() function to generate a string, using | 100 // Use the Win32 API FormatMessage() function to generate a string, using |
99 // Windows's default Message Compiled resources; ignoring the inserts. | 101 // Windows's default Message Compiled resources; ignoring the inserts. |
100 std::wstring FormatMessage(unsigned messageid); | 102 std::wstring FormatMessage(unsigned messageid); |
101 | 103 |
102 // Uses the last Win32 error to generate a human readable message string. | 104 // Uses the last Win32 error to generate a human readable message string. |
103 std::wstring FormatLastWin32Error(); | 105 std::wstring FormatLastWin32Error(); |
104 | 106 |
| 107 // These 2 methods are used to track HWND creation/destruction to investigate |
| 108 // a mysterious crasher http://crbugs.com/4714 (crasher in on NCDestroy) that |
| 109 // might be caused by a multiple delete of an HWND. |
| 110 void NotifyHWNDCreation(const tracked_objects::Location& from_here, HWND hwnd); |
| 111 void NotifyHWNDDestruction(const tracked_objects::Location& from_here, |
| 112 HWND hwnd); |
| 113 |
| 114 #ifdef NDEBUG |
| 115 #define TRACK_HWND_CREATION(hwnd) |
| 116 #define TRACK_HWND_DESTRUCTION(hwnd) |
| 117 #else |
| 118 #define TRACK_HWND_CREATION(hwnd) win_util::NotifyHWNDCreation(FROM_HERE, hwnd) |
| 119 #define TRACK_HWND_DESTRUCTION(hwnd) \ |
| 120 win_util::NotifyHWNDDestruction(FROM_HERE, hwnd) |
| 121 #endif |
| 122 |
105 } // namespace win_util | 123 } // namespace win_util |
106 | 124 |
107 #endif // BASE_WIN_UTIL_H__ | 125 #endif // BASE_WIN_UTIL_H__ |
108 | 126 |
OLD | NEW |