Commit fc3a6edf authored by Chris Lu's avatar Chris Lu Committed by Commit Bot

[ios] Add Infobar Badge UMA metrics

The UMA metrics logging for Infobar badges was removed in crrev.com/c/1717651.
This change adds it back in BadgeActionDispatcher. A new 'accepted' property
is added to the BadgeButton to determine badge state for the metrics.

Bug: 976901
Change-Id: Ic81988d59f6695a1b32e1ca0b4e340cc20966d52
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1749602
Commit-Queue: Chris Lu <thegreenfrog@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#686621}
parent bf4664e7
...@@ -18,6 +18,9 @@ ...@@ -18,6 +18,9 @@
// The badge type of the button. // The badge type of the button.
@property(nonatomic, assign, readonly) BadgeType badgeType; @property(nonatomic, assign, readonly) BadgeType badgeType;
// Whether the button is in an accepted state.
@property(nonatomic, assign, readonly) BOOL accepted;
// Sets the badge color to the accepted color if |accepted| is YES or the // Sets the badge color to the accepted color if |accepted| is YES or the
// default color if |accepted| is NO. Will animate change if |animated| is YES. // default color if |accepted| is NO. Will animate change if |animated| is YES.
- (void)setAccepted:(BOOL)accepted animated:(BOOL)animated; - (void)setAccepted:(BOOL)accepted animated:(BOOL)animated;
......
...@@ -24,6 +24,8 @@ const CGFloat kButtonCircularCornerRadiusDivisor = 2.0; ...@@ -24,6 +24,8 @@ const CGFloat kButtonCircularCornerRadiusDivisor = 2.0;
// Read/Write override. // Read/Write override.
@property(nonatomic, assign, readwrite) BadgeType badgeType; @property(nonatomic, assign, readwrite) BadgeType badgeType;
// Read/Write override.
@property(nonatomic, assign, readwrite) BOOL accepted;
@end @end
...@@ -49,6 +51,7 @@ const CGFloat kButtonCircularCornerRadiusDivisor = 2.0; ...@@ -49,6 +51,7 @@ const CGFloat kButtonCircularCornerRadiusDivisor = 2.0;
} }
- (void)setAccepted:(BOOL)accepted animated:(BOOL)animated { - (void)setAccepted:(BOOL)accepted animated:(BOOL)animated {
self.accepted = accepted;
void (^changeTintColor)() = ^{ void (^changeTintColor)() = ^{
self.tintColor = accepted ? [UIColor colorNamed:kBlueColor] self.tintColor = accepted ? [UIColor colorNamed:kBlueColor]
: [UIColor colorNamed:kToolbarButtonColor]; : [UIColor colorNamed:kToolbarButtonColor];
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#import "ios/chrome/browser/ui/badges/badge_button_action_handler.h" #import "ios/chrome/browser/ui/badges/badge_button_action_handler.h"
#include "base/mac/foundation_util.h" #include "base/mac/foundation_util.h"
#include "base/metrics/user_metrics.h"
#include "ios/chrome/browser/infobars/infobar_metrics_recorder.h"
#import "ios/chrome/browser/infobars/infobar_type.h" #import "ios/chrome/browser/infobars/infobar_type.h"
#import "ios/chrome/browser/ui/badges/badge_button.h" #import "ios/chrome/browser/ui/badges/badge_button.h"
#import "ios/chrome/browser/ui/commands/infobar_commands.h" #import "ios/chrome/browser/ui/commands/infobar_commands.h"
...@@ -17,11 +19,28 @@ ...@@ -17,11 +19,28 @@
- (void)passwordsBadgeButtonTapped:(id)sender { - (void)passwordsBadgeButtonTapped:(id)sender {
BadgeButton* badgeButton = base::mac::ObjCCastStrict<BadgeButton>(sender); BadgeButton* badgeButton = base::mac::ObjCCastStrict<BadgeButton>(sender);
MobileMessagesBadgeState state;
if (badgeButton.accepted) {
state = MobileMessagesBadgeState::Active;
base::RecordAction(
base::UserMetricsAction("MobileMessagesBadgeAcceptedTapped"));
} else {
state = MobileMessagesBadgeState::Inactive;
base::RecordAction(
base::UserMetricsAction("MobileMessagesBadgeNonAcceptedTapped"));
}
InfobarMetricsRecorder* metricsRecorder;
if (badgeButton.badgeType == BadgeType::kBadgeTypePasswordSave) { if (badgeButton.badgeType == BadgeType::kBadgeTypePasswordSave) {
metricsRecorder = [[InfobarMetricsRecorder alloc]
initWithType:InfobarType::kInfobarTypePasswordSave];
[self.dispatcher displayModalInfobar:InfobarType::kInfobarTypePasswordSave]; [self.dispatcher displayModalInfobar:InfobarType::kInfobarTypePasswordSave];
} else if (badgeButton.badgeType == BadgeType::kBadgeTypePasswordUpdate) { } else if (badgeButton.badgeType == BadgeType::kBadgeTypePasswordUpdate) {
[self.dispatcher displayModalInfobar:InfobarType::kInfobarTypePasswordSave]; metricsRecorder = [[InfobarMetricsRecorder alloc]
initWithType:InfobarType::kInfobarTypePasswordUpdate];
[self.dispatcher
displayModalInfobar:InfobarType::kInfobarTypePasswordUpdate];
} }
[metricsRecorder recordBadgeTappedInState:state];
} }
@end @end
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