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

The following examples show how to use org.chromium.chrome.browser.tab.Tab#isLoading() . 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: ToolbarManager.java    From delion with Apache License 2.0 6 votes vote down vote up
private void updateCurrentTabDisplayStatus() {
    Tab tab = mToolbarModel.getTab();
    mLocationBar.setUrlToPageUrl();

    updateTabLoadingState(true);

    if (tab == null) {
        finishLoadProgress(false);
        return;
    }

    mLoadProgressSimulator.cancel();

    if (tab.isLoading()) {
        if (NativePageFactory.isNativePageUrl(tab.getUrl(), tab.isIncognito())) {
            finishLoadProgress(false);
        } else {
            startLoadProgress();
            updateLoadProgress(tab.getProgress());
        }
    } else {
        finishLoadProgress(false);
    }
}
 
Example 2
Source File: ToolbarManager.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
private void updateCurrentTabDisplayStatus() {
    Tab tab = mToolbarModel.getTab();
    mLocationBar.setUrlToPageUrl();

    updateTabLoadingState(true);

    if (tab == null) {
        finishLoadProgress(false);
        return;
    }

    mLoadProgressSimulator.cancel();

    if (tab.isLoading()) {
        if (NativePageFactory.isNativePageUrl(tab.getUrl(), tab.isIncognito())) {
            finishLoadProgress(false);
        } else {
            startLoadProgress();
            updateLoadProgress(tab.getProgress());
        }
    } else {
        finishLoadProgress(false);
    }
}
 
Example 3
Source File: ToolbarManager.java    From 365browser with Apache License 2.0 6 votes vote down vote up
private void updateCurrentTabDisplayStatus() {
    Tab tab = mToolbarModel.getTab();
    mLocationBar.setUrlToPageUrl();

    updateTabLoadingState(true);

    if (tab == null) {
        finishLoadProgress(false);
        return;
    }

    mLoadProgressSimulator.cancel();

    if (tab.isLoading()) {
        if (NativePageFactory.isNativePageUrl(tab.getUrl(), tab.isIncognito())) {
            finishLoadProgress(false);
        } else {
            startLoadProgress();
            updateLoadProgress(tab.getProgress());
        }
    } else {
        finishLoadProgress(false);
    }
}
 
Example 4
Source File: ToolbarManager.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void stopOrReloadCurrentTab() {
    Tab currentTab = mToolbarModel.getTab();
    if (currentTab != null) {
        if (currentTab.isLoading()) {
            currentTab.stopLoading();
        } else {
            currentTab.reload();
            RecordUserAction.record("MobileToolbarReload");
        }
    }
    updateButtonStatus();
}
 
Example 5
Source File: ToolbarManager.java    From delion with Apache License 2.0 5 votes vote down vote up
private void updateReloadState(boolean tabCrashed) {
    Tab currentTab = mToolbarModel.getTab();
    boolean isLoading = false;
    if (!tabCrashed) {
        isLoading = (currentTab != null && currentTab.isLoading()) || !mNativeLibraryReady;
    }
    mToolbar.updateReloadButtonVisibility(isLoading);
    if (mMenuDelegatePhone != null) mMenuDelegatePhone.updateReloadButtonState(isLoading);
}
 
Example 6
Source File: ToolbarManager.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void stopOrReloadCurrentTab() {
    Tab currentTab = mToolbarModel.getTab();
    if (currentTab != null) {
        if (currentTab.isLoading()) {
            currentTab.stopLoading();
            RecordUserAction.record("MobileToolbarStop");
        } else {
            currentTab.reload();
            RecordUserAction.record("MobileToolbarReload");
        }
    }
    updateButtonStatus();
}
 
Example 7
Source File: ToolbarManager.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private void updateReloadState(boolean tabCrashed) {
    Tab currentTab = mToolbarModel.getTab();
    boolean isLoading = false;
    if (!tabCrashed) {
        isLoading = (currentTab != null && currentTab.isLoading()) || !mNativeLibraryReady;
    }
    mToolbar.updateReloadButtonVisibility(isLoading);
    if (mMenuDelegatePhone != null) mMenuDelegatePhone.updateReloadButtonState(isLoading);
}
 
Example 8
Source File: CustomTabObserver.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Tracks the next page load, with timestamp as the origin of time.
 * If a load is already happening, we track its PLT.
 * If not, we track NavigationCommit timing + PLT for the next load.
 */
public void trackNextPageLoadFromTimestamp(Tab tab, long timestamp) {
    mIntentReceivedTimestamp = timestamp;
    if (tab.isLoading()) {
        mPageLoadStartedTimestamp = -1;
        mCurrentState = STATE_WAITING_LOAD_FINISH;
    } else {
        mCurrentState = STATE_WAITING_LOAD_START;
    }
}
 
