Java Code Examples for org.chromium.chrome.browser.tab.Tab#enableEmbeddedMediaExperience()

The following examples show how to use org.chromium.chrome.browser.tab.Tab#enableEmbeddedMediaExperience() . 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: CustomTabActivity.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Encapsulates CustomTabsConnection#takeHiddenTab()
 * with additional initialization logic.
 */
private Tab getHiddenTab(CustomTabsConnection connection) {
    String url = getUrlToLoad();
    String referrerUrl = connection.getReferrer(mSession, getIntent());
    Tab tab = connection.takeHiddenTab(mSession, url, referrerUrl);
    mUsingHiddenTab = tab != null;
    if (!mUsingHiddenTab) return null;
    RecordHistogram.recordEnumeratedHistogram("CustomTabs.WebContentsStateOnLaunch",
            WEBCONTENTS_STATE_PRERENDERED_WEBCONTENTS, WEBCONTENTS_STATE_MAX);
    tab.setAppAssociatedWith(connection.getClientPackageNameForSession(mSession));
    if (mIntentDataProvider.shouldEnableEmbeddedMediaExperience()) {
        tab.enableEmbeddedMediaExperience(true);
    }
    initializeMainTab(tab);
    return tab;
}
 
Example 2
Source File: CustomTabActivity.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private Tab createMainTab() {
    CustomTabsConnection connection = CustomTabsConnection.getInstance(getApplication());
    String url = getUrlToLoad();
    String referrerUrl = connection.getReferrer(mSession, getIntent());
    Tab tab = new Tab(Tab.INVALID_TAB_ID, Tab.INVALID_TAB_ID, false, this, getWindowAndroid(),
            TabLaunchType.FROM_EXTERNAL_APP, null, null);
    tab.setAppAssociatedWith(connection.getClientPackageNameForSession(mSession));

    int webContentsStateOnLaunch = WEBCONTENTS_STATE_NO_WEBCONTENTS;
    WebContents webContents = connection.takePrerenderedUrl(mSession, url, referrerUrl);
    mUsingPrerender = webContents != null;
    if (mUsingPrerender) webContentsStateOnLaunch = WEBCONTENTS_STATE_PRERENDERED_WEBCONTENTS;
    if (!mUsingPrerender) {
        webContents = WarmupManager.getInstance().takeSpareWebContents(false, false);
        if (webContents != null) webContentsStateOnLaunch = WEBCONTENTS_STATE_SPARE_WEBCONTENTS;
    }
    RecordHistogram.recordEnumeratedHistogram("CustomTabs.WebContentsStateOnLaunch",
            webContentsStateOnLaunch, WEBCONTENTS_STATE_MAX);
    if (webContents == null) {
        webContents = WebContentsFactory.createWebContentsWithWarmRenderer(false, false);
    }
    if (!mUsingPrerender) {
        connection.resetPostMessageHandlerForSession(mSession, webContents);
    }
    tab.initialize(
            webContents, getTabContentManager(),
            new CustomTabDelegateFactory(
                    mIntentDataProvider.shouldEnableUrlBarHiding(),
                    mIntentDataProvider.isOpenedByChrome(),
                    getFullscreenManager().getBrowserVisibilityDelegate()),
            false, false);

    if (mIntentDataProvider.shouldEnableEmbeddedMediaExperience()) {
        tab.enableEmbeddedMediaExperience(true);
    }

    initializeMainTab(tab);
    return tab;
}