org.chromium.base.metrics.RecordUserAction Java Examples

The following examples show how to use org.chromium.base.metrics.RecordUserAction. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ToolbarPhone.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(View v) {
    if (mToggleTabStackButton == v) {
        // The button is clickable before the native library is loaded
        // and the listener is setup.
        if (mToggleTabStackButton != null && mToggleTabStackButton.isClickable()
                && mTabSwitcherListener != null) {
            dismissTabSwitcherCallout();
            cancelAppMenuUpdateBadgeAnimation();
            mTabSwitcherListener.onClick(mToggleTabStackButton);
            RecordUserAction.record("MobileToolbarShowStackView");
        }
    } else if (mNewTabButton == v) {
        v.setEnabled(false);

        if (mNewTabListener != null) {
            mNewTabListener.onClick(v);
            RecordUserAction.record("MobileToolbarStackViewNewTab");
            RecordUserAction.record("MobileNewTabOpened");
            // TODO(kkimlabs): Record UMA action for homepage button.
        }
    } else if (mHomeButton == v) {
        openHomepage();
    }
}
 
Example #2
Source File: AppMenuButtonHelper.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Shows the app menu if it is not already shown.
 * @param view View that initiated showing this menu. Normally it is a menu button.
 * @param startDragging Whether dragging is started.
 * @return Whether or not if the app menu is successfully shown.
 */
private boolean showAppMenu(View view, boolean startDragging) {
    if (!mMenuHandler.isAppMenuShowing()
            && mMenuHandler.showAppMenu(view, startDragging)) {
        // Initial start dragging can be canceled in case if it was just single tap.
        // So we only record non-dragging here, and will deal with those dragging cases in
        // AppMenuDragHelper class.
        if (!startDragging) RecordUserAction.record("MobileUsingMenuBySwButtonTap");

        if (mOnAppMenuShownListener != null) {
            mOnAppMenuShownListener.run();
        }
        return true;
    }
    return false;
}
 
Example #3
Source File: DownloadManagerToolbar.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public void onSelectionStateChange(List<DownloadHistoryItemWrapper> selectedItems) {
    boolean wasSelectionEnabled = mIsSelectionEnabled;
    super.onSelectionStateChange(selectedItems);

    if (!mIsSelectionEnabled) {
        updateTitle();
    } else {
        int numSelected = mSelectionDelegate.getSelectedItems().size();
        findViewById(R.id.selection_mode_share_menu_id).setContentDescription(
                getResources().getQuantityString(R.plurals.accessibility_share_selected_items,
                        numSelected, numSelected));
        findViewById(R.id.selection_mode_delete_menu_id).setContentDescription(
                getResources().getQuantityString(R.plurals.accessibility_remove_selected_items,
                        numSelected, numSelected));

        if (!wasSelectionEnabled) {
            RecordUserAction.record("Android.DownloadManager.SelectionEstablished");
        }
    }
}
 
Example #4
Source File: DownloadHistoryAdapter.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Checks if a wrapper corresponds to an item that was already deleted.
 * @return True if it does, false otherwise.
 */
private boolean updateDeletedFileMap(DownloadHistoryItemWrapper wrapper) {
    // TODO(twellington): The native downloads service should remove externally deleted
    //                    downloads rather than passing them to Java.
    if (sDeletedFileTracker.contains(wrapper)) return true;

    if (wrapper.hasBeenExternallyRemoved()) {
        sDeletedFileTracker.add(wrapper);
        wrapper.remove();
        mFilePathsToItemsMap.removeItem(wrapper);
        RecordUserAction.record("Android.DownloadManager.Item.ExternallyDeleted");
        return true;
    }

    return false;
}
 
Example #5
Source File: BookmarkPromoHeader.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Initializes the class. Note that this will start listening to signin related events and
 * update itself if needed.
 */