Example 9
Source File: ToolbarManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void stopOrReloadCurrentTab() {
    Tab currentTab = mToolbarModel.getTab();
    if (currentTab != null) {
        if (currentTab.isLoading()) {
            currentTab.stopLoading();
            RecordUserAction.record("MobileToolbarStop");
        } else {
            currentTab.reload();
            RecordUserAction.record("MobileToolbarReload");
        }
    }
    updateButtonStatus();
}
 
Example 10
Source File: ToolbarManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private void updateReloadState(boolean tabCrashed) {
    Tab currentTab = mToolbarModel.getTab();
    boolean isLoading = false;
    if (!tabCrashed) {
        isLoading = (currentTab != null && currentTab.isLoading()) || !mNativeLibraryReady;
    }
    mToolbar.updateReloadButtonVisibility(isLoading);
    if (mMenuDelegatePhone != null) mMenuDelegatePhone.updateReloadButtonState(isLoading);
}
 
Example 11
Source File: ChromeActivity.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * Handles menu item selection and keyboard shortcuts.
 *
 * @param id The ID of the selected menu item (defined in main_menu.xml) or
 *           keyboard shortcut (defined in values.xml).
 * @param fromMenu Whether this was triggered from the menu.
 * @return Whether the action was handled.
 */
public boolean onMenuOrKeyboardAction(int id, boolean fromMenu) {
    if (id == R.id.preferences_id) {
        PreferencesLauncher.launchSettingsPage(this, null);
        RecordUserAction.record("MobileMenuSettings");
    } else if (id == R.id.show_menu) {
        showAppMenuForKeyboardEvent();
    }

    if (id == R.id.update_menu_id) {
        UpdateMenuItemHelper.getInstance().onMenuItemClicked(this);
        return true;
    }

    // All the code below assumes currentTab is not null, so return early if it is null.
    final Tab currentTab = getActivityTab();
    if (currentTab == null) {
        return false;
    } else if (id == R.id.forward_menu_id) {
        if (currentTab.canGoForward()) {
            currentTab.goForward();
            RecordUserAction.record("MobileMenuForward");
            RecordUserAction.record("MobileTabClobbered");
        }
    } else if (id == R.id.bookmark_this_page_id) {
        addOrEditBookmark(currentTab);
        RecordUserAction.record("MobileMenuAddToBookmarks");
    } else if (id == R.id.reload_menu_id) {
        if (currentTab.isLoading()) {
            currentTab.stopLoading();
        } else {
            currentTab.reload();
            RecordUserAction.record("MobileToolbarReload");
        }
    } else if (id == R.id.info_menu_id) {
        WebsiteSettingsPopup.show(
                this, currentTab, null, WebsiteSettingsPopup.OPENED_FROM_MENU);
    } else if (id == R.id.open_history_menu_id) {
        currentTab.loadUrl(
                new LoadUrlParams(UrlConstants.HISTORY_URL, PageTransition.AUTO_TOPLEVEL));
        RecordUserAction.record("MobileMenuHistory");
        StartupMetrics.getInstance().recordOpenedHistory();
    } else if (id == R.id.share_menu_id || id == R.id.direct_share_menu_id) {
        onShareMenuItemSelected(id == R.id.direct_share_menu_id,
                getCurrentTabModel().isIncognito());
    } else if (id == R.id.print_id) {
        PrintingController printingController = getChromeApplication().getPrintingController();
        if (printingController != null && !printingController.isBusy()
                && PrefServiceBridge.getInstance().isPrintingEnabled()) {
            printingController.startPrint(new TabPrinter(currentTab),
                    new PrintManagerDelegateImpl(this));
            RecordUserAction.record("MobileMenuPrint");
        }
    } else if (id == R.id.add_to_homescreen_id) {
        AddToHomescreenDialog.show(this, currentTab);
        RecordUserAction.record("MobileMenuAddToHomescreen");
    } else if (id == R.id.request_desktop_site_id) {
        final boolean reloadOnChange = !currentTab.isNativePage();
        final boolean usingDesktopUserAgent = currentTab.getUseDesktopUserAgent();
        currentTab.setUseDesktopUserAgent(!usingDesktopUserAgent, reloadOnChange);
        RecordUserAction.record("MobileMenuRequestDesktopSite");
    } else if (id == R.id.reader_mode_prefs_id) {
        if (currentTab.getWebContents() != null) {
            RecordUserAction.record("DomDistiller_DistilledPagePrefsOpened");
            AlertDialog.Builder builder =
                    new AlertDialog.Builder(this, R.style.AlertDialogTheme);
            builder.setView(DistilledPagePrefsView.create(this));
            builder.show();
        }
    } else if (id == R.id.help_id) {
        // Since reading back the compositor is asynchronous, we need to do the readback
        // before starting the GoogleHelp.
        String helpContextId = HelpAndFeedback.getHelpContextIdFromUrl(
                this, currentTab.getUrl(), getCurrentTabModel().isIncognito());
        HelpAndFeedback.getInstance(this)
                .show(this, helpContextId, currentTab.getProfile(), currentTab.getUrl());
        RecordUserAction.record("MobileMenuFeedback");
    } else {
        return false;
    }
    return true;
}
 
