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) { ...@@ -67,7 +67,8 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
@property(nonatomic, strong) GridLayout* defaultLayout; @property(nonatomic, strong) GridLayout* defaultLayout;
// The layout used while the grid is being reordered. // The layout used while the grid is being reordered.
@property(nonatomic, strong) UICollectionViewLayout* reorderingLayout; @property(nonatomic, strong) UICollectionViewLayout* reorderingLayout;
// YES if, when reordering is enabled, the order of the cells has changed.
@property(nonatomic, assign) BOOL hasChangedOrder;
@end @end
@implementation GridViewController @implementation GridViewController
...@@ -88,6 +89,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) { ...@@ -88,6 +89,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
@synthesize emptyStateAnimator = _emptyStateAnimator; @synthesize emptyStateAnimator = _emptyStateAnimator;
@synthesize defaultLayout = _defaultLayout; @synthesize defaultLayout = _defaultLayout;
@synthesize reorderingLayout = _reorderingLayout; @synthesize reorderingLayout = _reorderingLayout;
@synthesize hasChangedOrder = _hasChangedOrder;
- (instancetype)init { - (instancetype)init {
if (self = [super init]) { if (self = [super init]) {
...@@ -286,7 +288,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) { ...@@ -286,7 +288,7 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
GridItem* item = self.items[source]; GridItem* item = self.items[source];
[self.items removeObjectAtIndex:source]; [self.items removeObjectAtIndex:source];
[self.items insertObject:item atIndex:destination]; [self.items insertObject:item atIndex:destination];
self.hasChangedOrder = YES;
[self.delegate gridViewController:self [self.delegate gridViewController:self
didMoveItemWithID:item.identifier didMoveItemWithID:item.identifier
toIndex:destination]; toIndex:destination];
...@@ -587,6 +589,8 @@ NSIndexPath* CreateIndexPath(NSInteger index) { ...@@ -587,6 +589,8 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
if (!moving) { if (!moving) {
gesture.enabled = NO; gesture.enabled = NO;
} else { } else {
base::RecordAction(
base::UserMetricsAction("MobileTabGridBeganReordering"));
CGPoint cellCenter = CGPoint cellCenter =
[self.collectionView cellForItemAtIndexPath:path].center; [self.collectionView cellForItemAtIndexPath:path].center;
self.itemReorderTouchPoint = self.itemReorderTouchPoint =
...@@ -624,12 +628,14 @@ NSIndexPath* CreateIndexPath(NSInteger index) { ...@@ -624,12 +628,14 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
animated:YES]; animated:YES];
}]; }];
[self.collectionView endInteractiveMovement]; [self.collectionView endInteractiveMovement];
[self recordInteractiveReordering];
[CATransaction commit]; [CATransaction commit];
break; break;
} }
case UIGestureRecognizerStateCancelled: case UIGestureRecognizerStateCancelled:
self.itemReorderTouchPoint = CGPointZero; self.itemReorderTouchPoint = CGPointZero;
[self.collectionView cancelInteractiveMovement]; [self.collectionView cancelInteractiveMovement];
[self recordInteractiveReordering];
[self.collectionView setCollectionViewLayout:self.defaultLayout [self.collectionView setCollectionViewLayout:self.defaultLayout
animated:YES]; animated:YES];
// Re-enable cancelled gesture. // Re-enable cancelled gesture.
...@@ -649,4 +655,14 @@ NSIndexPath* CreateIndexPath(NSInteger index) { ...@@ -649,4 +655,14 @@ NSIndexPath* CreateIndexPath(NSInteger index) {
[self.collectionView updateInteractiveMovementTargetPosition:targetLocation]; [self.collectionView updateInteractiveMovementTargetPosition:targetLocation];
} }
- (void)recordInteractiveReordering {
if (self.hasChangedOrder) {
base::RecordAction(base::UserMetricsAction("MobileTabGridReordered"));
} else {
base::RecordAction(
base::UserMetricsAction("MobileTabGridEndedWithoutReordering"));
}
self.hasChangedOrder = NO;
}
@end @end
...@@ -1245,14 +1245,20 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) { ...@@ -1245,14 +1245,20 @@ NSUInteger GetPageIndexFromPage(TabGridPage page) {
- (void)closeAllButtonTapped:(id)sender { - (void)closeAllButtonTapped:(id)sender {
switch (self.currentPage) { switch (self.currentPage) {
case TabGridPageIncognitoTabs: case TabGridPageIncognitoTabs:
base::RecordAction(
base::UserMetricsAction("MobileTabGridCloseAllIncognitoTabs"));
[self.incognitoTabsDelegate closeAllItems]; [self.incognitoTabsDelegate closeAllItems];
break; break;
case TabGridPageRegularTabs: case TabGridPageRegularTabs:
DCHECK_EQ(self.undoCloseAllAvailable, DCHECK_EQ(self.undoCloseAllAvailable,
self.regularTabsViewController.gridEmpty); self.regularTabsViewController.gridEmpty);
if (self.undoCloseAllAvailable) { if (self.undoCloseAllAvailable) {
base::RecordAction(
base::UserMetricsAction("MobileTabGridUndoCloseAllRegularTabs"));
[self.regularTabsDelegate undoCloseAllItems]; [self.regularTabsDelegate undoCloseAllItems];
} else { } else {
base::RecordAction(
base::UserMetricsAction("MobileTabGridCloseAllRegularTabs"));
[self.regularTabsDelegate saveAndCloseAllItems]; [self.regularTabsDelegate saveAndCloseAllItems];
} }
self.undoCloseAllAvailable = !self.undoCloseAllAvailable; self.undoCloseAllAvailable = !self.undoCloseAllAvailable;
......
...@@ -11766,6 +11766,57 @@ should be able to be added at any place in this file. ...@@ -11766,6 +11766,57 @@ should be able to be added at any place in this file.
</description> </description>
</action> </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"> <action name="MobileTabReturnedToCurrentTab">
<owner>rlanday@chromium.org</owner> <owner>rlanday@chromium.org</owner>
<description> <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