Chromium Code Reviews| Index: base/win/win_util.cc |
| diff --git a/base/win/win_util.cc b/base/win/win_util.cc |
| index 601dd7cd28847e1facb06d26b66f4952335124d0..358751261c4c26664cd33317286a7dbaee56a007 100644 |
| --- a/base/win/win_util.cc |
| +++ b/base/win/win_util.cc |
| @@ -6,6 +6,7 @@ |
| #include <aclapi.h> |
| #include <lm.h> |
| +#include <powrprof.h> |
| #include <shellapi.h> |
| #include <shlobj.h> |
| #include <shobjidl.h> // Must be before propkey. |
| @@ -232,6 +233,34 @@ bool IsTouchEnabledDevice() { |
| return false; |
| } |
| +bool IsTabletDevice() { |
| + if (GetSystemMetrics(SM_MAXIMUMTOUCHES) == 0) |
| + return false; |
| + |
| + base::win::Version version = base::win::GetVersion(); |
| + if (version == base::win::VERSION_XP) |
| + return (GetSystemMetrics(SM_TABLETPC) != 0); |
| + |
| + // If the device is docked, the user is treating the device as a PC. |
| + if (GetSystemMetrics(SM_SYSTEMDOCKED) != 0) |
| + return false; |
| + |
| + // PlatformRoleSlate was only added in Windows 8, but prior to Win8 it is |
| + // still possible to check for a mobile power profile. |
| + bool has_tablet_power_profile = false; |
|
cpu_(ooo_6.6-7.5)
2014/05/06 19:48:45
seems we can init has_table_power_profile in line
|
| + POWER_PLATFORM_ROLE role = PowerDeterminePlatformRole(); |
| + has_tablet_power_profile = (role == PlatformRoleMobile); |
| + if (version >= base::win::VERSION_WIN8) |
| + has_tablet_power_profile |= (role == PlatformRoleSlate); |
|
cpu_(ooo_6.6-7.5)
2014/05/06 19:48:45
the bitwise or scares me. Can you change to good o
|
| + |
| + if (has_tablet_power_profile) { |
| + bool slate_mode = (GetSystemMetrics(SM_CONVERTIBLESLATEMODE) == 0); |
| + return slate_mode; |
| + } |
| + |
| + return false; |
| +} |
| + |
| bool DisplayVirtualKeyboard() { |
| if (base::win::GetVersion() < base::win::VERSION_WIN8) |
| return false; |