Example 12
Source File: ChromeActivity.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * Handles menu item selection and keyboard shortcuts.
 *
 * @param id The ID of the selected menu item (defined in main_menu.xml) or
 *           keyboard shortcut (defined in values.xml).
 * @param fromMenu Whether this was triggered from the menu.
 * @return Whether the action was handled.
 */
public boolean onMenuOrKeyboardAction(int id, boolean fromMenu) {
    if (id == R.id.preferences_id) {
        PreferencesLauncher.launchSettingsPage(this, null);
        RecordUserAction.record("MobileMenuSettings");
    } else if (id == R.id.show_menu) {
        showAppMenuForKeyboardEvent();
    }

    if (id == R.id.update_menu_id) {
        UpdateMenuItemHelper.getInstance().onMenuItemClicked(this);
        return true;
    }

    // All the code below assumes currentTab is not null, so return early if it is null.
    final Tab currentTab = getActivityTab();
    if (currentTab == null) {
        return false;
    } else if (id == R.id.forward_menu_id) {
        if (currentTab.canGoForward()) {
            currentTab.goForward();
            RecordUserAction.record("MobileMenuForward");
            RecordUserAction.record("MobileTabClobbered");
        }
    } else if (id == R.id.bookmark_this_page_id) {
        addOrEditBookmark(currentTab);
        RecordUserAction.record("MobileMenuAddToBookmarks");
    } else if (id == R.id.offline_page_id) {
        DownloadUtils.downloadOfflinePage(this, currentTab);
        RecordUserAction.record("MobileMenuDownloadPage");
    } else if (id == R.id.reload_menu_id) {
        if (currentTab.isLoading()) {
            currentTab.stopLoading();
            RecordUserAction.record("MobileMenuStop");
        } else {
            currentTab.reload();
            RecordUserAction.record("MobileMenuReload");
        }
    } else if (id == R.id.info_menu_id) {
        WebsiteSettingsPopup.show(
                this, currentTab, null, WebsiteSettingsPopup.OPENED_FROM_MENU);
    } else if (id == R.id.open_history_menu_id) {
        currentTab.loadUrl(
                new LoadUrlParams(UrlConstants.HISTORY_URL, PageTransition.AUTO_TOPLEVEL));
        RecordUserAction.record("MobileMenuHistory");
        StartupMetrics.getInstance().recordOpenedHistory();
    } else if (id == R.id.share_menu_id || id == R.id.direct_share_menu_id) {
        onShareMenuItemSelected(id == R.id.direct_share_menu_id,
                getCurrentTabModel().isIncognito());
    } else if (id == R.id.print_id) {
        PrintingController printingController = PrintingControllerImpl.getInstance();
        if (printingController != null && !printingController.isBusy()
                && PrefServiceBridge.getInstance().isPrintingEnabled()) {
            printingController.startPrint(new TabPrinter(currentTab),
                    new PrintManagerDelegateImpl(this));
            RecordUserAction.record("MobileMenuPrint");
        }
    } else if (id == R.id.add_to_homescreen_id) {
        AddToHomescreenManager addToHomescreenManager =
                new AddToHomescreenManager(this, currentTab);
        addToHomescreenManager.start();
        RecordUserAction.record("MobileMenuAddToHomescreen");
    } else if (id == R.id.request_desktop_site_id) {
        final boolean reloadOnChange = !currentTab.isNativePage();
        final boolean usingDesktopUserAgent = currentTab.getUseDesktopUserAgent();
        currentTab.setUseDesktopUserAgent(!usingDesktopUserAgent, reloadOnChange);
        RecordUserAction.record("MobileMenuRequestDesktopSite");
    } else if (id == R.id.reader_mode_prefs_id) {
        if (currentTab.getWebContents() != null) {
            RecordUserAction.record("DomDistiller_DistilledPagePrefsOpened");
            AlertDialog.Builder builder =
                    new AlertDialog.Builder(this, R.style.AlertDialogTheme);
            builder.setView(DistilledPagePrefsView.create(this));
            builder.show();
        }
    } else if (id == R.id.help_id) {
        // Since reading back the compositor is asynchronous, we need to do the readback
        // before starting the GoogleHelp.
        String helpContextId = HelpAndFeedback.getHelpContextIdFromUrl(
                this, currentTab.getUrl(), getCurrentTabModel().isIncognito());
        HelpAndFeedback.getInstance(this)
                .show(this, helpContextId, currentTab.getProfile(), currentTab.getUrl());
        RecordUserAction.record("MobileMenuFeedback");
    } else {
        return false;
    }
    return true;
}
 
Example 13
Source File: CustomTabActivity.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * 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);
}