Java源码示例:org.chromium.chrome.browser.contextualsearch.ContextualSearchUma

示例1
/**
 * Called when a Search Term has been resolved.
 */
public void onSearchTermResolved() {
    long durationMs =
            (System.nanoTime() - mSearchRequestStartTimeNs) / MILLISECONDS_TO_NANOSECONDS;
    ContextualSearchUma.logSearchTermResolutionDuration(durationMs);
}
 
示例2
/**
 * 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);
}
 
示例3
/**
 * Called when a Search Term has been resolved.
 */
public void onSearchTermResolved() {
    long durationMs =
            (System.nanoTime() - mSearchRequestStartTimeNs) / MILLISECONDS_TO_NANOSECONDS;
    ContextualSearchUma.logSearchTermResolutionDuration(durationMs);
}
 
示例4
/**
 * 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);
}
 
示例5
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();
}
 
示例6
/**
 * Called when a Search Term has been resolved.
 */
public void onSearchTermResolved() {
    long durationMs =
            (System.nanoTime() - mSearchRequestStartTimeNs) / MILLISECONDS_TO_NANOSECONDS;
    ContextualSearchUma.logSearchTermResolutionDuration(durationMs);
}
 
示例7
/**
 * 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);
}
 
示例8
/**
 * 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);
}
 
示例9
/**
 * 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);
}