OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // ============================================================================= | |
6 // PLEASE READ | |
7 // | |
8 // In general, you should not be adding stuff to this file. | |
9 // | |
10 // - If your thing is only used in one place, just put it in a reasonable | |
11 // location in or near that one place. It's nice you want people to be able | |
12 // to re-use your function, but realistically, if it hasn't been necessary | |
13 // before after so many years of development, it's probably not going to be | |
14 // used in other places in the future unless you know of them now. | |
15 // | |
16 // - If your thing is used by multiple callers and is UI-related, it should | |
17 // probably be in app/win/ instead. Try to put it in the most specific file | |
18 // possible (avoiding the *_util files when practical). | |
19 // | |
20 // ============================================================================= | |
21 | |
22 #ifndef BASE_WIN_WIN_UTIL_H_ | |
23 #define BASE_WIN_WIN_UTIL_H_ | |
24 | |
25 #include <windows.h> | |
26 | |
27 #include <string> | |
28 | |
29 #include "base/base_export.h" | |
30 #include "base/strings/string16.h" | |
31 | |
32 struct IPropertyStore; | |
33 struct _tagpropertykey; | |
34 typedef _tagpropertykey PROPERTYKEY; | |
35 | |
36 // This is the same as NONCLIENTMETRICS except that the | |
37 // unused member |iPaddedBorderWidth| has been removed. | |
38 struct NONCLIENTMETRICS_XP { | |
39 UINT cbSize; | |
40 int iBorderWidth; | |
41 int iScrollWidth; | |
42 int iScrollHeight; | |
43 int iCaptionWidth; | |
44 int iCaptionHeight; | |
45 LOGFONTW lfCaptionFont; | |
46 int iSmCaptionWidth; | |
47 int iSmCaptionHeight; | |
48 LOGFONTW lfSmCaptionFont; | |
49 int iMenuWidth; | |
50 int iMenuHeight; | |
51 LOGFONTW lfMenuFont; | |
52 LOGFONTW lfStatusFont; | |
53 LOGFONTW lfMessageFont; | |
54 }; | |
55 | |
56 namespace base { | |
57 namespace win { | |
58 | |
59 BASE_EXPORT void GetNonClientMetrics(NONCLIENTMETRICS_XP* metrics); | |
60 | |
61 // Returns the string representing the current user sid. | |
62 BASE_EXPORT bool GetUserSidString(std::wstring* user_sid); | |
63 | |
64 // Returns true if the shift key is currently pressed. | |
65 BASE_EXPORT bool IsShiftPressed(); | |
66 | |
67 // Returns true if the ctrl key is currently pressed. | |
68 BASE_EXPORT bool IsCtrlPressed(); | |
69 | |
70 // Returns true if the alt key is currently pressed. | |
71 BASE_EXPORT bool IsAltPressed(); | |
72 | |
73 // Returns true if the altgr key is currently pressed. | |
74 // Windows does not have specific key code and modifier bit and Alt+Ctrl key is | |
75 // used as AltGr key in Windows. | |
76 BASE_EXPORT bool IsAltGrPressed(); | |
77 | |
78 // Returns false if user account control (UAC) has been disabled with the | |
79 // EnableLUA registry flag. Returns true if user account control is enabled. | |
80 // NOTE: The EnableLUA registry flag, which is ignored on Windows XP | |
81 // machines, might still exist and be set to 0 (UAC disabled), in which case | |
82 // this function will return false. You should therefore check this flag only | |
83 // if the OS is Vista or later. | |
84 BASE_EXPORT bool UserAccountControlIsEnabled(); | |
85 | |
86 // Sets the boolean value for a given key in given IPropertyStore. | |
87 BASE_EXPORT bool SetBooleanValueForPropertyStore( | |
88 IPropertyStore* property_store, | |
89 const PROPERTYKEY& property_key, | |
90 bool property_bool_value); | |
91 | |
92 // Sets the string value for a given key in given IPropertyStore. | |
93 BASE_EXPORT bool SetStringValueForPropertyStore( | |
94 IPropertyStore* property_store, | |
95 const PROPERTYKEY& property_key, | |
96 const wchar_t* property_string_value); | |
97 | |
98 // Sets the application id in given IPropertyStore. The function is intended | |
99 // for tagging application/chromium shortcut, browser window and jump list for | |
100 // Win7. | |
101 BASE_EXPORT bool SetAppIdForPropertyStore(IPropertyStore* property_store, | |
102 const wchar_t* app_id); | |
103 | |
104 // Adds the specified |command| using the specified |name| to the AutoRun key. | |
105 // |root_key| could be HKCU or HKLM or the root of any user hive. | |
106 BASE_EXPORT bool AddCommandToAutoRun(HKEY root_key, const string16& name, | |
107 const string16& command); | |
108 // Removes the command specified by |name| from the AutoRun key. |root_key| | |
109 // could be HKCU or HKLM or the root of any user hive. | |
110 BASE_EXPORT bool RemoveCommandFromAutoRun(HKEY root_key, const string16& name); | |
111 | |
112 // Reads the command specified by |name| from the AutoRun key. |root_key| | |
113 // could be HKCU or HKLM or the root of any user hive. Used for unit-tests. | |
114 BASE_EXPORT bool ReadCommandFromAutoRun(HKEY root_key, | |
115 const string16& name, | |
116 string16* command); | |
117 | |
118 // Sets whether to crash the process during exit. This is inspected by DLLMain | |
119 // and used to intercept unexpected terminations of the process (via calls to | |
120 // exit(), abort(), _exit(), ExitProcess()) and convert them into crashes. | |
121 // Note that not all mechanisms for terminating the process are covered by | |
122 // this. In particular, TerminateProcess() is not caught. | |
123 BASE_EXPORT void SetShouldCrashOnProcessDetach(bool crash); | |
124 BASE_EXPORT bool ShouldCrashOnProcessDetach(); | |
125 | |
126 // Adjusts the abort behavior so that crash reports can be generated when the | |
127 // process is aborted. | |
128 BASE_EXPORT void SetAbortBehaviorForCrashReporting(); | |
129 | |
130 // A tablet is a device that is touch enabled and also is being used | |
131 // "like a tablet". This is used primarily for metrics in order to gain some | |
132 // insight into how users use Chrome. | |
133 BASE_EXPORT bool IsTabletDevice(); | |
134 | |
135 // Get the size of a struct up to and including the specified member. | |
136 // This is necessary to set compatible struct sizes for different versions | |
137 // of certain Windows APIs (e.g. SystemParametersInfo). | |
138 #define SIZEOF_STRUCT_WITH_SPECIFIED_LAST_MEMBER(struct_name, member) \ | |
139 offsetof(struct_name, member) + \ | |
140 (sizeof static_cast<struct_name*>(NULL)->member) | |
141 | |
142 // Displays the on screen keyboard on Windows 8 and above. Returns true on | |
143 // success. | |
144 BASE_EXPORT bool DisplayVirtualKeyboard(); | |
145 | |
146 // Dismisses the on screen keyboard if it is being displayed on Windows 8 and. | |
147 // above. Returns true on success. | |
148 BASE_EXPORT bool DismissVirtualKeyboard(); | |
149 | |
150 // Returns true if the machine is enrolled to a domain. | |
151 BASE_EXPORT bool IsEnrolledToDomain(); | |
152 | |
153 // Used by tests to mock any wanted state. Call with |state| set to true to | |
154 // simulate being in a domain and false otherwise. | |
155 BASE_EXPORT void SetDomainStateForTesting(bool state); | |
156 | |
157 // Returns true if the current operating system has support for SHA-256 | |
158 // certificates. As its name indicates, this function provides a best-effort | |
159 // answer, which is solely based on comparing version numbers. The function | |
160 // may be re-implemented in the future to return a reliable value, based on | |
161 // run-time detection of this capability. | |
162 BASE_EXPORT bool MaybeHasSHA256Support(); | |
163 | |
164 } // namespace win | |
165 } // namespace base | |
166 | |
167 #endif // BASE_WIN_WIN_UTIL_H_ | |
OLD | NEW |