Commit d5e1dcb4 authored by Mark Cogan's avatar Mark Cogan Committed by Commit Bot

[iOS] Add more Tab Grid metrics.

This CL adds metrics to track:
  - Use of the new Close All and Undo Close All controls.
  - Use of interactive tab grid reordering.

Bug: 880845
Cq-Include-Trybots: luci.chromium.try:ios-simulator-cronet;luci.chromium.try:ios-simulator-full-configs
Change-Id: I822044ea7bd1065a987d50dd03842662fa618a41
Reviewed-on: https://chromium-review.googlesource.com/1206433Reviewed-by: default avataredchin <edchin@chromium.org>
Reviewed-by: default avatarSteven Holte <holte@chromium.org>
Commit-Queue: Mark Cogan <marq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589468}
parent 4dc2dd06
......@@ -67,7 +67,8 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
@property(nonatomic, strong) GridLayout* defaultLayout;
// The layout used while the grid is being reordered.
@property(nonatomic, strong) UICollectionViewLayout* reorderingLayout;
// YES if, when reordering is enabled, the order of the cells has changed.
@property(nonatomic, assign) BOOL hasChangedOrder;
@end
@implementation GridViewController
......@@ -88,6 +89,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
@synthesize emptyStateAnimator = _emptyStateAnimator;
@synthesize defaultLayout = _defaultLayout;
@synthesize reorderingLayout = _reorderingLayout;
@synthesize hasChangedOrder = _hasChangedOrder;
- (instancetype)init {
if (self = [super init]) {
......@@ -286,7 +288,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
GridItem* item = self.items[source];
[self.items removeObjectAtIndex:source];
[self.items insertObject:item atIndex:destination];
self.hasChangedOrder = YES;
[self.delegate gridViewController:self
didMoveItemWithID:item.identifier
toIndex:destination];
......@@ -587,6 +589,8 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
if (!moving) {
gesture.enabled = NO;
} else {
base::RecordAction(
base::UserMetricsAction("MobileTabGridBeganReordering"));
CGPoint cellCenter =
[self.collectionView cellForItemAtIndexPath:path].center;
self.itemReorderTouchPoint =
......@@ -624,12 +628,14 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
animated:YES];
}];
[self.collectionView endInteractiveMovement];
[self recordInteractiveReordering];
[CATransaction commit];
break;
}
case UIGestureRecognizerStateCancelled:
self.itemReorderTouchPoint = CGPointZero;
[self.collectionView cancelInteractiveMovement];
[self recordInteractiveReordering];
[self.collectionView setCollectionViewLayout:self.defaultLayout
animated:YES];
// Re-enable cancelled gesture.
......@@ -649,4 +655,14 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
[self.collectionView updateInteractiveMovementTargetPosition:targetLocation];
}
- (void)recordInteractiveReordering {
if (self.hasChangedOrder) {
base::RecordAction(base::UserMetricsAction("MobileTabGridReordered"));
} else {
base::RecordAction(
base::UserMetricsAction("MobileTabGridEndedWithoutReordering"));
}
self.hasChangedOrder = NO;
}
@end
......@@ -1245,14 +1245,20 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) {
- (void)closeAllButtonTapped:(id)sender {
switch (self.currentPage) {
case TabGridPageIncognitoTabs:
base::RecordAction(
base::UserMetricsAction("MobileTabGridCloseAllIncognitoTabs"));
[self.incognitoTabsDelegate closeAllItems];
break;
case TabGridPageRegularTabs:
DCHECK_EQ(self.undoCloseAllAvailable,
self.regularTabsViewController.gridEmpty);
if (self.undoCloseAllAvailable) {
base::RecordAction(
base::UserMetricsAction("MobileTabGridUndoCloseAllRegularTabs"));
[self.regularTabsDelegate undoCloseAllItems];
} else {
base::RecordAction(
base::UserMetricsAction("MobileTabGridCloseAllRegularTabs"));
[self.regularTabsDelegate saveAndCloseAllItems];
}
self.undoCloseAllAvailable = !self.undoCloseAllAvailable;
......
......@@ -11766,6 +11766,57 @@ should be able to be added at any place in this file.
</description>
</action>
<action name="MobileTabGridBeganReordering">
<owner>edchin@chromium.org</owner>
<owner>marq@chromium.org</owner>
<description>User in the iOS tab grid began reordering tabs.</description>
</action>
<action name="MobileTabGridCloseAllIncognitoTabs">
<owner>edchin@chromium.org</owner>
<owner>marq@chromium.org</owner>
<description>
User in the iOS tab grid used the Close All control while viewing the
incognito tabs.
</description>
</action>
<action name="MobileTabGridCloseAllRegularTabs">
<owner>edchin@chromium.org</owner>
<owner>marq@chromium.org</owner>
<description>
User in the iOS tab grid used the Close All control while viewing the
regular tabs.
</description>
</action>
<action name="MobileTabGridEndedWithoutReordering">
<owner>edchin@chromium.org</owner>
<owner>marq@chromium.org</owner>
<description>
User in the iOS tab grid finished reordering tabs, but didn't change the tab
order.
</description>
</action>
<action name="MobileTabGridReordered">
<owner>edchin@chromium.org</owner>
<owner>marq@chromium.org</owner>
<description>
User in the iOS tab grid finished reordering tabs, and changed the tab
order.
</description>
</action>
<action name="MobileTabGridUndoCloseAllRegularTabs">
<owner>edchin@chromium.org</owner>
<owner>marq@chromium.org</owner>
<description>
User in the iOS tab grid used the Undo control after closing all regular
tabs.
</description>
</action>
<action name="MobileTabReturnedToCurrentTab">
<owner>rlanday@chromium.org</owner>
<description>
......
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