当前位置: 首页>>代码示例>>Java>>正文


Java CustomTabsSessionToken.equals方法代码示例

本文整理汇总了Java中android.support.customtabs.CustomTabsSessionToken.equals方法的典型用法代码示例。如果您正苦于以下问题:Java CustomTabsSessionToken.equals方法的具体用法?Java CustomTabsSessionToken.equals怎么用?Java CustomTabsSessionToken.equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.customtabs.CustomTabsSessionToken的用法示例。


在下文中一共展示了CustomTabsSessionToken.equals方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleInActiveContentIfNeeded

import android.support.customtabs.CustomTabsSessionToken; //导入方法依赖的package包/类
/**
 * Used to check whether an incoming intent can be handled by the
 * current {@link CustomTabContentHandler}.
 * @return Whether the active {@link CustomTabContentHandler} has handled the intent.
 */
public static boolean handleInActiveContentIfNeeded(Intent intent) {
    if (sActiveContentHandler == null) return false;

    if (sActiveContentHandler.shouldIgnoreIntent(intent)) {
        Log.w(TAG, "Incoming intent to Custom Tab was ignored.");
        return false;
    }

    CustomTabsSessionToken session = CustomTabsSessionToken.getSessionTokenFromIntent(intent);
    if (session == null || !session.equals(sActiveContentHandler.getSession())) return false;

    String url = IntentHandler.getUrlFromIntent(intent);
    if (TextUtils.isEmpty(url)) return false;
    sActiveContentHandler.loadUrlAndTrackFromTimestamp(new LoadUrlParams(url),
            IntentHandler.getTimestampFromIntent(intent));
    return true;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:23,代码来源:CustomTabActivity.java

示例2: cancelSpeculation

import android.support.customtabs.CustomTabsSessionToken; //导入方法依赖的package包/类
/** Cancels the speculation for a given session, or any session if null. */
void cancelSpeculation(CustomTabsSessionToken session) {
    ThreadUtils.assertOnUiThread();
    if (mSpeculation == null) return;
    if (session == null || session.equals(mSpeculation.session)) {
        switch (mSpeculation.speculationMode) {
            case SpeculationParams.PRERENDER:
                if (mSpeculation.webContents == null) return;
                mExternalPrerenderHandler.cancelCurrentPrerender();
                mSpeculation.webContents.destroy();
                break;
            case SpeculationParams.PREFETCH:
                Profile profile = Profile.getLastUsedProfile();
                new LoadingPredictor(profile).cancelPageLoadHint(mSpeculation.url);
                break;
            default:
                return;
        }
        mSpeculation = null;
    }
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:22,代码来源:CustomTabsConnection.java

示例3: takePrerenderedUrl

import android.support.customtabs.CustomTabsSessionToken; //导入方法依赖的package包/类
/**
 * Transfers a prerendered WebContents if one exists.
 *
 * This resets the internal WebContents; a subsequent call to this method
 * returns null. Must be called from the UI thread.
 * If a prerender exists for a different URL with the same sessionId or with
 * a different referrer, then this is treated as a mispredict from the
 * client application, and cancels the previous prerender. This is done to
 * avoid keeping resources laying around for too long, but is subject to a
 * race condition, as the following scenario is possible:
 * The application calls:
 * 1. mayLaunchUrl(url1) <- IPC
 * 2. loadUrl(url2) <- Intent
 * 3. mayLaunchUrl(url3) <- IPC
 * If the IPC for url3 arrives before the intent for url2, then this methods
 * cancels the prerender for url3, which is unexpected. On the other
 * hand, not cancelling the previous prerender leads to wasted resources, as
 * a WebContents is lingering. This can be solved by requiring applications
 * to call mayLaunchUrl(null) to cancel a current prerender before 2, that
 * is for a mispredict.
 *
 * Note that this methods accepts URLs that don't exactly match the initially
 * prerendered URL. More precisely, the #fragment is ignored. In this case,
 * the client needs to navigate to the correct URL after the WebContents
 * swap. This can be tested using {@link UrlUtilities#urlsFragmentsDiffer()}.
 *
 * @param session The Binder object identifying a session.
 * @param url The URL the WebContents is for.
 * @param referrer The referrer to use for |url|.
 * @return The prerendered WebContents, or null.
 */
WebContents takePrerenderedUrl(CustomTabsSessionToken session, String url, String referrer) {
    ThreadUtils.assertOnUiThread();
    if (mSpeculation == null || session == null || !session.equals(mSpeculation.session)) {
        return null;
    }

    if (mSpeculation.prefetchOnly) {
        Profile profile = Profile.getLastUsedProfile();
        new ResourcePrefetchPredictor(profile).stopPrefetching(mSpeculation.url);
        mSpeculation = null;
        return null;
    }

    WebContents webContents = mSpeculation.webContents;
    String prerenderedUrl = mSpeculation.url;
    String prerenderReferrer = mSpeculation.referrer;
    if (referrer == null) referrer = "";
    boolean ignoreFragments = mClientManager.getIgnoreFragmentsForSession(session);
    boolean urlsMatch = TextUtils.equals(prerenderedUrl, url)
            || (ignoreFragments
                    && UrlUtilities.urlsMatchIgnoringFragments(prerenderedUrl, url));
    WebContents result = null;
    if (urlsMatch && TextUtils.equals(prerenderReferrer, referrer)) {
        result = webContents;
        mSpeculation = null;
    } else {
        cancelPrerender(session);
    }
    if (!mClientManager.usesDefaultSessionParameters(session) && webContents != null) {
        RecordHistogram.recordBooleanHistogram(
                "CustomTabs.NonDefaultSessionPrerenderMatched", result != null);
    }

    return result;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:67,代码来源:CustomTabsConnection.java

示例4: getPrerenderedUrl

import android.support.customtabs.CustomTabsSessionToken; //导入方法依赖的package包/类
/** Returns the URL prerendered for a session, or null. */
String getPrerenderedUrl(CustomTabsSessionToken session) {
    if (mSpeculation == null || session == null || !session.equals(mSpeculation.session)) {
        return null;
    }
    return mSpeculation.webContents != null ? mSpeculation.url : null;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:8,代码来源:CustomTabsConnection.java

示例5: cancelPrerender

import android.support.customtabs.CustomTabsSessionToken; //导入方法依赖的package包/类
/** Cancels a prerender for a given session, or any session if null. */
void cancelPrerender(CustomTabsSessionToken session) {
    ThreadUtils.assertOnUiThread();
    if (mSpeculation != null && (session == null || session.equals(mSpeculation.session))
            && mSpeculation.webContents != null) {
        mExternalPrerenderHandler.cancelCurrentPrerender();
        mSpeculation.webContents.destroy();
        mSpeculation = null;
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:11,代码来源:CustomTabsConnection.java

示例6: takePrerenderedUrl

import android.support.customtabs.CustomTabsSessionToken; //导入方法依赖的package包/类
/**
 * Transfers a prerendered WebContents if one exists.
 *
 * This resets the internal WebContents; a subsequent call to this method
 * returns null. Must be called from the UI thread.
 * If a prerender exists for a different URL with the same sessionId or with
 * a different referrer, then this is treated as a mispredict from the
 * client application, and cancels the previous prerender. This is done to
 * avoid keeping resources laying around for too long, but is subject to a
 * race condition, as the following scenario is possible:
 * The application calls:
 * 1. mayLaunchUrl(url1) <- IPC
 * 2. loadUrl(url2) <- Intent
 * 3. mayLaunchUrl(url3) <- IPC
 * If the IPC for url3 arrives before the intent for url2, then this methods
 * cancels the prerender for url3, which is unexpected. On the other
 * hand, not cancelling the previous prerender leads to wasted resources, as
 * a WebContents is lingering. This can be solved by requiring applications
 * to call mayLaunchUrl(null) to cancel a current prerender before 2, that
 * is for a mispredict.
 *
 * Note that this methods accepts URLs that don't exactly match the initially
 * prerendered URL. More precisely, the #fragment is ignored. In this case,
 * the client needs to navigate to the correct URL after the WebContents
 * swap. This can be tested using {@link UrlUtilities#urlsFragmentsDiffer()}.
 *
 * @param session The Binder object identifying a session.
 * @param url The URL the WebContents is for.
 * @param referrer The referrer to use for |url|.
 * @return The prerendered WebContents, or null.
 */
WebContents takePrerenderedUrl(CustomTabsSessionToken session, String url, String referrer) {
    ThreadUtils.assertOnUiThread();
    if (mSpeculation == null || session == null || !session.equals(mSpeculation.session)) {
        return null;
    }

    if (mSpeculation.speculationMode == SpeculationParams.PREFETCH) {
        cancelSpeculation(session);
        return null;
    }

    WebContents webContents = mSpeculation.webContents;
    String prerenderedUrl = mSpeculation.url;
    String prerenderReferrer = mSpeculation.referrer;
    if (referrer == null) referrer = "";
    boolean ignoreFragments = mClientManager.getIgnoreFragmentsForSession(session);
    boolean urlsMatch = TextUtils.equals(prerenderedUrl, url)
            || (ignoreFragments
                    && UrlUtilities.urlsMatchIgnoringFragments(prerenderedUrl, url));
    WebContents result = null;
    if (urlsMatch && TextUtils.equals(prerenderReferrer, referrer)) {
        result = webContents;
        mSpeculation = null;
    } else {
        cancelSpeculation(session);
    }
    if (!mClientManager.usesDefaultSessionParameters(session) && webContents != null) {
        RecordHistogram.recordBooleanHistogram(
                "CustomTabs.NonDefaultSessionPrerenderMatched", result != null);
    }

    return result;
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:65,代码来源:CustomTabsConnection.java

示例7: getSpeculatedUrl

import android.support.customtabs.CustomTabsSessionToken; //导入方法依赖的package包/类
String getSpeculatedUrl(CustomTabsSessionToken session) {
    if (mSpeculation == null || session == null || !session.equals(mSpeculation.session)) {
        return null;
    }
    switch (mSpeculation.speculationMode) {
        case SpeculationParams.PRERENDER:
            return mSpeculation.webContents != null ? mSpeculation.url : null;
        case SpeculationParams.HIDDEN_TAB:
            return mSpeculation.tab != null ? mSpeculation.url : null;
        default:
            return null;
    }
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:14,代码来源:CustomTabsConnection.java


注:本文中的android.support.customtabs.CustomTabsSessionToken.equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。