Chromium Code Reviews| Index: ios/chrome/browser/tabs/tab_model_metrics_observer.mm |
| diff --git a/ios/chrome/browser/tabs/tab_model_metrics_observer.mm b/ios/chrome/browser/tabs/tab_model_metrics_observer.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e94db54a316f3d9f81f2dcb33ac796c243a85c72 |
| --- /dev/null |
| +++ b/ios/chrome/browser/tabs/tab_model_metrics_observer.mm |
| @@ -0,0 +1,39 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#import "ios/chrome/browser/tabs/tab_model_metrics_observer.h" |
|
marq (ping after 24h)
2017/02/13 17:06:54
Can you put this in ios/shared/, since it's free o
sdefresne
2017/02/14 17:19:38
Should I rename it WebStateListMetricsObserver the
|
| + |
| +#include "base/metrics/user_metrics.h" |
| +#include "base/metrics/user_metrics_action.h" |
| + |
| +#if !defined(__has_feature) || !__has_feature(objc_arc) |
| +#error "This file requires ARC support." |
| +#endif |
| + |
| +@implementation TabModelMetricsObserver |
| + |
| +#pragma mark WebStateListObserver |
| + |
| +- (void)webStateList:(WebStateList*)webStateList |
| + webStateInserted:(web::WebState*)webState |
| + atIndex:(NSUInteger)index { |
| + base::RecordAction(base::UserMetricsAction("MobileNewTabOpened")); |
| +} |
| + |
| +- (void)webStateList:(WebStateList*)webStateList |
| + webStateReplaced:(web::WebState*)oldWebState |
| + byWebState:(web::WebState*)newWebState |
| + atIndex:(NSUInteger)index { |
| + // Record a tab clobber, since swapping tabs bypasses the Tab code that would |
| + // normally log clobbers. |
| + base::RecordAction(base::UserMetricsAction("MobileTabClobbered")); |
| +} |
| + |
| +- (void)webStateList:(WebStateList*)webStateList |
| + webStateRemoved:(web::WebState*)webState |
| + atIndex:(NSUInteger)index { |
| + base::RecordAction(base::UserMetricsAction("MobileTabClosed")); |
| +} |
| + |
| +@end |