BookmarkPromoHeader(Context context,
        PromoHeaderShowingChangeListener showingChangeListener) {
    mContext = context;
    mShowingChangeListener = showingChangeListener;

    AndroidSyncSettings.registerObserver(mContext, this);

    mSignInManager = SigninManager.get(mContext);
    mSignInManager.addSignInStateObserver(this);

    updateShouldShow(false);
    if (shouldShow()) {
        int promoShowCount = ContextUtils.getAppSharedPreferences()
                .getInt(PREF_SIGNIN_PROMO_SHOW_COUNT, 0) + 1;
        ContextUtils.getAppSharedPreferences().edit()
                .putInt(PREF_SIGNIN_PROMO_SHOW_COUNT, promoShowCount).apply();
        RecordUserAction.record("Signin_Impression_FromBookmarkManager");
    }
}
 
Example #6
Source File: AccountSigninView.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
private void showConfirmSigninPage() {
    mSignedIn = true;

    updateSignedInAccountInfo();

    mSigninChooseView.setVisibility(View.GONE);
    mSigninConfirmationView.setVisibility(View.VISIBLE);

    setButtonsEnabled(true);
    setUpConfirmButton();
    setUpUndoButton();

    NoUnderlineClickableSpan settingsSpan = new NoUnderlineClickableSpan() {
        @Override
        public void onClick(View widget) {
            mListener.onAccountSelected(getSelectedAccountName(), true);
            RecordUserAction.record("Signin_Signin_WithAdvancedSyncSettings");
        }
    };
    mSigninSettingsControl.setText(
            SpanApplier.applySpans(getSettingsControlDescription(mIsChildAccount),
                    new SpanInfo(SETTINGS_LINK_OPEN, SETTINGS_LINK_CLOSE, settingsSpan)));
}
 
Example #7
Source File: AppMenuButtonHelper.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Shows the app menu if it is not already shown.
 * @param view View that initiated showing this menu. Normally it is a menu button.
 * @param startDragging Whether dragging is started.
 * @return Whether or not if the app menu is successfully shown.
 */
private boolean showAppMenu(View view, boolean startDragging) {
    if (!mMenuHandler.isAppMenuShowing()
            && mMenuHandler.showAppMenu(view, startDragging)) {
        // Initial start dragging can be canceled in case if it was just single tap.
        // So we only record non-dragging here, and will deal with those dragging cases in
        // AppMenuDragHelper class.
        if (!startDragging) RecordUserAction.record("MobileUsingMenuBySwButtonTap");

        if (mOnAppMenuShownListener != null) {
            mOnAppMenuShownListener.run();
        }
        return true;
    }
    return false;
}
 
Example #8
Source File: ChromeActionModeCallback.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
private void search() {
    RecordUserAction.record("MobileActionMode.WebSearch");
    if (mTab.getTabModelSelector() == null) return;

    String query = mHelper.sanitizeQuery(mHelper.getSelectedText(),
            ActionModeCallbackHelper.MAX_SEARCH_QUERY_LENGTH);
    if (TextUtils.isEmpty(query)) return;

    String url = TemplateUrlService.getInstance().getUrlForSearchQuery(query);
    String headers = GeolocationHeader.getGeoHeader(mContext.getApplicationContext(),
            url, mTab.isIncognito());

    LoadUrlParams loadUrlParams = new LoadUrlParams(url);
    loadUrlParams.setVerbatimHeaders(headers);
    loadUrlParams.setTransitionType(PageTransition.GENERATED);
    mTab.getTabModelSelector().openNewTab(loadUrlParams,
            TabLaunchType.FROM_LONGPRESS_FOREGROUND, mTab, mTab.isIncognito());
}
 
