org.chromium.chrome.browser.tabmodel.document.AsyncTabCreationParams Java Examples

The following examples show how to use org.chromium.chrome.browser.tabmodel.document.AsyncTabCreationParams. 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: CustomTabDelegateFactory.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public void openNewTab(String url, String extraHeaders, ResourceRequestBody postData,
        int disposition, boolean isRendererInitiated) {
    // If attempting to open an incognito tab, always send the user to tabbed mode.
    if (disposition == WindowOpenDisposition.OFF_THE_RECORD) {
        if (isRendererInitiated) {
            throw new IllegalStateException(
                    "Invalid attempt to open an incognito tab from the renderer");
        }
        LoadUrlParams loadUrlParams = new LoadUrlParams(url);
        loadUrlParams.setVerbatimHeaders(extraHeaders);
        loadUrlParams.setPostData(postData);
        loadUrlParams.setIsRendererInitiated(isRendererInitiated);

        Class<? extends ChromeTabbedActivity> tabbedClass =
                MultiWindowUtils.getInstance().getTabbedActivityForIntent(
                        null, ContextUtils.getApplicationContext());
        AsyncTabCreationParams tabParams = new AsyncTabCreationParams(loadUrlParams,
                new ComponentName(ContextUtils.getApplicationContext(), tabbedClass));
        new TabDelegate(true).createNewTab(tabParams,
                TabLaunchType.FROM_LONGPRESS_FOREGROUND, TabModel.INVALID_TAB_INDEX);
        return;
    }

    super.openNewTab(url, extraHeaders, postData, disposition, isRendererInitiated);
}
 
Example #2
Source File: OfflinePageDownloadBridge.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * 'Opens' the offline page identified by the GUID.
 * This is done by creating a new tab and navigating it to the saved local snapshot.
 * No automatic redirection is happening based on the connection status.
 * If the item with specified GUID is not found or can't be opened, nothing happens.
 * @param guid          GUID of the item to open.
 * @param componentName If specified, targets a specific Activity to open the offline page in.
 */
@Override
public void openItem(String guid, @Nullable ComponentName componentName) {
    OfflinePageDownloadItem item = getItem(guid);
    if (item == null) return;

    LoadUrlParams params = OfflinePageUtils.getLoadUrlParamsForOpeningOfflineVersion(
            item.getUrl(), nativeGetOfflineIdByGuid(mNativeOfflinePageDownloadBridge, guid));
    AsyncTabCreationParams asyncParams = componentName == null
            ? new AsyncTabCreationParams(params)
            : new AsyncTabCreationParams(params, componentName);
    final TabDelegate tabDelegate = new TabDelegate(false);
    tabDelegate.createNewTab(asyncParams, TabLaunchType.FROM_CHROME_UI, Tab.INVALID_TAB_ID);
}
 
Example #3
Source File: OfflinePageDownloadBridge.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * 'Opens' the offline page identified by the GUID.
 * This is done by creating a new tab and navigating it to the saved local snapshot.
 * No automatic redirection is happening based on the connection status.
 * If the item with specified GUID is not found or can't be opened, nothing happens.
 * @param guid          GUID of the item to open.
 * @param componentName If specified, targets a specific Activity to open the offline page in.
 */
@Override
public void openItem(String guid, @Nullable ComponentName componentName) {
    OfflinePageDownloadItem item = getItem(guid);
    if (item == null) return;

    LoadUrlParams params = OfflinePageUtils.getLoadUrlParamsForOpeningOfflineVersion(
            item.getUrl(), nativeGetOfflineIdByGuid(mNativeOfflinePageDownloadBridge, guid));
    AsyncTabCreationParams asyncParams = componentName == null
            ? new AsyncTabCreationParams(params)
            : new AsyncTabCreationParams(params, componentName);
    final TabDelegate tabDelegate = new TabDelegate(false);
    tabDelegate.createNewTab(asyncParams, TabLaunchType.FROM_CHROME_UI, Tab.INVALID_TAB_ID);
}