| 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 14 matching lines...) Expand all Loading... |
| 25 #include "base/strings/string_util.h" | 25 #include "base/strings/string_util.h" |
| 26 #include "base/strings/stringprintf.h" | 26 #include "base/strings/stringprintf.h" |
| 27 #include "base/threading/thread_restrictions.h" | 27 #include "base/threading/thread_restrictions.h" |
| 28 #include "base/win/metro.h" | 28 #include "base/win/metro.h" |
| 29 #include "base/win/registry.h" | 29 #include "base/win/registry.h" |
| 30 #include "base/win/scoped_co_mem.h" | 30 #include "base/win/scoped_co_mem.h" |
| 31 #include "base/win/scoped_handle.h" | 31 #include "base/win/scoped_handle.h" |
| 32 #include "base/win/scoped_propvariant.h" | 32 #include "base/win/scoped_propvariant.h" |
| 33 #include "base/win/windows_version.h" | 33 #include "base/win/windows_version.h" |
| 34 | 34 |
| 35 namespace base { |
| 36 namespace win { |
| 37 |
| 35 namespace { | 38 namespace { |
| 36 | 39 |
| 37 // Sets the value of |property_key| to |property_value| in |property_store|. | 40 // Sets the value of |property_key| to |property_value| in |property_store|. |
| 38 bool SetPropVariantValueForPropertyStore( | 41 bool SetPropVariantValueForPropertyStore( |
| 39 IPropertyStore* property_store, | 42 IPropertyStore* property_store, |
| 40 const PROPERTYKEY& property_key, | 43 const PROPERTYKEY& property_key, |
| 41 const base::win::ScopedPropVariant& property_value) { | 44 const ScopedPropVariant& property_value) { |
| 42 DCHECK(property_store); | 45 DCHECK(property_store); |
| 43 | 46 |
| 44 HRESULT result = property_store->SetValue(property_key, property_value.get()); | 47 HRESULT result = property_store->SetValue(property_key, property_value.get()); |
| 45 if (result == S_OK) | 48 if (result == S_OK) |
| 46 result = property_store->Commit(); | 49 result = property_store->Commit(); |
| 47 return SUCCEEDED(result); | 50 return SUCCEEDED(result); |
| 48 } | 51 } |
| 49 | 52 |
| 50 void __cdecl ForceCrashOnSigAbort(int) { | 53 void __cdecl ForceCrashOnSigAbort(int) { |
| 51 *((int*)0) = 0x1337; | 54 *((int*)0) = 0x1337; |
| 52 } | 55 } |
| 53 | 56 |
| 54 const wchar_t kWindows8OSKRegPath[] = | 57 const wchar_t kWindows8OSKRegPath[] = |
| 55 L"Software\\Classes\\CLSID\\{054AAE20-4BEA-4347-8A35-64A533254A9D}" | 58 L"Software\\Classes\\CLSID\\{054AAE20-4BEA-4347-8A35-64A533254A9D}" |
| 56 L"\\LocalServer32"; | 59 L"\\LocalServer32"; |
| 57 | 60 |
| 58 // Returns true if a physical keyboard is detected on Windows 8 and up. | 61 // 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 | 62 // Uses the Setup APIs to enumerate the attached keyboards and returns true |
| 60 // if the keyboard count is 1 or more.. While this will work in most cases | 63 // 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 | 64 // it won't work if there are devices which expose keyboard interfaces which |
| 62 // are attached to the machine. | 65 // are attached to the machine. |
| 63 bool IsKeyboardPresentOnSlate() { | 66 bool IsKeyboardPresentOnSlate() { |
| 64 // This function is only supported for Windows 8 and up. | 67 // This function is only supported for Windows 8 and up. |
| 65 DCHECK(base::win::GetVersion() >= base::win::VERSION_WIN8); | 68 DCHECK(GetVersion() >= VERSION_WIN8); |
| 66 | 69 |
| 67 // This function should be only invoked for machines with touch screens. | 70 // This function should be only invoked for machines with touch screens. |
| 68 if ((GetSystemMetrics(SM_DIGITIZER) & NID_INTEGRATED_TOUCH) | 71 if ((GetSystemMetrics(SM_DIGITIZER) & NID_INTEGRATED_TOUCH) |
| 69 != NID_INTEGRATED_TOUCH) { | 72 != NID_INTEGRATED_TOUCH) { |
| 70 return true; | 73 return true; |
| 71 } | 74 } |
| 72 | 75 |
| 73 // If the device is docked, the user is treating the device as a PC. | 76 // If the device is docked, the user is treating the device as a PC. |
| 74 if (GetSystemMetrics(SM_SYSTEMDOCKED) != 0) | 77 if (GetSystemMetrics(SM_SYSTEMDOCKED) != 0) |
| 75 return true; | 78 return true; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 } | 156 } |
| 154 } | 157 } |
| 155 // The heuristic we are using is to check the count of keyboards and return | 158 // The heuristic we are using is to check the count of keyboards and return |
| 156 // true if the API's report one or more keyboards. Please note that this | 159 // true if the API's report one or more keyboards. Please note that this |
| 157 // will break for non keyboard devices which expose a keyboard PDO. | 160 // will break for non keyboard devices which expose a keyboard PDO. |
| 158 return keyboard_count >= 1; | 161 return keyboard_count >= 1; |
| 159 } | 162 } |
| 160 | 163 |
| 161 } // namespace | 164 } // namespace |
| 162 | 165 |
| 163 namespace base { | |
| 164 namespace win { | |
| 165 | |
| 166 static bool g_crash_on_process_detach = false; | 166 static bool g_crash_on_process_detach = false; |
| 167 | 167 |
| 168 void GetNonClientMetrics(NONCLIENTMETRICS_XP* metrics) { | 168 void GetNonClientMetrics(NONCLIENTMETRICS_XP* metrics) { |
| 169 DCHECK(metrics); | 169 DCHECK(metrics); |
| 170 metrics->cbSize = sizeof(*metrics); | 170 metrics->cbSize = sizeof(*metrics); |
| 171 const bool success = !!SystemParametersInfo( | 171 const bool success = !!SystemParametersInfo( |
| 172 SPI_GETNONCLIENTMETRICS, | 172 SPI_GETNONCLIENTMETRICS, |
| 173 metrics->cbSize, | 173 metrics->cbSize, |
| 174 reinterpret_cast<NONCLIENTMETRICS*>(metrics), | 174 reinterpret_cast<NONCLIENTMETRICS*>(metrics), |
| 175 0); | 175 0); |
| 176 DCHECK(success); | 176 DCHECK(success); |
| 177 } | 177 } |
| 178 | 178 |
| 179 bool GetUserSidString(std::wstring* user_sid) { | 179 bool GetUserSidString(std::wstring* user_sid) { |
| 180 // Get the current token. | 180 // Get the current token. |
| 181 HANDLE token = NULL; | 181 HANDLE token = NULL; |
| 182 if (!::OpenProcessToken(::GetCurrentProcess(), TOKEN_QUERY, &token)) | 182 if (!::OpenProcessToken(::GetCurrentProcess(), TOKEN_QUERY, &token)) |
| 183 return false; | 183 return false; |
| 184 base::win::ScopedHandle token_scoped(token); | 184 ScopedHandle token_scoped(token); |
| 185 | 185 |
| 186 DWORD size = sizeof(TOKEN_USER) + SECURITY_MAX_SID_SIZE; | 186 DWORD size = sizeof(TOKEN_USER) + SECURITY_MAX_SID_SIZE; |
| 187 scoped_ptr<BYTE[]> user_bytes(new BYTE[size]); | 187 scoped_ptr<BYTE[]> user_bytes(new BYTE[size]); |
| 188 TOKEN_USER* user = reinterpret_cast<TOKEN_USER*>(user_bytes.get()); | 188 TOKEN_USER* user = reinterpret_cast<TOKEN_USER*>(user_bytes.get()); |
| 189 | 189 |
| 190 if (!::GetTokenInformation(token, TokenUser, user, size, &size)) | 190 if (!::GetTokenInformation(token, TokenUser, user, size, &size)) |
| 191 return false; | 191 return false; |
| 192 | 192 |
| 193 if (!user->User.Sid) | 193 if (!user->User.Sid) |
| 194 return false; | 194 return false; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 219 | 219 |
| 220 bool IsAltGrPressed() { | 220 bool IsAltGrPressed() { |
| 221 return (::GetKeyState(VK_MENU) & 0x8000) == 0x8000 && | 221 return (::GetKeyState(VK_MENU) & 0x8000) == 0x8000 && |
| 222 (::GetKeyState(VK_CONTROL) & 0x8000) == 0x8000; | 222 (::GetKeyState(VK_CONTROL) & 0x8000) == 0x8000; |
| 223 } | 223 } |
| 224 | 224 |
| 225 bool UserAccountControlIsEnabled() { | 225 bool UserAccountControlIsEnabled() { |
| 226 // This can be slow if Windows ends up going to disk. Should watch this key | 226 // This can be slow if Windows ends up going to disk. Should watch this key |
| 227 // for changes and only read it once, preferably on the file thread. | 227 // for changes and only read it once, preferably on the file thread. |
| 228 // http://code.google.com/p/chromium/issues/detail?id=61644 | 228 // http://code.google.com/p/chromium/issues/detail?id=61644 |
| 229 base::ThreadRestrictions::ScopedAllowIO allow_io; | 229 ThreadRestrictions::ScopedAllowIO allow_io; |
| 230 | 230 |
| 231 base::win::RegKey key(HKEY_LOCAL_MACHINE, | 231 RegKey key(HKEY_LOCAL_MACHINE, |
| 232 L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", | 232 L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", |
| 233 KEY_READ); | 233 KEY_READ); |
| 234 DWORD uac_enabled; | 234 DWORD uac_enabled; |
| 235 if (key.ReadValueDW(L"EnableLUA", &uac_enabled) != ERROR_SUCCESS) | 235 if (key.ReadValueDW(L"EnableLUA", &uac_enabled) != ERROR_SUCCESS) |
| 236 return true; | 236 return true; |
| 237 // Users can set the EnableLUA value to something arbitrary, like 2, which | 237 // Users can set the EnableLUA value to something arbitrary, like 2, which |
| 238 // Vista will treat as UAC enabled, so we make sure it is not set to 0. | 238 // Vista will treat as UAC enabled, so we make sure it is not set to 0. |
| 239 return (uac_enabled != 0); | 239 return (uac_enabled != 0); |
| 240 } | 240 } |
| 241 | 241 |
| 242 bool SetBooleanValueForPropertyStore(IPropertyStore* property_store, | 242 bool SetBooleanValueForPropertyStore(IPropertyStore* property_store, |
| 243 const PROPERTYKEY& property_key, | 243 const PROPERTYKEY& property_key, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 return SetStringValueForPropertyStore(property_store, | 277 return SetStringValueForPropertyStore(property_store, |
| 278 PKEY_AppUserModel_ID, | 278 PKEY_AppUserModel_ID, |
| 279 app_id); | 279 app_id); |
| 280 } | 280 } |
| 281 | 281 |
| 282 static const char16 kAutoRunKeyPath[] = | 282 static const char16 kAutoRunKeyPath[] = |
| 283 L"Software\\Microsoft\\Windows\\CurrentVersion\\Run"; | 283 L"Software\\Microsoft\\Windows\\CurrentVersion\\Run"; |
| 284 | 284 |
| 285 bool AddCommandToAutoRun(HKEY root_key, const string16& name, | 285 bool AddCommandToAutoRun(HKEY root_key, const string16& name, |
| 286 const string16& command) { | 286 const string16& command) { |
| 287 base::win::RegKey autorun_key(root_key, kAutoRunKeyPath, KEY_SET_VALUE); | 287 RegKey autorun_key(root_key, kAutoRunKeyPath, KEY_SET_VALUE); |
| 288 return (autorun_key.WriteValue(name.c_str(), command.c_str()) == | 288 return (autorun_key.WriteValue(name.c_str(), command.c_str()) == |
| 289 ERROR_SUCCESS); | 289 ERROR_SUCCESS); |
| 290 } | 290 } |
| 291 | 291 |
| 292 bool RemoveCommandFromAutoRun(HKEY root_key, const string16& name) { | 292 bool RemoveCommandFromAutoRun(HKEY root_key, const string16& name) { |
| 293 base::win::RegKey autorun_key(root_key, kAutoRunKeyPath, KEY_SET_VALUE); | 293 RegKey autorun_key(root_key, kAutoRunKeyPath, KEY_SET_VALUE); |
| 294 return (autorun_key.DeleteValue(name.c_str()) == ERROR_SUCCESS); | 294 return (autorun_key.DeleteValue(name.c_str()) == ERROR_SUCCESS); |
| 295 } | 295 } |
| 296 | 296 |
| 297 bool ReadCommandFromAutoRun(HKEY root_key, | 297 bool ReadCommandFromAutoRun(HKEY root_key, |
| 298 const string16& name, | 298 const string16& name, |
| 299 string16* command) { | 299 string16* command) { |
| 300 base::win::RegKey autorun_key(root_key, kAutoRunKeyPath, KEY_QUERY_VALUE); | 300 RegKey autorun_key(root_key, kAutoRunKeyPath, KEY_QUERY_VALUE); |
| 301 return (autorun_key.ReadValue(name.c_str(), command) == ERROR_SUCCESS); | 301 return (autorun_key.ReadValue(name.c_str(), command) == ERROR_SUCCESS); |
| 302 } | 302 } |
| 303 | 303 |
| 304 void SetShouldCrashOnProcessDetach(bool crash) { | 304 void SetShouldCrashOnProcessDetach(bool crash) { |
| 305 g_crash_on_process_detach = crash; | 305 g_crash_on_process_detach = crash; |
| 306 } | 306 } |
| 307 | 307 |
| 308 bool ShouldCrashOnProcessDetach() { | 308 bool ShouldCrashOnProcessDetach() { |
| 309 return g_crash_on_process_detach; | 309 return g_crash_on_process_detach; |
| 310 } | 310 } |
| 311 | 311 |
| 312 void SetAbortBehaviorForCrashReporting() { | 312 void SetAbortBehaviorForCrashReporting() { |
| 313 // Prevent CRT's abort code from prompting a dialog or trying to "report" it. | 313 // Prevent CRT's abort code from prompting a dialog or trying to "report" it. |
| 314 // Disabling the _CALL_REPORTFAULT behavior is important since otherwise it | 314 // Disabling the _CALL_REPORTFAULT behavior is important since otherwise it |
| 315 // has the sideffect of clearing our exception filter, which means we | 315 // has the sideffect of clearing our exception filter, which means we |
| 316 // don't get any crash. | 316 // don't get any crash. |
| 317 _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT); | 317 _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT); |
| 318 | 318 |
| 319 // Set a SIGABRT handler for good measure. We will crash even if the default | 319 // Set a SIGABRT handler for good measure. We will crash even if the default |
| 320 // is left in place, however this allows us to crash earlier. And it also | 320 // is left in place, however this allows us to crash earlier. And it also |
| 321 // lets us crash in response to code which might directly call raise(SIGABRT) | 321 // lets us crash in response to code which might directly call raise(SIGABRT) |
| 322 signal(SIGABRT, ForceCrashOnSigAbort); | 322 signal(SIGABRT, ForceCrashOnSigAbort); |
| 323 } | 323 } |
| 324 | 324 |
| 325 bool IsTabletDevice() { | 325 bool IsTabletDevice() { |
| 326 if (GetSystemMetrics(SM_MAXIMUMTOUCHES) == 0) | 326 if (GetSystemMetrics(SM_MAXIMUMTOUCHES) == 0) |
| 327 return false; | 327 return false; |
| 328 | 328 |
| 329 base::win::Version version = base::win::GetVersion(); | 329 Version version = GetVersion(); |
| 330 if (version == base::win::VERSION_XP) | 330 if (version == VERSION_XP) |
| 331 return (GetSystemMetrics(SM_TABLETPC) != 0); | 331 return (GetSystemMetrics(SM_TABLETPC) != 0); |
| 332 | 332 |
| 333 // If the device is docked, the user is treating the device as a PC. | 333 // If the device is docked, the user is treating the device as a PC. |
| 334 if (GetSystemMetrics(SM_SYSTEMDOCKED) != 0) | 334 if (GetSystemMetrics(SM_SYSTEMDOCKED) != 0) |
| 335 return false; | 335 return false; |
| 336 | 336 |
| 337 // PlatformRoleSlate was only added in Windows 8, but prior to Win8 it is | 337 // PlatformRoleSlate was only added in Windows 8, but prior to Win8 it is |
| 338 // still possible to check for a mobile power profile. | 338 // still possible to check for a mobile power profile. |
| 339 POWER_PLATFORM_ROLE role = PowerDeterminePlatformRole(); | 339 POWER_PLATFORM_ROLE role = PowerDeterminePlatformRole(); |
| 340 bool mobile_power_profile = (role == PlatformRoleMobile); | 340 bool mobile_power_profile = (role == PlatformRoleMobile); |
| 341 bool slate_power_profile = false; | 341 bool slate_power_profile = false; |
| 342 if (version >= base::win::VERSION_WIN8) | 342 if (version >= VERSION_WIN8) |
| 343 slate_power_profile = (role == PlatformRoleSlate); | 343 slate_power_profile = (role == PlatformRoleSlate); |
| 344 | 344 |
| 345 if (mobile_power_profile || slate_power_profile) | 345 if (mobile_power_profile || slate_power_profile) |
| 346 return (GetSystemMetrics(SM_CONVERTIBLESLATEMODE) == 0); | 346 return (GetSystemMetrics(SM_CONVERTIBLESLATEMODE) == 0); |
| 347 | 347 |
| 348 return false; | 348 return false; |
| 349 } | 349 } |
| 350 | 350 |
| 351 bool DisplayVirtualKeyboard() { | 351 bool DisplayVirtualKeyboard() { |
| 352 if (base::win::GetVersion() < base::win::VERSION_WIN8) | 352 if (GetVersion() < VERSION_WIN8) |
| 353 return false; | 353 return false; |
| 354 | 354 |
| 355 if (IsKeyboardPresentOnSlate()) | 355 if (IsKeyboardPresentOnSlate()) |
| 356 return false; | 356 return false; |
| 357 | 357 |
| 358 static base::LazyInstance<string16>::Leaky osk_path = | 358 static LazyInstance<string16>::Leaky osk_path = LAZY_INSTANCE_INITIALIZER; |
| 359 LAZY_INSTANCE_INITIALIZER; | |
| 360 | 359 |
| 361 if (osk_path.Get().empty()) { | 360 if (osk_path.Get().empty()) { |
| 362 // We need to launch TabTip.exe from the location specified under the | 361 // We need to launch TabTip.exe from the location specified under the |
| 363 // LocalServer32 key for the {{054AAE20-4BEA-4347-8A35-64A533254A9D}} | 362 // LocalServer32 key for the {{054AAE20-4BEA-4347-8A35-64A533254A9D}} |
| 364 // CLSID. | 363 // CLSID. |
| 365 // TabTip.exe is typically found at | 364 // TabTip.exe is typically found at |
| 366 // c:\program files\common files\microsoft shared\ink on English Windows. | 365 // c:\program files\common files\microsoft shared\ink on English Windows. |
| 367 // We don't want to launch TabTip.exe from | 366 // We don't want to launch TabTip.exe from |
| 368 // c:\program files (x86)\common files\microsoft shared\ink. This path is | 367 // c:\program files (x86)\common files\microsoft shared\ink. This path is |
| 369 // normally found on 64 bit Windows. | 368 // normally found on 64 bit Windows. |
| 370 base::win::RegKey key(HKEY_LOCAL_MACHINE, | 369 RegKey key(HKEY_LOCAL_MACHINE, kWindows8OSKRegPath, |
| 371 kWindows8OSKRegPath, | 370 KEY_READ | KEY_WOW64_64KEY); |
| 372 KEY_READ | KEY_WOW64_64KEY); | |
| 373 DWORD osk_path_length = 1024; | 371 DWORD osk_path_length = 1024; |
| 374 if (key.ReadValue(NULL, | 372 if (key.ReadValue(NULL, |
| 375 WriteInto(&osk_path.Get(), osk_path_length), | 373 WriteInto(&osk_path.Get(), osk_path_length), |
| 376 &osk_path_length, | 374 &osk_path_length, |
| 377 NULL) != ERROR_SUCCESS) { | 375 NULL) != ERROR_SUCCESS) { |
| 378 DLOG(WARNING) << "Failed to read on screen keyboard path from registry"; | 376 DLOG(WARNING) << "Failed to read on screen keyboard path from registry"; |
| 379 return false; | 377 return false; |
| 380 } | 378 } |
| 381 size_t common_program_files_offset = | 379 size_t common_program_files_offset = |
| 382 osk_path.Get().find(L"%CommonProgramFiles%"); | 380 osk_path.Get().find(L"%CommonProgramFiles%"); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 403 DWORD buffer_size = | 401 DWORD buffer_size = |
| 404 GetEnvironmentVariable(L"CommonProgramW6432", NULL, 0); | 402 GetEnvironmentVariable(L"CommonProgramW6432", NULL, 0); |
| 405 if (buffer_size) { | 403 if (buffer_size) { |
| 406 common_program_files_wow6432.reset(new wchar_t[buffer_size]); | 404 common_program_files_wow6432.reset(new wchar_t[buffer_size]); |
| 407 GetEnvironmentVariable(L"CommonProgramW6432", | 405 GetEnvironmentVariable(L"CommonProgramW6432", |
| 408 common_program_files_wow6432.get(), | 406 common_program_files_wow6432.get(), |
| 409 buffer_size); | 407 buffer_size); |
| 410 common_program_files_path = common_program_files_wow6432.get(); | 408 common_program_files_path = common_program_files_wow6432.get(); |
| 411 DCHECK(!common_program_files_path.empty()); | 409 DCHECK(!common_program_files_path.empty()); |
| 412 } else { | 410 } else { |
| 413 base::win::ScopedCoMem<wchar_t> common_program_files; | 411 ScopedCoMem<wchar_t> common_program_files; |
| 414 if (FAILED(SHGetKnownFolderPath(FOLDERID_ProgramFilesCommon, 0, NULL, | 412 if (FAILED(SHGetKnownFolderPath(FOLDERID_ProgramFilesCommon, 0, NULL, |
| 415 &common_program_files))) { | 413 &common_program_files))) { |
| 416 return false; | 414 return false; |
| 417 } | 415 } |
| 418 common_program_files_path = common_program_files; | 416 common_program_files_path = common_program_files; |
| 419 } | 417 } |
| 420 | 418 |
| 421 osk_path.Get().insert(1, common_program_files_path); | 419 osk_path.Get().insert(1, common_program_files_path); |
| 422 } | 420 } |
| 423 } | 421 } |
| 424 | 422 |
| 425 HINSTANCE ret = ::ShellExecuteW(NULL, | 423 HINSTANCE ret = ::ShellExecuteW(NULL, |
| 426 L"", | 424 L"", |
| 427 osk_path.Get().c_str(), | 425 osk_path.Get().c_str(), |
| 428 NULL, | 426 NULL, |
| 429 NULL, | 427 NULL, |
| 430 SW_SHOW); | 428 SW_SHOW); |
| 431 return reinterpret_cast<intptr_t>(ret) > 32; | 429 return reinterpret_cast<intptr_t>(ret) > 32; |
| 432 } | 430 } |
| 433 | 431 |
| 434 bool DismissVirtualKeyboard() { | 432 bool DismissVirtualKeyboard() { |
| 435 if (base::win::GetVersion() < base::win::VERSION_WIN8) | 433 if (GetVersion() < VERSION_WIN8) |
| 436 return false; | 434 return false; |
| 437 | 435 |
| 438 // We dismiss the virtual keyboard by generating the ESC keystroke | 436 // We dismiss the virtual keyboard by generating the ESC keystroke |
| 439 // programmatically. | 437 // programmatically. |
| 440 const wchar_t kOSKClassName[] = L"IPTip_Main_Window"; | 438 const wchar_t kOSKClassName[] = L"IPTip_Main_Window"; |
| 441 HWND osk = ::FindWindow(kOSKClassName, NULL); | 439 HWND osk = ::FindWindow(kOSKClassName, NULL); |
| 442 if (::IsWindow(osk) && ::IsWindowEnabled(osk)) { | 440 if (::IsWindow(osk) && ::IsWindowEnabled(osk)) { |
| 443 PostMessage(osk, WM_SYSCOMMAND, SC_CLOSE, 0); | 441 PostMessage(osk, WM_SYSCOMMAND, SC_CLOSE, 0); |
| 444 return true; | 442 return true; |
| 445 } | 443 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 467 } | 465 } |
| 468 | 466 |
| 469 return g_domain_state == ENROLLED; | 467 return g_domain_state == ENROLLED; |
| 470 } | 468 } |
| 471 | 469 |
| 472 void SetDomainStateForTesting(bool state) { | 470 void SetDomainStateForTesting(bool state) { |
| 473 g_domain_state = state ? ENROLLED : NOT_ENROLLED; | 471 g_domain_state = state ? ENROLLED : NOT_ENROLLED; |
| 474 } | 472 } |
| 475 | 473 |
| 476 bool MaybeHasSHA256Support() { | 474 bool MaybeHasSHA256Support() { |
| 477 const base::win::OSInfo* os_info = base::win::OSInfo::GetInstance(); | 475 const OSInfo* os_info = OSInfo::GetInstance(); |
| 478 | 476 |
| 479 if (os_info->version() == base::win::VERSION_PRE_XP) | 477 if (os_info->version() == VERSION_PRE_XP) |
| 480 return false; // Too old to have it and this OS is not supported anyway. | 478 return false; // Too old to have it and this OS is not supported anyway. |
| 481 | 479 |
| 482 if (os_info->version() == base::win::VERSION_XP) | 480 if (os_info->version() == VERSION_XP) |
| 483 return os_info->service_pack().major >= 3; // Windows XP SP3 has it. | 481 return os_info->service_pack().major >= 3; // Windows XP SP3 has it. |
| 484 | 482 |
| 485 // Assume it is missing in this case, although it may not be. This category | 483 // Assume it is missing in this case, although it may not be. This category |
| 486 // includes Windows XP x64, and Windows Server, where a hotfix could be | 484 // includes Windows XP x64, and Windows Server, where a hotfix could be |
| 487 // deployed. | 485 // deployed. |
| 488 if (os_info->version() == base::win::VERSION_SERVER_2003) | 486 if (os_info->version() == VERSION_SERVER_2003) |
| 489 return false; | 487 return false; |
| 490 | 488 |
| 491 DCHECK(os_info->version() >= base::win::VERSION_VISTA); | 489 DCHECK(os_info->version() >= VERSION_VISTA); |
| 492 return true; // New enough to have SHA-256 support. | 490 return true; // New enough to have SHA-256 support. |
| 493 } | 491 } |
| 494 | 492 |
| 495 } // namespace win | 493 } // namespace win |
| 496 } // namespace base | 494 } // namespace base |
| OLD | NEW |