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

The following examples show how to use org.chromium.chrome.browser.tab.Tab#isShowingInterstitialPage() . 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: DownloadUtils.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Whether the user should be allowed to download the current page.
 * @param tab Tab displaying the page that will be downloaded.
 * @return    Whether the "Download Page" button should be enabled.
 */
public static boolean isAllowedToDownloadPage(Tab tab) {
    if (tab == null) return false;

    // Only allow HTTP and HTTPS pages, as that is these are the only scenarios supported by the
    // background/offline page saving.
    if (!tab.getUrl().startsWith(UrlConstants.HTTP_SCHEME)
            && !tab.getUrl().startsWith(UrlConstants.HTTPS_SCHEME)) {
        return false;
    }
    if (tab.isShowingErrorPage()) return false;
    if (tab.isShowingInterstitialPage()) return false;

    // Don't allow re-downloading the currently displayed offline page.
    if (tab.isOfflinePage()) return false;

    // Offline pages isn't supported in Incognito.
    if (tab.isIncognito()) return false;

    return true;
}
 
Example 2
Source File: DownloadUtils.java    From 365browser with Apache License 2.0 6 votes vote down vote up
/**
 * Whether the user should be allowed to download the current page.
 * @param tab Tab displaying the page that will be downloaded.
 * @return    Whether the "Download Page" button should be enabled.
 */
public static boolean isAllowedToDownloadPage(Tab tab) {
    if (tab == null) return false;

    // Offline pages isn't supported in Incognito. This should be checked before calling
    // OfflinePageBridge.getForProfile because OfflinePageBridge instance will not be found
    // for incognito profile.
    if (tab.isIncognito()) return false;

    // Check if the page url is supported for saving. Only HTTP and HTTPS pages are allowed.
    if (!OfflinePageBridge.canSavePage(tab.getUrl())) return false;

    // Download will only be allowed for the error page if download button is shown in the page.
    if (tab.isShowingErrorPage()) {
        final OfflinePageBridge bridge = OfflinePageBridge.getForProfile(tab.getProfile());
        return bridge.isShowingDownloadButtonInErrorPage(tab.getWebContents());
    }

    if (tab.isShowingInterstitialPage()) return false;

    // Don't allow re-downloading the currently displayed offline page.
    if (OfflinePageUtils.isOfflinePage(tab)) return false;

    return true;
}