OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "base/win/win_util.h" | 5 #include "base/win/win_util.h" |
6 | 6 |
7 #include <aclapi.h> | 7 #include <aclapi.h> |
8 #include <cfgmgr32.h> | 8 #include <cfgmgr32.h> |
9 #include <lm.h> | 9 #include <lm.h> |
10 #include <powrprof.h> | 10 #include <powrprof.h> |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 void __cdecl ForceCrashOnSigAbort(int) { | 50 void __cdecl ForceCrashOnSigAbort(int) { |
51 *((int*)0) = 0x1337; | 51 *((int*)0) = 0x1337; |
52 } | 52 } |
53 | 53 |
54 const wchar_t kWindows8OSKRegPath[] = | 54 const wchar_t kWindows8OSKRegPath[] = |
55 L"Software\\Classes\\CLSID\\{054AAE20-4BEA-4347-8A35-64A533254A9D}" | 55 L"Software\\Classes\\CLSID\\{054AAE20-4BEA-4347-8A35-64A533254A9D}" |
56 L"\\LocalServer32"; | 56 L"\\LocalServer32"; |
57 | 57 |
58 // Returns true if a physical keyboard is detected on Windows 8 and up. | 58 // Returns true if a physical keyboard is detected on Windows 8 and up. |
59 // Uses the Setup APIs to enumerate the attached keyboards and returns true | 59 // Uses the Setup APIs to enumerate the attached keyboards and returns true |
60 // if the keyboard count is more than 1. While this will work in most cases | 60 // if the keyboard count is 1 or more.. While this will work in most cases |
61 // it won't work if there are devices which expose keyboard interfaces which | 61 // it won't work if there are devices which expose keyboard interfaces which |
62 // are attached to the machine. | 62 // are attached to the machine. |
63 bool IsKeyboardPresentOnSlate() { | 63 bool IsKeyboardPresentOnSlate() { |
64 // This function is only supported for Windows 8 and up. | 64 // This function is only supported for Windows 8 and up. |
65 DCHECK(base::win::GetVersion() >= base::win::VERSION_WIN8); | 65 DCHECK(base::win::GetVersion() >= base::win::VERSION_WIN8); |
66 | 66 |
67 // This function should be only invoked for machines with touch screens. | 67 // This function should be only invoked for machines with touch screens. |
68 if ((GetSystemMetrics(SM_DIGITIZER) & NID_INTEGRATED_TOUCH) | 68 if ((GetSystemMetrics(SM_DIGITIZER) & NID_INTEGRATED_TOUCH) |
69 != NID_INTEGRATED_TOUCH) { | 69 != NID_INTEGRATED_TOUCH) { |
70 return true; | 70 return true; |
(...skipping 11 matching lines...) Expand all Loading... |
82 | 82 |
83 // Enumerate all keyboards and look for ACPI\PNP and HID\VID devices. If | 83 // Enumerate all keyboards and look for ACPI\PNP and HID\VID devices. If |
84 // the count is more than 1 we assume that a keyboard is present. This is | 84 // the count is more than 1 we assume that a keyboard is present. This is |
85 // under the assumption that there will always be one keyboard device. | 85 // under the assumption that there will always be one keyboard device. |
86 int keyboard_count = 0; | 86 int keyboard_count = 0; |
87 for (DWORD i = 0;; ++i) { | 87 for (DWORD i = 0;; ++i) { |
88 SP_DEVINFO_DATA device_info_data = { 0 }; | 88 SP_DEVINFO_DATA device_info_data = { 0 }; |
89 device_info_data.cbSize = sizeof(device_info_data); | 89 device_info_data.cbSize = sizeof(device_info_data); |
90 if (!SetupDiEnumDeviceInfo(device_info, i, &device_info_data)) | 90 if (!SetupDiEnumDeviceInfo(device_info, i, &device_info_data)) |
91 break; | 91 break; |
| 92 |
92 // Get the device ID. | 93 // Get the device ID. |
93 wchar_t device_id[MAX_DEVICE_ID_LEN]; | 94 wchar_t device_id[MAX_DEVICE_ID_LEN]; |
94 CONFIGRET status = CM_Get_Device_ID(device_info_data.DevInst, | 95 CONFIGRET status = CM_Get_Device_ID(device_info_data.DevInst, |
95 device_id, | 96 device_id, |
96 MAX_DEVICE_ID_LEN, | 97 MAX_DEVICE_ID_LEN, |
97 0); | 98 0); |
98 if (status == CR_SUCCESS) { | 99 if (status == CR_SUCCESS) { |
99 // To reduce the scope of the hack we only look for PNP and HID | 100 // To reduce the scope of the hack we only look for PNP, MSF and HID |
100 // keyboards. | 101 // keyboards. |
101 if (StartsWith(L"ACPI\\PNP", device_id, false) || | 102 if (StartsWith(device_id, L"ACPI\\PNP", false) || |
102 StartsWith(L"HID\\VID", device_id, false)) { | 103 StartsWith(device_id, L"ACPI\\MSF", false) || |
| 104 StartsWith(device_id, L"HID\\VID", false)) { |
103 keyboard_count++; | 105 keyboard_count++; |
104 } | 106 } |
105 } | 107 } |
106 } | 108 } |
107 // On a Windows machine, the API's always report 1 keyboard at least | 109 // The heuristic we are using is to check the count of keyboards and return |
108 // regardless of whether the machine has a keyboard attached or not. | 110 // true if the API's report one or more keyboards. Please note that this |
109 // The heuristic we are using is to check the count and return true | |
110 // if the API's report more than one keyboard. Please note that this | |
111 // will break for non keyboard devices which expose a keyboard PDO. | 111 // will break for non keyboard devices which expose a keyboard PDO. |
112 return keyboard_count > 1; | 112 return keyboard_count >= 1; |
113 } | 113 } |
114 | 114 |
115 } // namespace | 115 } // namespace |
116 | 116 |
117 namespace base { | 117 namespace base { |
118 namespace win { | 118 namespace win { |
119 | 119 |
120 static bool g_crash_on_process_detach = false; | 120 static bool g_crash_on_process_detach = false; |
121 | 121 |
122 void GetNonClientMetrics(NONCLIENTMETRICS_XP* metrics) { | 122 void GetNonClientMetrics(NONCLIENTMETRICS_XP* metrics) { |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 // deployed. | 441 // deployed. |
442 if (os_info->version() == base::win::VERSION_SERVER_2003) | 442 if (os_info->version() == base::win::VERSION_SERVER_2003) |
443 return false; | 443 return false; |
444 | 444 |
445 DCHECK(os_info->version() >= base::win::VERSION_VISTA); | 445 DCHECK(os_info->version() >= base::win::VERSION_VISTA); |
446 return true; // New enough to have SHA-256 support. | 446 return true; // New enough to have SHA-256 support. |
447 } | 447 } |
448 | 448 |
449 } // namespace win | 449 } // namespace win |
450 } // namespace base | 450 } // namespace base |
OLD | NEW |