Example #9
Source File: BookmarkAddActivity.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void finishNativeInitialization() {
    RecordUserAction.record("MobileAddBookmarkViaIntent");

    final String title = getIntent().getStringExtra(EXTRA_TITLE);
    final String url = getIntent().getStringExtra(EXTRA_URL);

    // Partner bookmarks need to be loaded explicitly.
    PartnerBookmarksShim.kickOffReading(this);

    // Store mModel as a member variable so it can't be garbage collected. Otherwise the
    // Runnable might never be run.
    mModel = new BookmarkModel();
    mModel.runAfterBookmarkModelLoaded(new Runnable() {
        @Override
        public void run() {
            BookmarkId bookmarkId = BookmarkUtils.addBookmarkSilently(
                    BookmarkAddActivity.this, mModel, title, url);
            if (bookmarkId != null) {
                BookmarkUtils.startEditActivity(BookmarkAddActivity.this, bookmarkId);
            }
            finish();
        }
    });
}
 
Example #10
Source File: CustomTabActivity.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void onStartWithNative() {
    super.onStartWithNative();
    setActiveContentHandler(mCustomTabContentHandler);

    if (getSavedInstanceState() != null || !mIsInitialStart) {
        RecordUserAction.record("CustomTabs.StartedReopened");
    } else {
        ExternalAppId externalId =
                IntentHandler.determineExternalIntentSource(getPackageName(), getIntent());
        RecordHistogram.recordEnumeratedHistogram("CustomTabs.ClientAppId",
                externalId.ordinal(), ExternalAppId.INDEX_BOUNDARY.ordinal());

        RecordUserAction.record("CustomTabs.StartedInitially");
    }
    mIsInitialStart = false;
}
 
Example #11
Source File: CustomTabActivity.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
protected boolean handleBackPressed() {
    RecordUserAction.record("CustomTabs.SystemBack");

    if (getActivityTab() == null) return false;

    if (exitFullscreenIfShowing()) return true;

    if (!getToolbarManager().back()) {
        if (getCurrentTabModel().getCount() > 1) {
            getCurrentTabModel().closeTab(getActivityTab(), false, false, false);
        } else {
            if (mIntentDataProvider.isOpenedByChrome() && isHerbResultNeeded()) {
                createHerbResultIntent(RESULT_BACK_PRESSED);
            }
            finishAndClose();
        }
    }
    return true;
}
 
Example #12
Source File: LocationBarLayout.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(View v) {
    if (v == mDeleteButton) {
        if (!TextUtils.isEmpty(mUrlBar.getQueryText())) {
            setUrlBarText("", null);
            hideSuggestions();
            updateButtonVisibility();
        }

        startZeroSuggest();
        return;
    } else if (!mUrlHasFocus && shouldShowPageInfoForView(v)) {
        Tab currentTab = getCurrentTab();
        if (currentTab != null && currentTab.getWebContents() != null) {
            Activity activity = currentTab.getWindowAndroid().getActivity().get();
            if (activity != null) {
                WebsiteSettingsPopup.show(
                        activity, currentTab, null, WebsiteSettingsPopup.OPENED_FROM_TOOLBAR);
            }
        }
    } else if (v == mMicButton) {
        RecordUserAction.record("MobileOmniboxVoiceSearch");
        startVoiceRecognition();
    }
}
 
Example #13
Source File: BookmarkAddActivity.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public void finishNativeInitialization() {
    RecordUserAction.record("MobileAddBookmarkViaIntent");

    final String title = getIntent().getStringExtra(EXTRA_TITLE);
    final String url = getIntent().getStringExtra(EXTRA_URL);

    // Partner bookmarks need to be loaded explicitly.
    PartnerBookmarksShim.kickOffReading(this);

    // Store mModel as a member variable so it can't be garbage collected. Otherwise the
    // Runnable might never be run.
    mModel = new BookmarkModel();
    mModel.runAfterBookmarkModelLoaded(new Runnable() {
        @Override
        public void run() {
            BookmarkId bookmarkId = BookmarkUtils.addBookmarkSilently(
                    BookmarkAddActivity.this, mModel, title, url);
            if (bookmarkId != null) {
                BookmarkUtils.startEditActivity(BookmarkAddActivity.this, bookmarkId);
            }
            finish();
        }
    });
}
 
