Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(255)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/widget/bottomsheet/BottomSheetMetrics.java

Issue 2754313002: [Home] Record some user actions for the Chrome Home BottomSheet (Closed)
Patch Set: Move early return to BottomSheet Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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);
gone 2017/03/20 20:29:32 This should be left to the BottomSheet to do. It'
Theresa 2017/03/20 20:59:12 Done.
22 }
23
24 @Override
25 public void onSheetOpened() {
26 mIsSheetOpen = true;
27 RecordUserAction.record("Android.ChromeHome.Opened");
28 }
29
30 @Override
31 public void onSheetClosed() {
32 mIsSheetOpen = false;
33 RecordUserAction.record("Android.ChromeHome.Closed");
34 }
35
36 @Override
37 public void onSheetStateChanged(int newState) {
38 if (newState == BottomSheet.SHEET_STATE_HALF) {
39 RecordUserAction.record("Android.ChromeHome.HalfState");
40 } else if (newState == BottomSheet.SHEET_STATE_FULL) {
41 RecordUserAction.record("Android.ChromeHome.FullState");
42 }
43 }
44
45 @Override
46 public void onSheetContentChanged(BottomSheetContent newContent) {
47 // Return early if the sheet content is being set during initialization (previous content
48 // is null) or while the sheet is closed (sheet content being reset), so that we only
49 // record actions when the user explicitly takes an action.
50 if (mLastContent == null || !mIsSheetOpen) {
Theresa 2017/03/17 22:55:25 nit: remove the extra space that crept in.
Theresa 2017/03/20 20:59:12 Done.
51 mLastContent = newContent;
52 return;
53 }
54
55 if (newContent.getType() == BottomSheetContentController.TYPE_SUGGESTION S) {
56 RecordUserAction.record("Android.ChromeHome.ShowSuggestions");
57 } else if (newContent.getType() == BottomSheetContentController.TYPE_DOW NLOADS) {
58 RecordUserAction.record("Android.ChromeHome.ShowDownloads");
59 } else if (newContent.getType() == BottomSheetContentController.TYPE_BOO KMARKS) {
60 RecordUserAction.record("Android.ChromeHome.ShowBookmarks");
61 } else if (newContent.getType() == BottomSheetContentController.TYPE_HIS TORY) {
62 RecordUserAction.record("Android.ChromeHome.ShowHistory");
63 }
gone 2017/03/20 20:29:32 else assert false;
Theresa 2017/03/20 20:59:12 Done.
64 mLastContent = newContent;
65 }
66
67 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698