Search in sources :

Example 81 with Tab

use of org.chromium.chrome.browser.tab.Tab in project AndroidChromium by JackyAndroid.

the class ToolbarManager method updateButtonStatus.

/**
     * Updates the current button states and calls appropriate abstract visibility methods, giving
     * inheriting classes the chance to update the button visuals as well.
     */
private void updateButtonStatus() {
    Tab currentTab = mToolbarModel.getTab();
    boolean tabCrashed = currentTab != null && currentTab.isShowingSadTab();
    mToolbar.updateButtonVisibility();
    mToolbar.updateBackButtonVisibility(currentTab != null && currentTab.canGoBack());
    mToolbar.updateForwardButtonVisibility(currentTab != null && currentTab.canGoForward());
    updateReloadState(tabCrashed);
    updateBookmarkButtonStatus();
    mToolbar.getMenuButtonWrapper().setVisibility(View.VISIBLE);
}
Also used : Tab(org.chromium.chrome.browser.tab.Tab)

Example 82 with Tab

use of org.chromium.chrome.browser.tab.Tab in project AndroidChromium by JackyAndroid.

the class ToolbarManager method back.

@Override
public boolean back() {
    Tab tab = mToolbarModel.getTab();
    if (tab != null && tab.canGoBack()) {
        tab.goBack();
        updateButtonStatus();
        return true;
    }
    return false;
}
Also used : Tab(org.chromium.chrome.browser.tab.Tab)

Example 83 with Tab

use of org.chromium.chrome.browser.tab.Tab in project AndroidChromium by JackyAndroid.

the class ToolbarManager method refreshSelectedTab.

/**
     * Triggered when the selected tab has changed.
     */
private void refreshSelectedTab() {
    Tab tab = null;
    if (mPreselectedTabId != Tab.INVALID_TAB_ID) {
        tab = mTabModelSelector.getTabById(mPreselectedTabId);
    }
    if (tab == null)
        tab = mTabModelSelector.getCurrentTab();
    boolean wasIncognito = mToolbarModel.isIncognito();
    Tab previousTab = mToolbarModel.getTab();
    boolean isIncognito = tab != null ? tab.isIncognito() : mTabModelSelector.isIncognitoSelected();
    mToolbarModel.setTab(tab, isIncognito);
    updateCurrentTabDisplayStatus();
    if (previousTab != tab || wasIncognito != isIncognito) {
        if (previousTab != tab) {
            if (previousTab != null) {
                previousTab.removeObserver(mTabObserver);
                previousTab.setIsAllowedToReturnToExternalApp(false);
            }
            if (tab != null)
                tab.addObserver(mTabObserver);
        }
        int defaultPrimaryColor = isIncognito ? ApiCompatibilityUtils.getColor(mToolbar.getResources(), R.color.incognito_primary_color) : ApiCompatibilityUtils.getColor(mToolbar.getResources(), R.color.default_primary_color);
        int primaryColor = tab != null ? tab.getThemeColor() : defaultPrimaryColor;
        updatePrimaryColor(primaryColor, false);
        mToolbar.onTabOrModelChanged();
        if (tab != null && tab.getWebContents() != null && tab.getWebContents().isLoadingToDifferentDocument()) {
            mToolbar.onNavigatedToDifferentPage();
        }
        // Ensure the URL bar loses focus if the tab it was interacting with is changed from
        // underneath it.
        setUrlBarFocus(false);
        // needed, we will refocus the omnibox and make the cursor visible here.
        if (shouldShowCusrsorInLocationBar()) {
            mToolbar.getLocationBar().showUrlBarCursorWithoutFocusAnimations();
        }
    }
    Profile profile = mTabModelSelector.getModel(isIncognito).getProfile();
    if (mCurrentProfile != profile) {
        if (mBookmarkBridge != null)
            mBookmarkBridge.destroy();
        mBookmarkBridge = new BookmarkBridge(profile);
        mBookmarkBridge.addObserver(mBookmarksObserver);
        mAppMenuPropertiesDelegate.setBookmarkBridge(mBookmarkBridge);
        mLocationBar.setAutocompleteProfile(profile);
        mCurrentProfile = profile;
    }
    updateButtonStatus();
}
Also used : Tab(org.chromium.chrome.browser.tab.Tab) BookmarkBridge(org.chromium.chrome.browser.bookmarks.BookmarkBridge) Profile(org.chromium.chrome.browser.profiles.Profile)

Example 84 with Tab

use of org.chromium.chrome.browser.tab.Tab in project AndroidChromium by JackyAndroid.

the class ToolbarManager method updateReloadState.

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);
}
Also used : Tab(org.chromium.chrome.browser.tab.Tab)

Example 85 with Tab

use of org.chromium.chrome.browser.tab.Tab in project AndroidChromium by JackyAndroid.

the class ToolbarManager method forward.

@Override
public boolean forward() {
    Tab tab = mToolbarModel.getTab();
    if (tab != null && tab.canGoForward()) {
        tab.goForward();
        updateButtonStatus();
        return true;
    }
    return false;
}
Also used : Tab(org.chromium.chrome.browser.tab.Tab)

Aggregations

Tab (org.chromium.chrome.browser.tab.Tab)116 LayoutTab (org.chromium.chrome.browser.compositor.layouts.components.LayoutTab)13 TabModel (org.chromium.chrome.browser.tabmodel.TabModel)10 LoadUrlParams (org.chromium.content_public.browser.LoadUrlParams)9 SuppressLint (android.annotation.SuppressLint)8 TabModelSelectorTabObserver (org.chromium.chrome.browser.tabmodel.TabModelSelectorTabObserver)8 Intent (android.content.Intent)5 FrameLayout (android.widget.FrameLayout)4 ContentViewCore (org.chromium.content.browser.ContentViewCore)4 WebContents (org.chromium.content_public.browser.WebContents)4 Activity (android.app.Activity)3 Bitmap (android.graphics.Bitmap)3 TabLaunchType (org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType)3 PendingIntent (android.app.PendingIntent)2 Context (android.content.Context)2 Bundle (android.os.Bundle)2 StrictMode (android.os.StrictMode)2 CustomTabsIntent (android.support.customtabs.CustomTabsIntent)2 MenuItem (android.view.MenuItem)2 View (android.view.View)2