Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/ActionItem.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/ActionItem.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/ActionItem.java |
| index a1a4e11875be3fdc3e182d8a25d15ffca6e2650b..5e39b96dd9d5fbfb6202eba0ccbec202e4d09683 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/ActionItem.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/ActionItem.java |
| @@ -14,6 +14,7 @@ |
| import org.chromium.chrome.browser.ntp.ContextMenuManager.Delegate; |
| import org.chromium.chrome.browser.ntp.NewTabPageView.NewTabPageManager; |
| import org.chromium.chrome.browser.ntp.UiConfig; |
| +import org.chromium.chrome.browser.ntp.snippets.CategoryInt; |
| import org.chromium.chrome.browser.ntp.snippets.SnippetsConfig; |
| import java.lang.annotation.Retention; |
| @@ -24,7 +25,7 @@ |
| * Note: Use {@link #refreshVisibility()} to update the visibility of the button instead of calling |
| * {@link #setVisible(boolean)} directly. |
| */ |
| -class ActionItem extends OptionalLeaf { |
| +public class ActionItem extends OptionalLeaf { |
| @IntDef({ACTION_NONE, ACTION_VIEW_ALL, ACTION_FETCH_MORE, ACTION_RELOAD}) |
| @Retention(RetentionPolicy.SOURCE) |
| public @interface Action {} |
| @@ -39,6 +40,7 @@ |
| @Action |
| private int mCurrentAction = ACTION_NONE; |
| private boolean mImpressionTracked; |
| + private int mPerSectionRank = -1; |
| public ActionItem(SuggestionsSection section) { |
| mCategoryInfo = section.getCategoryInfo(); |
| @@ -62,14 +64,22 @@ protected void onBindViewHolder(NewTabPageViewHolder holder) { |
| ((ViewHolder) holder).onBindViewHolder(this); |
| } |
| - private int getPosition() { |
| - // TODO(dgn): looks dodgy. Confirm that's what we want. |
| - return mParentSection.getSuggestionsCount(); |
| + @CategoryInt |
| + public int getCategory() { |
| + return mCategoryInfo.getCategory(); |
| + } |
| + |
| + public void setRank(int perSectionRank) { |
|
Bernhard Bauer
2017/01/17 17:42:31
The corresponding getter is called getPerSectionRa
dgn
2017/01/17 18:46:24
Done.
|
| + mPerSectionRank = perSectionRank; |
| + } |
| + |
| + public int getPerSectionRank() { |
| + return mPerSectionRank; |
| } |
| @VisibleForTesting |
| void performAction(NewTabPageManager manager) { |
| - manager.trackSnippetCategoryActionClick(mCategoryInfo.getCategory(), getPosition()); |
| + manager.getSuggestionsMetricsReporter().onMoreButtonClicked(this); |
| switch (mCurrentAction) { |
| case ACTION_VIEW_ALL: |
| @@ -97,6 +107,7 @@ private int findAppropriateAction() { |
| return ACTION_NONE; |
| } |
| + /** ViewHolder associated to {@link ItemViewType#ACTION}. */ |
| public static class ViewHolder extends CardViewHolder implements ContextMenuManager.Delegate { |
| private ActionItem mActionListItem; |
| @@ -117,9 +128,7 @@ public void onClick(View v) { |
| public void onImpression() { |
| if (mActionListItem != null && !mActionListItem.mImpressionTracked) { |
| mActionListItem.mImpressionTracked = true; |
| - manager.trackSnippetCategoryActionImpression( |
| - mActionListItem.mCategoryInfo.getCategory(), |
| - mActionListItem.getPosition()); |
| + manager.getSuggestionsMetricsReporter().onMoreButtonShown(mActionListItem); |
| } |
| } |
| }); |