Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / components / autofill / ios / browser / keyboard_accessory_metrics_logger.mm
blob9f4bb781681a014f071f702f72f30e9de1477aa5
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"
12 namespace autofill {
14 namespace {
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);
22   } else {
23     UMA_HISTOGRAM_ENUMERATION(
24         "Autofill.KeyboardAccessoryButtonsIOS_ScreenReaderOff", metric,
25         KeyboardAccessoryMetricsLogger::NUM_BUTTON_METRICS);
26   }
29 }  // namespace
31 KeyboardAccessoryMetricsLogger::KeyboardAccessoryMetricsLogger()
32     : has_logged_close_button_(false),
33       has_logged_next_button_(false),
34       has_logged_previous_button_(false) {}
36 // static
37 void KeyboardAccessoryMetricsLogger::OnFormsLoaded() {
38   Log(FORMS_LOADED);
41 // static
42 void KeyboardAccessoryMetricsLogger::OnFormSubmitted() {
43   Log(SUBMITTED_FORM);
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);
51   }
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);
59   }
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);
67   }
70 }  // namespace autofill