Example #14
Source File: BookmarkPromoHeader.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Initializes the class. Note that this will start listening to signin related events and
 * update itself if needed.
 */
BookmarkPromoHeader(Context context,
        PromoHeaderShowingChangeListener showingChangeListener) {
    mContext = context;
    mShowingChangeListener = showingChangeListener;

    AndroidSyncSettings.registerObserver(mContext, this);

    mSignInManager = SigninManager.get(mContext);
    mSignInManager.addSignInStateObserver(this);

    updateShouldShow(false);
    if (shouldShow()) {
        int promoShowCount = ContextUtils.getAppSharedPreferences()
                .getInt(PREF_SIGNIN_PROMO_SHOW_COUNT, 0) + 1;
        ContextUtils.getAppSharedPreferences().edit()
                .putInt(PREF_SIGNIN_PROMO_SHOW_COUNT, promoShowCount).apply();
        RecordUserAction.record("Signin_Impression_FromBookmarkManager");
    }
}
 
Example #15
Source File: ChromeActivity.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public final void onBackPressed() {
    RecordUserAction.record("SystemBack");
    if (mCompositorViewHolder != null) {
        LayoutManager layoutManager = mCompositorViewHolder.getLayoutManager();
        if (layoutManager != null && layoutManager.onBackPressed()) return;
    }

    ContentViewCore contentViewCore = getContentViewCore();
    if (contentViewCore != null && contentViewCore.isSelectActionBarShowing()) {
        contentViewCore.clearSelection();
        return;
    }

    if (mContextualSearchManager != null && mContextualSearchManager.onBackPressed()) return;

    if (handleBackPressed()) return;

    super.onBackPressed();
}
 
Example #16
Source File: AccountSigninView.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
private void setUpMoreButtonVisible(boolean enabled) {
    if (enabled) {
        mPositiveButton.setVisibility(View.GONE);
        mMoreButton.setVisibility(View.VISIBLE);
        mMoreButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                mSigninConfirmationView.smoothScrollBy(0, mSigninConfirmationView.getHeight());
                RecordUserAction.record("Signin_MoreButton_Shown");
            }
        });
    } else {
        mPositiveButton.setVisibility(View.VISIBLE);
        mMoreButton.setVisibility(View.GONE);
    }
}
 
Example #17
Source File: RecentTabsRowAdapter.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
View getChildView(int childPosition, boolean isLastChild, View convertView,
        ViewGroup parent) {
    if (convertView == null) {
        SigninAndSyncView.Listener listener = new SigninAndSyncView.Listener() {
            @Override
            public void onViewDismissed() {
                mRecentTabsManager.setSigninPromoDeclined();
                notifyDataSetChanged();
            }
        };

        convertView =
                SigninAndSyncView.create(parent, listener, SigninAccessPoint.RECENT_TABS);
    }
    if (!mRecentTabsManager.isSignedIn()) {
        RecordUserAction.record("Signin_Impression_FromRecentTabs");
    }
    return convertView;
}
 
Example #18
Source File: MinidumpDirectoryObserver.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 *  When a minidump is detected, upload it to Google crash server
 */
@Override
public void onEvent(int event, String path) {
    // This is executed on a thread dedicated to FileObserver.
    if (CrashFileManager.isMinidumpMIMEFirstTry(path)) {
        Context appContext = ContextUtils.getApplicationContext();
        try {
            Intent intent =
                    MinidumpUploadService.createFindAndUploadLastCrashIntent(appContext);
            appContext.startService(intent);
            Log.i(TAG, "Detects a new minidump %s send intent to MinidumpUploadService", path);
            RecordUserAction.record("MobileBreakpadUploadAttempt");
        } catch (SecurityException e) {
            // For KitKat and below, there was a framework bug which cause us to not be able to
            // find our own crash uploading service. Ignore a SecurityException here on older
            // OS versions since the crash will eventually get uploaded on next start.
            // crbug/542533
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                throw e;
            }
        }
    }
}
 
