| 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> | |
| 10 #include <powrprof.h> | 9 #include <powrprof.h> |
| 11 #include <shobjidl.h> // Must be before propkey. | 10 #include <shobjidl.h> // Must be before propkey. |
| 12 #include <initguid.h> | 11 #include <initguid.h> |
| 13 #include <inspectable.h> | 12 #include <inspectable.h> |
| 14 #include <propkey.h> | 13 #include <propkey.h> |
| 15 #include <propvarutil.h> | 14 #include <propvarutil.h> |
| 16 #include <psapi.h> | 15 #include <psapi.h> |
| 17 #include <roapi.h> | 16 #include <roapi.h> |
| 18 #include <sddl.h> | 17 #include <sddl.h> |
| 19 #include <setupapi.h> | 18 #include <setupapi.h> |
| 19 #include <shlwapi.h> |
| 20 #include <signal.h> | 20 #include <signal.h> |
| 21 #include <stddef.h> | 21 #include <stddef.h> |
| 22 #include <stdlib.h> | 22 #include <stdlib.h> |
| 23 #include <tchar.h> // Must be before tpcshrd.h or for any use of _T macro | 23 #include <tchar.h> // Must be before tpcshrd.h or for any use of _T macro |
| 24 #include <tpcshrd.h> | 24 #include <tpcshrd.h> |
| 25 #include <uiviewsettingsinterop.h> | 25 #include <uiviewsettingsinterop.h> |
| 26 #include <windows.ui.viewmanagement.h> | 26 #include <windows.ui.viewmanagement.h> |
| 27 #include <winstring.h> | 27 #include <winstring.h> |
| 28 #include <wrl/wrappers/corewrappers.h> | 28 #include <wrl/wrappers/corewrappers.h> |
| 29 | 29 |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 "PlatformRoleSlate\n"; | 511 "PlatformRoleSlate\n"; |
| 512 } | 512 } |
| 513 } | 513 } |
| 514 } else { | 514 } else { |
| 515 if (reason) | 515 if (reason) |
| 516 *reason += "Device role is not mobile or slate.\n"; | 516 *reason += "Device role is not mobile or slate.\n"; |
| 517 } | 517 } |
| 518 return is_tablet; | 518 return is_tablet; |
| 519 } | 519 } |
| 520 | 520 |
| 521 enum DomainEnrollementState {UNKNOWN = -1, NOT_ENROLLED, ENROLLED}; | 521 enum DomainEnrollmentState {UNKNOWN = -1, NOT_ENROLLED, ENROLLED}; |
| 522 static volatile long int g_domain_state = UNKNOWN; | 522 static volatile long int g_domain_state = UNKNOWN; |
| 523 | 523 |
| 524 bool IsEnrolledToDomain() { | 524 bool IsEnrolledToDomain() { |
| 525 // Doesn't make any sense to retry inside a user session because joining a | 525 // Doesn't make any sense to retry inside a user session because joining a |
| 526 // domain will only kick in on a restart. | 526 // domain will only kick in on a restart. |
| 527 if (g_domain_state == UNKNOWN) { | 527 if (g_domain_state == UNKNOWN) { |
| 528 LPWSTR domain; | |
| 529 NETSETUP_JOIN_STATUS join_status; | |
| 530 if(::NetGetJoinInformation(NULL, &domain, &join_status) != NERR_Success) | |
| 531 return false; | |
| 532 ::NetApiBufferFree(domain); | |
| 533 ::InterlockedCompareExchange(&g_domain_state, | 528 ::InterlockedCompareExchange(&g_domain_state, |
| 534 join_status == ::NetSetupDomainName ? | 529 IsOS(OS_DOMAINMEMBER) ? |
| 535 ENROLLED : NOT_ENROLLED, | 530 ENROLLED : NOT_ENROLLED, |
| 536 UNKNOWN); | 531 UNKNOWN); |
| 537 } | 532 } |
| 538 | 533 |
| 539 return g_domain_state == ENROLLED; | 534 return g_domain_state == ENROLLED; |
| 540 } | 535 } |
| 541 | 536 |
| 542 void SetDomainStateForTesting(bool state) { | 537 void SetDomainStateForTesting(bool state) { |
| 543 g_domain_state = state ? ENROLLED : NOT_ENROLLED; | 538 g_domain_state = state ? ENROLLED : NOT_ENROLLED; |
| 544 } | 539 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 } | 592 } |
| 598 | 593 |
| 599 void DisableFlicks(HWND hwnd) { | 594 void DisableFlicks(HWND hwnd) { |
| 600 ::SetProp(hwnd, MICROSOFT_TABLETPENSERVICE_PROPERTY, | 595 ::SetProp(hwnd, MICROSOFT_TABLETPENSERVICE_PROPERTY, |
| 601 reinterpret_cast<HANDLE>(TABLET_DISABLE_FLICKS | | 596 reinterpret_cast<HANDLE>(TABLET_DISABLE_FLICKS | |
| 602 TABLET_DISABLE_FLICKFALLBACKKEYS)); | 597 TABLET_DISABLE_FLICKFALLBACKKEYS)); |
| 603 } | 598 } |
| 604 | 599 |
| 605 } // namespace win | 600 } // namespace win |
| 606 } // namespace base | 601 } // namespace base |
| OLD | NEW |