Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / content / browser / accessibility / browser_accessibility_state_impl_win.cc
blobddce50ec60e9ac2027c09040c136593a91b166f6
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
3 // found in the LICENSE file.
5 #include "content/browser/accessibility/browser_accessibility_state_impl.h"
7 #include <windows.h>
8 #include <psapi.h>
10 #include "base/files/file_path.h"
11 #include "base/macros.h"
12 #include "base/metrics/histogram.h"
13 #include "base/strings/string_util.h"
15 namespace content {
17 void BrowserAccessibilityStateImpl::UpdatePlatformSpecificHistograms() {
18 // NOTE: this method is run from the file thread to reduce jank, since
19 // there's no guarantee these system calls will return quickly. Be careful
20 // not to add any code that isn't safe to run from a non-main thread!
22 AUDIODESCRIPTION audio_description = {0};
23 audio_description.cbSize = sizeof(AUDIODESCRIPTION);
24 SystemParametersInfo(SPI_GETAUDIODESCRIPTION, 0, &audio_description, 0);
25 UMA_HISTOGRAM_BOOLEAN("Accessibility.WinAudioDescription",
26 !!audio_description.Enabled);
28 BOOL win_screen_reader = FALSE;
29 SystemParametersInfo(SPI_GETSCREENREADER, 0, &win_screen_reader, 0);
30 UMA_HISTOGRAM_BOOLEAN("Accessibility.WinScreenReader",
31 !!win_screen_reader);
33 STICKYKEYS sticky_keys = {0};
34 sticky_keys.cbSize = sizeof(STICKYKEYS);
35 SystemParametersInfo(SPI_GETSTICKYKEYS, 0, &sticky_keys, 0);
36 UMA_HISTOGRAM_BOOLEAN("Accessibility.WinStickyKeys",
37 0 != (sticky_keys.dwFlags & SKF_STICKYKEYSON));
39 // Get the file paths of all DLLs loaded.
40 HANDLE process = GetCurrentProcess();
41 HMODULE* modules = NULL;
42 DWORD bytes_required;
43 if (!EnumProcessModules(process, modules, 0, &bytes_required))
44 return;
46 scoped_ptr<char[]> buffer(new char[bytes_required]);
47 modules = reinterpret_cast<HMODULE*>(buffer.get());
48 DWORD ignore;
49 if (!EnumProcessModules(process, modules, bytes_required, &ignore))
50 return;
52 // Look for DLLs of assistive technology known to work with Chrome.
53 bool jaws = false;
54 bool nvda = false;
55 bool satogo = false;
56 bool zoomtext = false;
57 size_t module_count = bytes_required / sizeof(HMODULE);
58 for (size_t i = 0; i < module_count; i++) {
59 TCHAR filename[MAX_PATH];
60 GetModuleFileName(modules[i], filename, arraysize(filename));
61 base::string16 module_name(base::FilePath(filename).BaseName().value());
62 if (LowerCaseEqualsASCII(module_name, "fsdomsrv.dll"))
63 jaws = true;
64 if (LowerCaseEqualsASCII(module_name, "vbufbackend_gecko_ia2.dll"))
65 nvda = true;
66 if (LowerCaseEqualsASCII(module_name, "stsaw32.dll"))
67 satogo = true;
68 if (LowerCaseEqualsASCII(module_name, "zslhook.dll"))
69 zoomtext = true;
72 UMA_HISTOGRAM_BOOLEAN("Accessibility.WinJAWS", jaws);
73 UMA_HISTOGRAM_BOOLEAN("Accessibility.WinNVDA", nvda);
74 UMA_HISTOGRAM_BOOLEAN("Accessibility.WinSAToGo", satogo);
75 UMA_HISTOGRAM_BOOLEAN("Accessibility.WinZoomText", zoomtext);
78 } // namespace content