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);
}
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;
}
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();
}
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);
}
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;
}
Aggregations