1 // Copyright 2015 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 #import "components/autofill/ios/browser/keyboard_accessory_metrics_logger.h"
7 #import <UIKit/UIKit.h>
9 #include "base/logging.h"
10 #include "base/metrics/histogram_macros.h"
16 void Log(KeyboardAccessoryMetricsLogger::ButtonMetric metric) {
17 DCHECK_LT(metric, KeyboardAccessoryMetricsLogger::NUM_BUTTON_METRICS);
18 if (UIAccessibilityIsVoiceOverRunning()) {
19 UMA_HISTOGRAM_ENUMERATION(
20 "Autofill.KeyboardAccessoryButtonsIOS_ScreenReaderOn", metric,
21 KeyboardAccessoryMetricsLogger::NUM_BUTTON_METRICS);
23 UMA_HISTOGRAM_ENUMERATION(
24 "Autofill.KeyboardAccessoryButtonsIOS_ScreenReaderOff", metric,
25 KeyboardAccessoryMetricsLogger::NUM_BUTTON_METRICS);
31 KeyboardAccessoryMetricsLogger::KeyboardAccessoryMetricsLogger()
32 : has_logged_close_button_(false),
33 has_logged_next_button_(false),
34 has_logged_previous_button_(false) {}
37 void KeyboardAccessoryMetricsLogger::OnFormsLoaded() {
42 void KeyboardAccessoryMetricsLogger::OnFormSubmitted() {
46 void KeyboardAccessoryMetricsLogger::OnCloseButtonPressed() {
47 Log(CLOSE_BUTTON_PRESSED);
48 if (!has_logged_close_button_) {
49 has_logged_close_button_ = true;
50 Log(CLOSE_BUTTON_PRESSED_ONCE);
54 void KeyboardAccessoryMetricsLogger::OnNextButtonPressed() {
55 Log(NEXT_BUTTON_PRESSED);
56 if (!has_logged_next_button_) {
57 has_logged_next_button_ = true;
58 Log(NEXT_BUTTON_PRESSED_ONCE);
62 void KeyboardAccessoryMetricsLogger::OnPreviousButtonPressed() {
63 Log(PREVIOUS_BUTTON_PRESSED);
64 if (!has_logged_previous_button_) {
65 has_logged_previous_button_ = true;
66 Log(PREVIOUS_BUTTON_PRESSED_ONCE);
70 } // namespace autofill