UMA metrics added for HID detection dialog.

BUG=366850

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272526 0039d316-1c4b-4281-b951-d872f2087c98
parent 8e4f76b2
......@@ -734,6 +734,10 @@ void WizardController::PerformPostEulaActions() {
void WizardController::PerformOOBECompletedActions() {
StartupUtils::MarkOobeCompleted();
UMA_HISTOGRAM_COUNTS_100(
"HIDDetection.TimesDialogShownPerOOBECompleted",
GetLocalState()->GetInteger(prefs::kTimesHIDDialogShown));
GetLocalState()->ClearPref(prefs::kTimesHIDDialogShown);
}
void WizardController::SetCurrentScreen(WizardScreen* new_current) {
......
......@@ -161,6 +161,7 @@
#include "chrome/browser/chromeos/system/automatic_reboot_manager.h"
#include "chrome/browser/extensions/api/enterprise_platform_keys_private/enterprise_platform_keys_private_api.h"
#include "chrome/browser/ui/webui/chromeos/charger_replacement_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/network_screen_handler.h"
#include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h"
#else
......@@ -289,6 +290,7 @@ void RegisterLocalState(PrefRegistrySimple* registry) {
chromeos::KioskAppManager::RegisterPrefs(registry);
chromeos::LoginUtils::RegisterPrefs(registry);
chromeos::MultiProfileUserController::RegisterPrefs(registry);
chromeos::HIDDetectionScreenHandler::RegisterPrefs(registry);
chromeos::NetworkScreenHandler::RegisterPrefs(registry);
chromeos::Preferences::RegisterPrefs(registry);
chromeos::proxy_config::RegisterPrefs(registry);
......
......@@ -7,10 +7,14 @@
#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/metrics/histogram.h"
#include "base/prefs/pref_service.h"
#include "base/strings/string16.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h"
#include "chrome/common/pref_names.h"
#include "device/bluetooth/bluetooth_adapter_factory.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
......@@ -67,7 +71,7 @@ HIDDetectionScreenHandler::HIDDetectionScreenHandler()
mouse_is_pairing_(false),
keyboard_is_pairing_(false),
switch_on_adapter_when_ready_(false),
skip_screen_if_devices_present_(true),
first_time_screen_show_(true),
weak_ptr_factory_(this) {
}
......@@ -100,8 +104,8 @@ void HIDDetectionScreenHandler::Show() {
return;
}
input_service_proxy_.AddObserver(this);
skip_screen_if_devices_present_ = true;
UpdateDevices();
first_time_screen_show_ = true;
GetDevicesFirstTime();
ShowScreen(OobeUI::kScreenHIDDetection, NULL);
}
......@@ -155,6 +159,21 @@ void HIDDetectionScreenHandler::RegisterMessages() {
}
void HIDDetectionScreenHandler::HandleOnContinue() {
if (!first_time_screen_show_) {
// Continue button pressed.
ContinueScenarioType scenario_type;
if (!pointing_device_id_.empty() && !keyboard_device_id_.empty())
scenario_type = All_DEVICES_DETECTED;
else if (pointing_device_id_.empty())
scenario_type = KEYBOARD_DEVICE_ONLY_DETECTED;
else
scenario_type = POINTING_DEVICE_ONLY_DETECTED;
UMA_HISTOGRAM_ENUMERATION(
"HIDDetection.OOBEDevicesDetectedOnContinuePressed",
scenario_type,
CONTINUE_SCENARIO_TYPE_SIZE);
}
if (delegate_)
delegate_->OnExit();
}
......@@ -330,10 +349,21 @@ void HIDDetectionScreenHandler::OnInputDeviceRemoved(const std::string& id) {
}
}
// static
void HIDDetectionScreenHandler::RegisterPrefs(PrefRegistrySimple* registry) {
registry->RegisterIntegerPref(prefs::kTimesHIDDialogShown, 0);
}
void HIDDetectionScreenHandler::GetDevicesFirstTime() {
input_service_proxy_.GetDevices(
base::Bind(&HIDDetectionScreenHandler::OnGetInputDevicesListFirstTime,
weak_ptr_factory_.GetWeakPtr()));
}
void HIDDetectionScreenHandler::UpdateDevices() {
input_service_proxy_.GetDevices(
base::Bind(&HIDDetectionScreenHandler::OnGetInputDevicesList,
base::Unretained(this)));
weak_ptr_factory_.GetWeakPtr()));
}
void HIDDetectionScreenHandler::UpdateBTDevices() {
......@@ -353,7 +383,7 @@ void HIDDetectionScreenHandler::UpdateBTDevices() {
}
}
void HIDDetectionScreenHandler::OnGetInputDevicesList(
void HIDDetectionScreenHandler::ProcessConnectedDevicesList(
const std::vector<InputDeviceInfo>& devices) {
for (std::vector<InputDeviceInfo>::const_iterator it = devices.begin();
it != devices.end() &&
......@@ -372,14 +402,9 @@ void HIDDetectionScreenHandler::OnGetInputDevicesList(
SendKeyboardDeviceNotification(NULL);
}
}
// Skip screen if both devices are present and skip was requested.
if (!pointing_device_id_.empty() &&
!keyboard_device_id_.empty() &&
skip_screen_if_devices_present_) {
HandleOnContinue();
}
// Skip requested only once on dialog show.
skip_screen_if_devices_present_ = false;
}
void HIDDetectionScreenHandler::TryInitiateBTDevicesUpdate() {
if ((pointing_device_id_.empty() || keyboard_device_id_.empty()) &&
adapter_) {
if (!adapter_->IsPresent()) {
......@@ -398,6 +423,35 @@ void HIDDetectionScreenHandler::OnGetInputDevicesList(
}
}
void HIDDetectionScreenHandler::OnGetInputDevicesListFirstTime(
const std::vector<InputDeviceInfo>& devices) {
ProcessConnectedDevicesList(devices);
// Skip screen if both devices are present.
bool all_devices_autodetected = !pointing_device_id_.empty() &&
!keyboard_device_id_.empty();
UMA_HISTOGRAM_BOOLEAN("HIDDetection.OOBEDialogShown",
!all_devices_autodetected);
if (all_devices_autodetected) {
HandleOnContinue();
return;
}
PrefService* local_state = g_browser_process->local_state();
int num_of_times_dialog_was_shown = local_state->GetInteger(
prefs::kTimesHIDDialogShown);
local_state->SetInteger(prefs::kTimesHIDDialogShown,
num_of_times_dialog_was_shown + 1);
first_time_screen_show_ = false;
TryInitiateBTDevicesUpdate();
}
void HIDDetectionScreenHandler::OnGetInputDevicesList(
const std::vector<InputDeviceInfo>& devices) {
ProcessConnectedDevicesList(devices);
TryInitiateBTDevicesUpdate();
}
void HIDDetectionScreenHandler::ConnectBTDevice(
device::BluetoothDevice* device) {
if (!device->IsPairable() || device->IsPaired())
......
......@@ -11,6 +11,7 @@
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/prefs/pref_registry_simple.h"
#include "base/values.h"
#include "chrome/browser/chromeos/device/input_service_proxy.h"
#include "chrome/browser/chromeos/login/screens/hid_detection_screen_actor.h"
......@@ -78,7 +79,25 @@ class HIDDetectionScreenHandler
virtual void OnInputDeviceAdded(const InputDeviceInfo& info) OVERRIDE;
virtual void OnInputDeviceRemoved(const std::string& id) OVERRIDE;
// Registers the preference for derelict state.
static void RegisterPrefs(PrefRegistrySimple* registry);
private:
// Types of dialog leaving scenarios for UMA metric.
enum ContinueScenarioType {
// Only pointing device detected, user pressed 'Continue'.
POINTING_DEVICE_ONLY_DETECTED,
// Only keyboard detected, user pressed 'Continue'.
KEYBOARD_DEVICE_ONLY_DETECTED,
// All devices detected.
All_DEVICES_DETECTED,
// Must be last enum element.
CONTINUE_SCENARIO_TYPE_SIZE
};
void InitializeAdapter(scoped_refptr<device::BluetoothAdapter> adapter);
// Sends a notification to the Web UI of the status of available Bluetooth/USB
......@@ -89,6 +108,21 @@ class HIDDetectionScreenHandler
// keyboard device.
void SendKeyboardDeviceNotification(base::DictionaryValue* params);
// Updates internal state and UI using list of connected devices.
void ProcessConnectedDevicesList(const std::vector<InputDeviceInfo>& devices);
// Checks for lack of mouse or keyboard. If found starts BT devices update.
// Initiates BTAdapter if it's not active and BT devices update required.
void TryInitiateBTDevicesUpdate();
// Processes list of input devices returned by InputServiceProxy on the first
// time the screen is initiated. Skips the screen if all required devices are
// present.
void OnGetInputDevicesListFirstTime(
const std::vector<InputDeviceInfo>& devices);
// Processes list of input devices returned by InputServiceProxy on regular
// request.
void OnGetInputDevicesList(const std::vector<InputDeviceInfo>& devices);
void StartBTDiscoverySession();
......@@ -128,6 +162,10 @@ class HIDDetectionScreenHandler
// power BT adapter.
void SetPoweredError();
// Special case uf UpdateDevice. Called on first show, skips the dialog if
// all necessary devices (mouse and keyboard) already connected.
void GetDevicesFirstTime();
// Called for revision of active devices. If current-placement is available
// for mouse or keyboard device, sets one of active devices as current or
// tries to connect some BT device if no appropriate devices are connected.
......@@ -170,7 +208,7 @@ class HIDDetectionScreenHandler
bool switch_on_adapter_when_ready_;
bool skip_screen_if_devices_present_;
bool first_time_screen_show_;
base::WeakPtrFactory<HIDDetectionScreenHandler> weak_ptr_factory_;
......
......@@ -2030,6 +2030,9 @@ const char kDeviceEnrollmentAutoStart[] = "enrollment.auto_start";
// Whether the user may exit enrollment.
const char kDeviceEnrollmentCanExit[] = "enrollment.can_exit";
// How many times HID detection OOBE dialog was shown.
const char kTimesHIDDialogShown[] = "HIDDialog.shown_how_many_times";
// Dictionary of per-user Least Recently Used input method (used at login
// screen).
extern const char kUsersLRUInputMethod[] = "UsersLRUInputMethod";
......
......@@ -704,6 +704,7 @@ extern const char kDeviceRobotAnyApiRefreshToken[];
extern const char kDeviceEnrollmentRequisition[];
extern const char kDeviceEnrollmentAutoStart[];
extern const char kDeviceEnrollmentCanExit[];
extern const char kTimesHIDDialogShown[];
extern const char kUsersLRUInputMethod[];
extern const char kEchoCheckedOffers[];
extern const char kCachedMultiProfileUserBehavior[];
......
......@@ -7835,6 +7835,31 @@ Therefore, the affected-histogram name has to have at least one dot in it.
</summary>
</histogram>
<histogram name="HIDDetection.OOBEDevicesDetectedOnContinuePressed"
enum="HIDContinueScenarioType">
<owner>merkulova@chromium.org</owner>
<summary>
Which HID were detected when user pressed Continue on OOBE dialog. This
metric is specific to ChromeOS.
</summary>
</histogram>
<histogram name="HIDDetection.OOBEDialogShown">
<owner>merkulova@chromium.org</owner>
<summary>
Whether HID detection dialog was shown on OOBE. Logged on screen show or on
screen skip respectively. This metric is specific to ChromeOS.
</summary>
</histogram>
<histogram name="HIDDetection.TimesDialogShownPerOOBECompleted">
<owner>merkulova@chromium.org</owner>
<summary>
Records number of times the dialog was shown by the time OOBE is completed.
This metric is specific to ChromeOS.
</summary>
</histogram>
<histogram name="History.DeleteFTSIndexDatabases">
<owner>Please list the metric's owners. Add more owner tags as needed.</owner>
<summary>
......@@ -36259,6 +36284,13 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<int value="12" label="SERVICE_ERROR"/>
</enum>
<enum name="HIDContinueScenarioType" type="int">
<summary>Possible detected devices combination on leaving dialog</summary>
<int value="0" label="Pointing device only detected."/>
<int value="1" label="Keyboard device only detected."/>
<int value="2" label="Both devices, pointing and keyboard, detected."/>
</enum>
<enum name="HistoryFaviconsRecoveryEnum" type="int">
<summary>Error states noted in thumbnail_database.cc recovery code.</summary>
<int value="0" label="RECOVERY_EVENT_RECOVERED">Successful recovery.</int>
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