@Override
  public void onTabOrModelChanged() {
    super.onTabOrModelChanged();
    boolean incognito = isIncognito();
    if (mUseLightColorAssets == null || mUseLightColorAssets != incognito) {
      setBackgroundResource(
          incognito ? R.color.incognito_primary_color : R.color.default_primary_color);

      mMenuButton.setTint(incognito ? mLightModeTint : mDarkModeTint);
      mHomeButton.setTint(incognito ? mLightModeTint : mDarkModeTint);
      mBackButton.setTint(incognito ? mLightModeTint : mDarkModeTint);
      mForwardButton.setTint(incognito ? mLightModeTint : mDarkModeTint);
      if (incognito) {
        mLocationBar
            .getContainerView()
            .getBackground()
            .setAlpha(ToolbarPhone.LOCATION_BAR_TRANSPARENT_BACKGROUND_ALPHA);
      } else {
        mLocationBar.getContainerView().getBackground().setAlpha(255);
      }
      mAccessibilitySwitcherButton.setImageDrawable(
          incognito ? mTabSwitcherButtonDrawableLight : mTabSwitcherButtonDrawable);
      mLocationBar.updateVisualsForState();
      if (mShowMenuBadge) {
        setAppMenuUpdateBadgeDrawable(incognito);
      }
      mUseLightColorAssets = incognito;
    }
    mLocationBar.setUrlBarFocus(false);
  }
  /** Triggered when the selected tab has changed. */
  private void refreshSelectedTab() {
    ChromeTab tab = null;
    if (mPreselectedTabId != Tab.INVALID_TAB_ID) {
      tab = ChromeTab.fromTab(mTabModelSelector.getTabById(mPreselectedTabId));
    }
    if (tab == null) tab = ChromeTab.fromTab(mTabModelSelector.getCurrentTab());

    boolean wasIncognito = mToolbarModel.isIncognito();
    ChromeTab previousTab = ChromeTab.fromTab(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);
        if (tab != null) tab.addObserver(mTabObserver);
      }
      int defaultPrimaryColor =
          isIncognito
              ? mToolbar.getResources().getColor(R.color.incognito_primary_color)
              : mToolbar.getResources().getColor(R.color.default_primary_color);
      int primaryColor =
          (tab != null && tab.getWebContents() != null)
              ? tab.getWebContents().getThemeColor(defaultPrimaryColor)
              : defaultPrimaryColor;
      updatePrimaryColor(primaryColor);

      mToolbar.onTabOrModelChanged();

      if (tab != null
          && tab.getWebContents() != null
          && tab.getWebContents().isLoadingToDifferentDocument()) {
        mToolbar.onNavigatedToDifferentPage();
      }
    }

    Profile profile = mTabModelSelector.getModel(isIncognito).getProfile();
    if (mCurrentProfile != profile) {
      if (mBookmarksBridge != null) mBookmarksBridge.destroy();
      mBookmarksBridge = new BookmarksBridge(profile);
      mBookmarksBridge.addObserver(mBookmarksObserver);
      mLocationBar.setAutocompleteProfile(profile);
      mCurrentProfile = profile;
    }
  }