Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4716)

Unified Diff: chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.cc

Issue 276433003: UMA metrics added for HID detection dialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Refactored. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.cc
diff --git a/chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.cc
index 567a8ad77fba4cddef20dd7974a140a2a4019daf..90c9d585a11e7ec842c148d4886eb88f63929631 100644
--- a/chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.cc
+++ b/chrome/browser/ui/webui/chromeos/login/hid_detection_screen_handler.cc
@@ -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.
+ int scenario_type;
Alexei Svitkine (slow) 2014/05/14 14:57:48 Nit: ContinueScenarioType instead of int.
merkulova 2014/05/22 12:02:32 Done.
+ 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,6 +349,17 @@ 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,
+ base::Unretained(this)));
Alexei Svitkine (slow) 2014/05/14 14:57:48 Why not use weak_ptr_factory_.GetWeakPtr() instead
merkulova 2014/05/22 12:02:32 Done.
+}
+
void HIDDetectionScreenHandler::UpdateDevices() {
input_service_proxy_.GetDevices(
base::Bind(&HIDDetectionScreenHandler::OnGetInputDevicesList,
@@ -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();
Alexei Svitkine (slow) 2014/05/14 14:57:48 Nit: prefer an early return and no else block.
merkulova 2014/05/22 12:02:32 Done.
+ } else {
+ PrefService* const local_state = g_browser_process->local_state();
Alexei Svitkine (slow) 2014/05/14 14:57:48 Nit: Chromium style doesn't usually use const in t
merkulova 2014/05/22 12:02:32 Done.
+ 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())

Powered by Google App Engine
This is Rietveld 408576698