org.chromium.chrome.browser.contextualsearch.ContextualSearchUma Java Examples

The following examples show how to use org.chromium.chrome.browser.contextualsearch.ContextualSearchUma. 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: ContextualSearchPanelMetrics.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * Called when a Search Term has been resolved.
 */
public void onSearchTermResolved() {
    long durationMs =
            (System.nanoTime() - mSearchRequestStartTimeNs) / MILLISECONDS_TO_NANOSECONDS;
    ContextualSearchUma.logSearchTermResolutionDuration(durationMs);
}
 
Example #2
Source File: ContextualSearchPanelMetrics.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * Called after the panel has navigated to prefetched Search Results.
 * This is the point where the search result starts to render in the panel.
 */
public void onPanelNavigatedToPrefetchedSearch(boolean didResolve) {
    long durationMs =
            (System.nanoTime() - mSearchRequestStartTimeNs) / MILLISECONDS_TO_NANOSECONDS;
    ContextualSearchUma.logPrefetchedSearchNavigatedDuration(durationMs, didResolve);
}
 
Example #3
Source File: ContextualSearchPanelMetrics.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * Called when a Search Term has been resolved.
 */
public void onSearchTermResolved() {
    long durationMs =
            (System.nanoTime() - mSearchRequestStartTimeNs) / MILLISECONDS_TO_NANOSECONDS;
    ContextualSearchUma.logSearchTermResolutionDuration(durationMs);
}
 
Example #4
Source File: ContextualSearchPanelMetrics.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * Called after the panel has navigated to prefetched Search Results.
 * This is the point where the search result starts to render in the panel.
 */
public void onPanelNavigatedToPrefetchedSearch(boolean didResolve) {
    long durationMs =
            (System.nanoTime() - mSearchRequestStartTimeNs) / MILLISECONDS_TO_NANOSECONDS;
    ContextualSearchUma.logPrefetchedSearchNavigatedDuration(durationMs, didResolve);
}
 
Example #5
Source File: ContextualSearchQuickActionControl.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
private void resolveIntent() {
    try {
        mIntent = Intent.parseUri(mQuickActionUri, 0);
    } catch (URISyntaxException e) {
        // If the intent cannot be parsed, there is no quick action available.
        ContextualSearchUma.logQuickActionIntentResolution(mQuickActionCategory, 0);
        reset();
        return;
    }

    PackageManager packageManager = mContext.getPackageManager();

    // If a default is set, PackageManager#resolveActivity() will return the ResolveInfo
    // for the default activity.
    ResolveInfo possibleDefaultActivity = packageManager.resolveActivity(mIntent, 0);

    // PackageManager#queryIntentActivities() will return a list of activities that can handle
    // the intent, sorted from best to worst. If there are no matching activities, an empty
    // list is returned.
    List<ResolveInfo> resolveInfoList = packageManager.queryIntentActivities(
            mIntent, 0);

    int numMatchingActivities = 0;
    ResolveInfo defaultActivityResolveInfo = null;
    for (ResolveInfo resolveInfo : resolveInfoList) {
        // TODO(twellington): do not count browser activities as a match?
        if (resolveInfo.activityInfo != null && resolveInfo.activityInfo.exported) {
            numMatchingActivities++;

            // Return early if this resolveInfo matches the possibleDefaultActivity.
            ActivityInfo possibleDefaultActivityInfo = possibleDefaultActivity.activityInfo;
            if (possibleDefaultActivityInfo == null) continue;

            ActivityInfo resolveActivityInfo = resolveInfo.activityInfo;
            boolean matchesPossibleDefaultActivity =
                    TextUtils.equals(resolveActivityInfo.name,
                            possibleDefaultActivityInfo.name)
                    && TextUtils.equals(resolveActivityInfo.packageName,
                            possibleDefaultActivityInfo.packageName);

            if (matchesPossibleDefaultActivity) {
                defaultActivityResolveInfo = resolveInfo;
                break;
            }
        }
    }

    ContextualSearchUma.logQuickActionIntentResolution(mQuickActionCategory,
            numMatchingActivities);

    if (numMatchingActivities == 0) {
        reset();
        return;
    }

    mHasQuickAction = true;
    Drawable iconDrawable = null;
    int iconResId = 0;
    if (defaultActivityResolveInfo != null) {
        iconDrawable = defaultActivityResolveInfo.loadIcon(mContext.getPackageManager());

        if (mQuickActionCategory != QuickActionCategory.PHONE) {
            // Use the default app's name to construct the caption.
            mCaption = mContext.getResources().getString(
                    DEFAULT_APP_CAPTION_MAP.get(mQuickActionCategory),
                    defaultActivityResolveInfo.loadLabel(packageManager));
        } else {
            // The caption for phone numbers does not use the app's name.
            mCaption = mContext.getResources().getString(
                    DEFAULT_APP_CAPTION_MAP.get(mQuickActionCategory));
        }
    } else {
        iconResId = ICON_MAP.get(mQuickActionCategory);
        mCaption = mContext.getResources().getString(
                FALLBACK_CAPTION_MAP.get(mQuickActionCategory));
    }

    inflate();

    if (iconDrawable != null) {
        ((ImageView) getView()).setImageDrawable(iconDrawable);
    } else {
        ((ImageView) getView()).setImageResource(iconResId);
    }

    invalidate();
}
 
Example #6
Source File: ContextualSearchPanelMetrics.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * Called when a Search Term has been resolved.
 */
public void onSearchTermResolved() {
    long durationMs =
            (System.nanoTime() - mSearchRequestStartTimeNs) / MILLISECONDS_TO_NANOSECONDS;
    ContextualSearchUma.logSearchTermResolutionDuration(durationMs);
}
 
Example #7
Source File: ContextualSearchPanelMetrics.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * Called after the panel has navigated to prefetched Search Results.
 * This is the point where the search result starts to render in the panel.
 */
public void onPanelNavigatedToPrefetchedSearch(boolean didResolve) {
    long durationMs =
            (System.nanoTime() - mSearchRequestStartTimeNs) / MILLISECONDS_TO_NANOSECONDS;
    ContextualSearchUma.logPrefetchedSearchNavigatedDuration(durationMs, didResolve);
}
 
Example #8
Source File: ContextualSearchPanelMetrics.java    From delion with Apache License 2.0 2 votes vote down vote up
/**
 * Logs the duration the user waited for the search panel to fully load, once it was opened.
 * @param wasPrefetch Whether the load included prefetch.
 * @param durationMs The duration to log.
 */
private void logSearchPanelLoadDuration(boolean wasPrefetch, long durationMs) {
    ContextualSearchUma.logSearchPanelLoadDuration(wasPrefetch, durationMs);
}
 
Example #9
Source File: ContextualSearchPanelMetrics.java    From AndroidChromium with Apache License 2.0 2 votes vote down vote up
/**
 * Logs the duration the user waited for the search panel to fully load, once it was opened.
 * @param wasPrefetch Whether the load included prefetch.
 * @param durationMs The duration to log.
 */
private void logSearchPanelLoadDuration(boolean wasPrefetch, long durationMs) {
    ContextualSearchUma.logSearchPanelLoadDuration(wasPrefetch, durationMs);
}