Search in sources :

Example 1 with BookmarkBridge

use of org.chromium.chrome.browser.bookmarks.BookmarkBridge 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)

Aggregations

BookmarkBridge (org.chromium.chrome.browser.bookmarks.BookmarkBridge)1 Profile (org.chromium.chrome.browser.profiles.Profile)1 Tab (org.chromium.chrome.browser.tab.Tab)1