Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsPage.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsPage.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsPage.java |
| index edea4d841e66c2f9d5b371e93bc91f0852dbed53..61ca388e2cf02bac305cb64a9f91bcccdcf7dace 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsPage.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/InterestsPage.java |
| @@ -10,6 +10,8 @@ import android.view.LayoutInflater; |
| import android.view.View; |
| import org.chromium.base.ApiCompatibilityUtils; |
| +import org.chromium.base.metrics.RecordHistogram; |
| +import org.chromium.base.metrics.RecordUserAction; |
| import org.chromium.chrome.R; |
| import org.chromium.chrome.browser.NativePage; |
| import org.chromium.chrome.browser.UrlConstants; |
| @@ -35,6 +37,8 @@ public class InterestsPage implements NativePage { |
| private final int mBackgroundColor; |
| private final int mThemeColor; |
| + private boolean mClicked; |
| + |
| /** |
| * Creates a InterestsPage to be shown in document mode. |
| * |
| @@ -57,21 +61,39 @@ public class InterestsPage implements NativePage { |
| new GetInterestsCallback() { |
| @Override |
| public void onInterestsAvailableCallback(Interest[] interests) { |
| - if (interests == null) { |
| - Toast toast = Toast.makeText(context, |
| - R.string.ntp_no_interests_toast, Toast.LENGTH_SHORT); |
| - toast.show(); |
| + boolean gotInterests = interests != null; |
| + RecordHistogram.recordBooleanHistogram( |
| + "NewTabPage.Interests.InterestsFetchSuccess", gotInterests); |
| + if (!gotInterests) { |
| + showToastOnFailure(); |
| return; |
| } |
| List<Interest> interestList = Arrays.asList(interests); |
| - |
| + RecordHistogram.recordSparseSlowlyHistogram( |
| + "NewTabPage.Interests.NumInterests", interestList.size()); |
|
Alexei Svitkine (slow)
2015/12/09 16:15:57
Why sparse and not counts?
knn
2015/12/10 06:57:17
The same rationale as when we discussed NewTabPage
Alexei Svitkine (slow)
2015/12/10 16:13:47
Please add a comment about this above the function
knn
2015/12/17 05:30:01
Done.
|
| + if (interestList.size() == 0) { |
| + showToastOnFailure(); |
| + return; |
| + } |
| mPageView.setInterests(interestList); |
| } |
| + |
| + private void showToastOnFailure() { |
| + Toast.makeText(context, R.string.ntp_no_interests_toast, Toast.LENGTH_SHORT) |
| + .show(); |
| + } |
| }); |
| } |
| - public void setListener(InterestsClickListener listener) { |
| - mPageView.setListener(listener); |
| + public void setListener(final InterestsClickListener listener) { |
| + mPageView.setListener(new InterestsClickListener() { |
| + public void onInterestClicked(String interest) { |
| + mClicked = true; |
| + NewTabPageUma.recordAction(NewTabPageUma.ACTION_CLICKED_INTEREST); |
| + RecordUserAction.record("MobileNTP.Interests.Click"); |
| + listener.onInterestClicked(interest); |
| + } |
| + }); |
| } |
| /** |
| @@ -108,6 +130,8 @@ public class InterestsPage implements NativePage { |
| @Override |
| public void destroy() { |
| + if (mClicked) return; |
| + RecordUserAction.record("MobileNTP.Interests.Dismissed"); |
| } |
| @Override |