Commit 89430150 authored by dmazzoni@chromium.org's avatar dmazzoni@chromium.org

Re-land: Add Chrome OS accessibility histograms.

BUG=99504
TBR=joi

Review URL: https://codereview.chromium.org/11414232

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170786 0039d316-1c4b-4281-b951-d872f2087c98
parent beee3435
......@@ -13,6 +13,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/logging.h"
#include "base/metrics/histogram.h"
#include "chrome/browser/accessibility/accessibility_extension_api.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/accessibility/magnification_manager.h"
......@@ -31,6 +32,7 @@
#include "chrome/common/extensions/user_script.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/browser_accessibility_state.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
......@@ -112,6 +114,20 @@ class ContentScriptLoader {
std::queue<ExtensionResource> resources_;
};
void UpdateChromeOSAccessibilityHistograms() {
UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosSpokenFeedback",
IsSpokenFeedbackEnabled());
UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosHighContrast",
IsHighContrastEnabled());
UMA_HISTOGRAM_BOOLEAN("Accessibility.CrosVirtualKeyboard",
IsVirtualKeyboardEnabled());
}
void Initialize() {
content::BrowserAccessibilityState::GetInstance()->AddHistogramCallback(
base::Bind(&UpdateChromeOSAccessibilityHistograms));
}
void EnableSpokenFeedback(bool enabled, content::WebUI* login_web_ui) {
bool spoken_feedback_enabled = g_browser_process &&
g_browser_process->local_state()->GetBoolean(
......@@ -248,6 +264,16 @@ bool IsHighContrastEnabled() {
return high_contrast_enabled;
}
bool IsVirtualKeyboardEnabled() {
if (!g_browser_process) {
return false;
}
PrefService* prefs = g_browser_process->local_state();
bool virtual_keyboard_enabled = prefs &&
prefs->GetBoolean(prefs::kVirtualKeyboardEnabled);
return virtual_keyboard_enabled;
}
ash::MagnifierType GetMagnifierType() {
if (!MagnificationManager::GetInstance())
return ash::MAGNIFIER_OFF;
......
......@@ -18,6 +18,9 @@ class WebUI;
namespace chromeos {
namespace accessibility {
// Do any accessibility initialization that should happen once on startup.
void Initialize();
// Enables or disables spoken feedback. Enabling spoken feedback installs the
// ChromeVox component extension. If this is being called in a login/oobe
// login screen, pass the WebUI object in login_web_ui so that ChromeVox
......@@ -46,6 +49,9 @@ bool IsSpokenFeedbackEnabled();
// Returns true if High Contrast is enabled, or false if not.
bool IsHighContrastEnabled();
// Returns true if the Virtual Keyboard is enabled, or false if not.
bool IsVirtualKeyboardEnabled();
// Returns the current state of the screen magnifier.
ash::MagnifierType GetMagnifierType();
......
......@@ -17,6 +17,7 @@
#include "base/string_number_conversions.h"
#include "base/string_split.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/accessibility/accessibility_util.h"
#include "chrome/browser/chromeos/accessibility/magnification_manager.h"
#include "chrome/browser/chromeos/audio/audio_handler.h"
#include "chrome/browser/chromeos/boot_times_loader.h"
......@@ -528,6 +529,7 @@ void ChromeBrowserMainPartsChromeos::PostProfileInit() {
}
magnification_manager_.reset(
chromeos::MagnificationManager::CreateInstance());
chromeos::accessibility::Initialize();
primary_display_switch_observer_.reset(
new PrimaryDisplaySwitchObserver());
......
......@@ -80,9 +80,17 @@ bool BrowserAccessibilityStateImpl::IsAccessibleBrowser() {
return (accessibility_mode_ == AccessibilityModeComplete);
}
void BrowserAccessibilityStateImpl::AddHistogramCallback(
base::Closure callback) {
histogram_callbacks_.push_back(callback);
}
void BrowserAccessibilityStateImpl::UpdateHistogram() {
UpdatePlatformSpecificHistograms();
for (size_t i = 0; i < histogram_callbacks_.size(); ++i)
histogram_callbacks_[i].Run();
UMA_HISTOGRAM_BOOLEAN("Accessibility.State", IsAccessibleBrowser());
UMA_HISTOGRAM_BOOLEAN("Accessibility.InvertedColors",
gfx::IsInvertedColorScheme());
......
......@@ -5,6 +5,8 @@
#ifndef CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_STATE_IMPL_H_
#define CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_STATE_IMPL_H_
#include <vector>
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/singleton.h"
......@@ -41,6 +43,7 @@ class CONTENT_EXPORT BrowserAccessibilityStateImpl
virtual void OnAccessibilityEnabledManually() OVERRIDE;
virtual void OnScreenReaderDetected() OVERRIDE;
virtual bool IsAccessibleBrowser() OVERRIDE;
virtual void AddHistogramCallback(base::Closure callback) OVERRIDE;
// Called a short while after startup to allow time for the accessibility
// state to be determined. Updates a histogram with the current state.
......@@ -60,6 +63,8 @@ class CONTENT_EXPORT BrowserAccessibilityStateImpl
AccessibilityMode accessibility_mode_;
std::vector<base::Closure> histogram_callbacks_;
DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityStateImpl);
};
......
......@@ -5,6 +5,7 @@
#ifndef CONTENT_PUBLIC_BROWSER_BROWSER_ACCESSIBILITY_STATE_H_
#define CONTENT_PUBLIC_BROWSER_BROWSER_ACCESSIBILITY_STATE_H_
#include "base/callback_forward.h"
#include "content/common/content_export.h"
namespace content {
......@@ -27,6 +28,12 @@ class CONTENT_EXPORT BrowserAccessibilityState {
// Returns true if the browser should be customized for accessibility.
virtual bool IsAccessibleBrowser() = 0;
// Add a callback method that will be called once, a small while after the
// browser starts up, when accessibility state histograms are updated.
// Use this to register a method to update additional accessibility
// histograms.
virtual void AddHistogramCallback(base::Closure callback) = 0;
};
} // namespace content
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment