From 8b2c54e7bacc29372dff990016e90e7152ac9cee Mon Sep 17 00:00:00 2001 From: Christian Xu Date: Tue, 15 Aug 2023 01:27:03 +0000 Subject: [PATCH] [iOS][Settings][M117] Add metrics for Address Bar settings page Add user action for the address bar settings page actions. - Page shown - Top address bar selected - Bottom address bar selected - Back button tapped - Page dismissed (cherry picked from commit 8e48a245a427e2b8ee492f1cc65af6adeba4f36f) Bug: 1470688 Change-Id: I2c835f1d1f57c1b924412838647faf869ba8f7df Low-Coverage-Reason: UI with no existing coverage. Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4757059 Reviewed-by: Elly FJ Reviewed-by: Gauthier Ambard Commit-Queue: Christian Xu Auto-Submit: Christian Xu Cr-Original-Commit-Position: refs/heads/main@{#1182121} Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4771482 Cr-Commit-Position: refs/branch-heads/5938@{#129} Cr-Branched-From: 2b50cb4bcc2318034581a816714d9535dc38966d-refs/heads/main@{#1181205} --- .../address_bar_preference_view_controller.h | 4 +- .../address_bar_preference_view_controller.mm | 11 +++++ .../cells/address_bar_options_item.mm | 11 +++++ .../settings_table_view_controller.mm | 1 + tools/metrics/actions/actions.xml | 43 +++++++++++++++++++ 5 files changed, 69 insertions(+), 1 deletion(-) diff --git a/ios/chrome/browser/ui/settings/address_bar_preference/address_bar_preference_view_controller.h b/ios/chrome/browser/ui/settings/address_bar_preference/address_bar_preference_view_controller.h index 5227c18275c574..f0ccfd1b581992 100644 --- a/ios/chrome/browser/ui/settings/address_bar_preference/address_bar_preference_view_controller.h +++ b/ios/chrome/browser/ui/settings/address_bar_preference/address_bar_preference_view_controller.h @@ -6,13 +6,15 @@ #define IOS_CHROME_BROWSER_UI_SETTINGS_ADDRESS_BAR_PREFERENCE_ADDRESS_BAR_PREFERENCE_VIEW_CONTROLLER_H_ #import "ios/chrome/browser/ui/settings/address_bar_preference/address_bar_preference_consumer.h" +#import "ios/chrome/browser/ui/settings/settings_controller_protocol.h" #import "ios/chrome/browser/ui/settings/settings_root_table_view_controller.h" @protocol AddressBarPreferenceServiceDelegate; // This class is the view controller for the address bar preference setting. @interface AddressBarPreferenceViewController - : SettingsRootTableViewController + : SettingsRootTableViewController @property(nonatomic, weak) id prefServiceDelegate; diff --git a/ios/chrome/browser/ui/settings/address_bar_preference/address_bar_preference_view_controller.mm b/ios/chrome/browser/ui/settings/address_bar_preference/address_bar_preference_view_controller.mm index 0b9f8177cda22b..64d63ede0a9eb1 100644 --- a/ios/chrome/browser/ui/settings/address_bar_preference/address_bar_preference_view_controller.mm +++ b/ios/chrome/browser/ui/settings/address_bar_preference/address_bar_preference_view_controller.mm @@ -4,6 +4,7 @@ #import "ios/chrome/browser/ui/settings/address_bar_preference/address_bar_preference_view_controller.h" +#import "base/metrics/user_metrics.h" #import "ios/chrome/browser/ui/settings/address_bar_preference/cells/address_bar_options_item.h" #import "ios/chrome/grit/ios_strings.h" #import "ui/base/l10n/l10n_util_mac.h" @@ -67,4 +68,14 @@ - (void)setPreferenceForOmniboxAtBottom:(BOOL)omniboxAtBottom { } } +#pragma mark - SettingsControllerProtocol + +- (void)reportDismissalUserAction { + base::RecordAction(base::UserMetricsAction("Settings.AddressBar.Dismissed")); +} + +- (void)reportBackUserAction { + base::RecordAction(base::UserMetricsAction("Settings.AddressBar.Back")); +} + @end diff --git a/ios/chrome/browser/ui/settings/address_bar_preference/cells/address_bar_options_item.mm b/ios/chrome/browser/ui/settings/address_bar_preference/cells/address_bar_options_item.mm index 153a54e6068a00..6b9b25bdf8c15b 100644 --- a/ios/chrome/browser/ui/settings/address_bar_preference/cells/address_bar_options_item.mm +++ b/ios/chrome/browser/ui/settings/address_bar_preference/cells/address_bar_options_item.mm @@ -4,6 +4,7 @@ #import "ios/chrome/browser/ui/settings/address_bar_preference/cells/address_bar_options_item.h" +#import "base/metrics/user_metrics.h" #import "ios/chrome/browser/shared/ui/symbols/symbols.h" #import "ios/chrome/browser/ui/settings/address_bar_preference/cells/address_bar_option_item_view.h" #import "ios/chrome/browser/ui/settings/address_bar_preference/cells/address_bar_preference_service_delegate.h" @@ -121,12 +122,22 @@ - (UIStackView*)addressBarPreferenceOptionsContent { // Notifies the address bar preference service to update the state to top // address bar. - (void)onSelectTopAddressBar { + if (_topAddressBar.selected) { + return; + } + base::RecordAction( + base::UserMetricsAction("Settings.AddressBar.TopAddressBar")); [_addressBarpreferenceServiceDelegate didSelectTopAddressBarPreference]; } // Notifies the address bar preference service to update the state to bottom // address bar. - (void)onSelectBottomAddressBar { + if (_bottomAddressBar.selected) { + return; + } + base::RecordAction( + base::UserMetricsAction("Settings.AddressBar.BottomAddressBar")); [_addressBarpreferenceServiceDelegate didSelectBottomAddressBarPreference]; } diff --git a/ios/chrome/browser/ui/settings/settings_table_view_controller.mm b/ios/chrome/browser/ui/settings/settings_table_view_controller.mm index d4d65f136916cf..b57f01a711987e 100644 --- a/ios/chrome/browser/ui/settings/settings_table_view_controller.mm +++ b/ios/chrome/browser/ui/settings/settings_table_view_controller.mm @@ -1386,6 +1386,7 @@ - (void)tableView:(UITableView*)tableView initWithBrowserState:_browserState]; break; case SettingsItemTypeAddressBar: + base::RecordAction(base::UserMetricsAction("Settings.AddressBar.Opened")); [self showAddressBarPreferenceSetting]; break; case SettingsItemTypePasswords: diff --git a/tools/metrics/actions/actions.xml b/tools/metrics/actions/actions.xml index 14271c542c1a8e..c291fc84331b66 100644 --- a/tools/metrics/actions/actions.xml +++ b/tools/metrics/actions/actions.xml @@ -29790,6 +29790,49 @@ should be able to be added at any place in this file. + + christianxu@chromium.org + gambard@chromium.org + + Reported when user clicks the back button on the Address Bar Settings. iOS + only. + + + + + christianxu@chromium.org + gambard@chromium.org + + Reported when user selects bottom address bar in Address Bar Settings. iOS + only. + + + + + christianxu@chromium.org + gambard@chromium.org + + Reported when user dismisses the Address Bar Settings. iOS only. + + + + + christianxu@chromium.org + gambard@chromium.org + + Reported when user navigates to Address Bar Settings. iOS only. + + + + + christianxu@chromium.org + gambard@chromium.org + + Reported when user selects top address bar in Address Bar Settings. iOS + only. + + + gambard@chromium.org sczs@chromium.org