Example #19
Source File: CustomTabActivity.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Configures the custom button on toolbar. Does nothing if invalid data is provided by clients.
 */
private void showCustomButtonOnToolbar() {
    final CustomButtonParams params = mIntentDataProvider.getCustomButtonOnToolbar();
    if (params == null) return;
    getToolbarManager().setCustomActionButton(
            params.getIcon(getResources()),
            params.getDescription(),
            new OnClickListener() {
                @Override
                public void onClick(View v) {
                    mIntentDataProvider.sendButtonPendingIntentWithUrl(
                            getApplicationContext(), getActivityTab().getUrl());
                    RecordUserAction.record("CustomTabsCustomActionButtonClick");
                }
            });
}
 
Example #20
Source File: SingleCategoryPreferences.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * This clears all the storage for websites that are displayed to the user. This happens
 * asynchronously, and then we call {@link #getInfoForOrigins()} when we're done.
 */
public void clearStorage() {
    if (mWebsites == null) {
        return;
    }
    RecordUserAction.record("MobileSettingsStorageClearAll");

    // The goal is to refresh the info for origins again after we've cleared all of them, so we
    // wait until the last website is cleared to refresh the origin list.
    final int[] numLeft = new int[1];
    numLeft[0] = mWebsites.size();
    for (int i = 0; i < mWebsites.size(); i++) {
        WebsitePreference preference = mWebsites.get(i);
        preference.site().clearAllStoredData(new StoredDataClearedCallback() {
            @Override
            public void onStoredDataCleared() {
                if (--numLeft[0] <= 0) {
                    getInfoForOrigins();
                }
            }
        });
    }
}
 
Example #21
Source File: SearchEnginePreference.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(View v) {
    if (v == mCancelButton) {
        getActivity().finish();
    } else if (v == mSaveButton) {
        TemplateUrlService.getInstance().setSearchEngine(mSelectedIndex);
        // If the user has manually set the default search engine, disable auto switching.
        boolean manualSwitch = mSelectedIndex != mSearchEngineAdapter
                .getInitialSearchEnginePosition();
        if (manualSwitch) {
            RecordUserAction.record("SearchEngine_ManualChange");
            LocaleManager.getInstance().setSearchEngineAutoSwitch(false);
        }
        getActivity().finish();
    }
}
 
Example #22
Source File: CustomTabActivity.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
protected boolean handleBackPressed() {
    RecordUserAction.record("CustomTabs.SystemBack");

    if (getActivityTab() == null) return false;

    if (exitFullscreenIfShowing()) return true;

    if (!getToolbarManager().back()) {
        if (getCurrentTabModel().getCount() > 1) {
            getCurrentTabModel().closeTab(getActivityTab(), false, false, false);
        } else {
            finishAndClose(false);
        }
    }
    return true;
}
 
Example #23
Source File: ChromeActivity.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Records user actions associated with entering and exiting Android N multi-window mode
 * @param isInMultiWindowMode True if the activity is in multi-window mode.
 */
protected void recordMultiWindowModeChangedUserAction(boolean isInMultiWindowMode) {
    if (isInMultiWindowMode) {
        RecordUserAction.record("Android.MultiWindowMode.Enter");
    } else {
        RecordUserAction.record("Android.MultiWindowMode.Exit");
    }
}
 
Example #24
Source File: PhysicalWebUma.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private void uploadActions(String key) {
    int count = mPrefs.getInt(key, 0);
    removePref(key);
    for (int i = 0; i < count; i++) {
        RecordUserAction.record(key);
    }
}
 
Example #25
Source File: ExternalNavigationDelegateImpl.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private void recordExternalNavigationDispatched(Intent intent) {
    ArrayList<String> specializedHandlers = intent.getStringArrayListExtra(
            IntentHandler.EXTRA_EXTERNAL_NAV_PACKAGES);
    if (specializedHandlers != null && specializedHandlers.size() > 0) {
        RecordUserAction.record("MobileExternalNavigationDispatched");
    }
}
 
Example #26
Source File: ManageSpaceActivity.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/** @see BrowserParts#finishNativeInitialization */
public void finishNativeInitialization() {
    mIsNativeInitialized = true;
    mManageSiteDataButton.setEnabled(true);
    mClearUnimportantButton.setEnabled(true);
    RecordUserAction.record("Android.ManageSpace");
    refreshStorageNumbers();
}
 
Example #27
Source File: CustomTabActivity.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void onResumeWithNative() {
    super.onResumeWithNative();

    if (getSavedInstanceState() != null || !mIsInitialResume) {
        if (mIntentDataProvider.isOpenedByChrome()) {
            RecordUserAction.record("ChromeGeneratedCustomTab.StartedReopened");
        } else {
            RecordUserAction.record("CustomTabs.StartedReopened");
        }
    } else {
        SharedPreferences preferences = ContextUtils.getAppSharedPreferences();
        String lastUrl = preferences.getString(LAST_URL_PREF, null);
        if (lastUrl != null && lastUrl.equals(getUrlToLoad())) {
            RecordUserAction.record("CustomTabsMenuOpenSameUrl");
        } else {
            preferences.edit().putString(LAST_URL_PREF, getUrlToLoad()).apply();
        }

        if (mIntentDataProvider.isOpenedByChrome()) {
            RecordUserAction.record("ChromeGeneratedCustomTab.StartedInitially");
        } else {
            ExternalAppId externalId =
                    IntentHandler.determineExternalIntentSource(getPackageName(), getIntent());
            RecordHistogram.recordEnumeratedHistogram("CustomTabs.ClientAppId",
                    externalId.ordinal(), ExternalAppId.INDEX_BOUNDARY.ordinal());

            RecordUserAction.record("CustomTabs.StartedInitially");
        }
    }
    mIsInitialResume = false;
}
 
Example #28
Source File: IntentHandler.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Records an action when a user chose to handle a URL in Chrome that could have been handled
 * by an application installed on the phone. Also records the name of that application.
 * This doesn't include generic URL handlers, such as browsers.
 */
private void recordAppHandlersForIntent(Intent intent) {
    List<String> packages = IntentUtils.safeGetStringArrayListExtra(intent,
            IntentHandler.EXTRA_EXTERNAL_NAV_PACKAGES);
    if (packages != null && packages.size() > 0) {
        RecordUserAction.record("MobileExternalNavigationReceived");
        for (String name : packages) {
            RapporServiceBridge.sampleString("Android.ExternalNavigationNotChosen", name);
        }
    }
}
 
Example #29
Source File: ChromeActivity.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void onResumeWithNative() {
    super.onResumeWithNative();
    markSessionResume();
    RecordUserAction.record("MobileComeToForeground");

    if (getActivityTab() != null) {
        LaunchMetrics.commitLaunchMetrics(getActivityTab().getWebContents());
    }
    FeatureUtilities.setCustomTabVisible(isCustomTab());
    FeatureUtilities.setIsInMultiWindowMode(
            MultiWindowUtils.getInstance().isInMultiWindowMode(this));
}
 
Example #30
Source File: ContextualSearchUma.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Logs a user action for the duration of viewing the panel that describes the amount of time
 * the user viewed the bar and panel overall.
 * @param durationMs The duration to record.
 */
public static void logPanelViewDurationAction(long durationMs) {
    if (durationMs < 1000) {
        RecordUserAction.record("ContextualSearch.ViewLessThanOneSecond");
    } else if (durationMs < 3000) {
        RecordUserAction.record("ContextualSearch.ViewOneToThreeSeconds");
    } else if (durationMs < 10000) {
        RecordUserAction.record("ContextualSearch.ViewThreeToTenSeconds");
    } else {
        RecordUserAction.record("ContextualSearch.ViewMoreThanTenSeconds");
    }
}