Java Code Examples for org.chromium.chrome.browser.tab.Tab#isShowingErrorPage()
The following examples show how to use
org.chromium.chrome.browser.tab.Tab#isShowingErrorPage() .
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 |
/** * 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 |
/** * 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; }
Example 3
Source File: OfflinePageUtils.java From delion with Apache License 2.0 | 4 votes |
/** * Indicates whether we should skip saving the given tab as an offline page. * A tab shouldn't be saved offline if it shows an error page or a sad tab page. */ private static boolean shouldSkipSavingTabOffline(Tab tab) { WebContents webContents = tab.getWebContents(); return tab.isShowingErrorPage() || tab.isShowingSadTab() || webContents == null || webContents.isDestroyed() || webContents.isIncognito(); }
Example 4
Source File: OfflinePageUtils.java From AndroidChromium with Apache License 2.0 | 4 votes |
/** * Indicates whether we should skip saving the given tab as an offline page. * A tab shouldn't be saved offline if it shows an error page or a sad tab page. */ private static boolean shouldSkipSavingTabOffline(Tab tab) { WebContents webContents = tab.getWebContents(); return tab.isShowingErrorPage() || tab.isShowingSadTab() || webContents == null || webContents.isDestroyed() || webContents.isIncognito(); }
Example 5
Source File: OfflinePageUtils.java From 365browser with Apache License 2.0 | 4 votes |
/** * Indicates whether we should skip saving the given tab as an offline page. * A tab shouldn't be saved offline if it shows an error page or a sad tab page. */ private static boolean shouldSkipSavingTabOffline(Tab tab) { WebContents webContents = tab.getWebContents(); return tab.isShowingErrorPage() || tab.isShowingSadTab() || webContents == null || webContents.isDestroyed() || webContents.isIncognito(); }
Example 6
Source File: CustomTabActivity.java From 365browser with Apache License 2.0 | 4 votes |
/** * Loads the current tab with the given load params while taking client * referrer and extra headers into account. */ private void loadUrlInTab(final Tab tab, final LoadUrlParams params, long timeStamp) { Intent intent = getIntent(); String url = getUrlToLoad(); // Caching isFirstLoad value to deal with multiple return points. boolean isFirstLoad = mIsFirstLoad; mIsFirstLoad = false; // The following block is a hack that deals with urls preloaded with // the wrong fragment. Does an extra pageload and replaces history. if (mHasSpeculated && isFirstLoad && UrlUtilities.urlsFragmentsDiffer(mSpeculatedUrl, url)) { if (mUsingPrerender) { LoadUrlParams temporaryParams = new LoadUrlParams(mSpeculatedUrl); IntentHandler.addReferrerAndHeaders(temporaryParams, intent); tab.loadUrl(temporaryParams); } params.setShouldReplaceCurrentEntry(true); } mTabObserver.trackNextPageLoadFromTimestamp(tab, timeStamp); // Manually generating metrics in case the hidden tab has completely finished loading. if (mUsingHiddenTab && !tab.isLoading() && !tab.isShowingErrorPage()) { mTabObserver.onPageLoadStarted(tab, params.getUrl()); mTabObserver.onPageLoadFinished(tab); } // No actual load to do if tab already has the exact correct url. if (TextUtils.equals(mSpeculatedUrl, params.getUrl()) && mUsingHiddenTab && isFirstLoad) { return; } IntentHandler.addReferrerAndHeaders(params, intent); if (params.getReferrer() == null) { params.setReferrer(CustomTabsConnection.getInstance(getApplication()) .getReferrerForSession(mSession)); } // See ChromeTabCreator#getTransitionType(). This marks the navigation chain as starting // from an external intent (unless otherwise specified by an extra in the intent). params.setTransitionType(IntentHandler.getTransitionTypeFromIntent(intent, PageTransition.LINK | PageTransition.FROM_API)); tab.loadUrl(params); }