summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorzturner@chromium.org <zturner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-07 16:45:41 +0000
committerzturner@chromium.org <zturner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-07 16:45:41 +0000
commitcb424dfa6da29ac0626167f565f791ebb63d5205 (patch)
tree29ca83ceed3d3c32f13622b4925104ad22836e58 /base
parent873100d2a9eae863f7e6693b251ab1767ce1ef95 (diff)
downloadchromium_src-cb424dfa6da29ac0626167f565f791ebb63d5205.zip
chromium_src-cb424dfa6da29ac0626167f565f791ebb63d5205.tar.gz
chromium_src-cb424dfa6da29ac0626167f565f791ebb63d5205.tar.bz2
Add an UMA metric to track whether chrome is running on a tablet.
BUG=353701 R=cpu@chromium.org, isherman@chromium.org, thakis@chromium.org Review URL: https://codereview.chromium.org/262773015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@268825 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/base.gyp12
-rw-r--r--base/win/win_util.cc27
-rw-r--r--base/win/win_util.h5
3 files changed, 44 insertions, 0 deletions
diff --git a/base/base.gyp b/base/base.gyp
index e8b7d30..6127c4b 100644
--- a/base/base.gyp
+++ b/base/base.gyp
@@ -183,6 +183,18 @@
],
},
}],
+ ['OS == "win"', {
+ 'msvs_settings': {
+ 'VCLinkerTool': {
+ 'DelayLoadDLLs': [
+ 'powrprof.dll',
+ ],
+ 'AdditionalDependencies': [
+ 'powrprof.lib',
+ ],
+ },
+ },
+ }],
['OS != "win" and OS != "ios"', {
'dependencies': ['../third_party/libevent/libevent.gyp:libevent'],
},],
diff --git a/base/win/win_util.cc b/base/win/win_util.cc
index 601dd7c..061b2a4 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,32 @@ 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.
+ POWER_PLATFORM_ROLE role = PowerDeterminePlatformRole();
+ bool mobile_power_profile = (role == PlatformRoleMobile);
+ bool slate_power_profile = false;
+ if (version >= base::win::VERSION_WIN8)
+ slate_power_profile = (role == PlatformRoleSlate);
+
+ if (mobile_power_profile || slate_power_profile)
+ return (GetSystemMetrics(SM_CONVERTIBLESLATEMODE) == 0);
+
+ return false;
+}
+
bool DisplayVirtualKeyboard() {
if (base::win::GetVersion() < base::win::VERSION_WIN8)
return false;
diff --git a/base/win/win_util.h b/base/win/win_util.h
index 4a5c5cd..1c3f0f3 100644
--- a/base/win/win_util.h
+++ b/base/win/win_util.h
@@ -111,6 +111,11 @@ BASE_EXPORT void SetAbortBehaviorForCrashReporting();
// integrated multi-touch ready to use and has Windows version > Windows7.
BASE_EXPORT bool IsTouchEnabledDevice();
+// A tablet is a device that is touch enabled and also is being used
+// "like a tablet". This is used primarily for metrics in order to gain some
+// insight into how users use Chrome.
+BASE_EXPORT bool IsTabletDevice();
+
// Get the size of a struct up to and including the specified member.
// This is necessary to set compatible struct sizes for different versions
// of certain Windows APIs (e.g. SystemParametersInfo).