Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 package org.chromium.chrome.browser.widget.bottomsheet; | |
| 6 | |
| 7 import org.chromium.base.metrics.RecordUserAction; | |
| 8 import org.chromium.chrome.browser.widget.bottomsheet.BottomSheet.BottomSheetCon tent; | |
| 9 | |
| 10 /** | |
| 11 * Records user action and histograms related to the {@link BottomSheet}. | |
| 12 */ | |
| 13 public class BottomSheetMetrics extends EmptyBottomSheetObserver { | |
| 14 private boolean mIsSheetOpen; | |
| 15 private BottomSheetContent mLastContent; | |
| 16 | |
| 17 /** | |
| 18 * @param sheet The {@link BottomSheet} to record metrics for. | |
| 19 */ | |
| 20 public BottomSheetMetrics(BottomSheet sheet) { | |
| 21 sheet.addObserver(this); | |
| 22 } | |
| 23 | |
| 24 @Override | |
| 25 public void onSheetOpened() { | |
| 26 if (mIsSheetOpen) return; | |
| 27 | |
| 28 mIsSheetOpen = true; | |
| 29 RecordUserAction.record("Android.ChromeHome.Opened"); | |
| 30 } | |
| 31 | |
| 32 @Override | |
| 33 public void onSheetClosed() { | |
| 34 if (!mIsSheetOpen) return; | |
|
mdjones
2017/03/17 18:17:26
Are the onSheetOpened and onSheetClosed events not
Theresa
2017/03/17 20:26:30
onSheetClosed gets called when the activity is fir
mdjones
2017/03/17 21:53:32
I think I'd rather have this check in the bottom s
Theresa
2017/03/17 22:55:25
Done.
| |
| 35 | |
| 36 mIsSheetOpen = false; | |
| 37 RecordUserAction.record("Android.ChromeHome.Closed"); | |
| 38 } | |
| 39 | |
| 40 @Override | |
| 41 public void onSheetStateChanged(int newState) { | |
| 42 if (newState == BottomSheet.SHEET_STATE_HALF) { | |
| 43 RecordUserAction.record("Android.ChromeHome.HalfState"); | |
| 44 } else if (newState == BottomSheet.SHEET_STATE_FULL) { | |
| 45 RecordUserAction.record("Android.ChromeHome.FullState"); | |
| 46 } | |
| 47 } | |
| 48 | |
| 49 @Override | |
| 50 public void onSheetContentChanged(BottomSheetContent newContent) { | |
| 51 if (mLastContent == null || !mIsSheetOpen) { | |
| 52 mLastContent = newContent; | |
| 53 return; | |
| 54 } | |
| 55 | |
| 56 mLastContent = newContent; | |
| 57 RecordUserAction.record("Android.ChromeHome.Show" + mLastContent.getMetr icsName()); | |
|
Theresa
2017/03/17 16:07:12
The upside to this approach is that it's simple. T
mdjones
2017/03/17 18:17:26
Though I like the current approach, I'm inclined t
Theresa
2017/03/17 20:26:30
Done.
| |
| 58 } | |
| 59 | |
| 60 } | |
| OLD | NEW |