use of org.chromium.chrome.browser.tabmodel.TabModelSelector in project AndroidChromium by JackyAndroid.
the class ContextualSearchManager method listenForTabModelSelectorNotifications.
/**
* Listens for notifications that should hide the Contextual Search bar.
*/
private void listenForTabModelSelectorNotifications() {
TabModelSelector selector = mActivity.getTabModelSelector();
mTabModelSelectorTabObserver = new TabModelSelectorTabObserver(selector) {
@Override
public void onPageLoadStarted(Tab tab, String url) {
hideContextualSearch(StateChangeReason.UNKNOWN);
mDidBasePageLoadJustStart = true;
}
@Override
public void onCrash(Tab tab, boolean sadTabShown) {
if (sadTabShown) {
// Hide contextual search if the foreground tab crashed
hideContextualSearch(StateChangeReason.UNKNOWN);
}
}
@Override
public void onClosingStateChanged(Tab tab, boolean closing) {
if (closing)
hideContextualSearch(StateChangeReason.UNKNOWN);
}
};
for (TabModel tabModel : selector.getModels()) {
tabModel.addObserver(mTabModelObserver);
}
}
use of org.chromium.chrome.browser.tabmodel.TabModelSelector in project AndroidChromium by JackyAndroid.
the class ContextualSearchManager method openResolvedSearchUrlInNewTab.
@Override
public void openResolvedSearchUrlInNewTab() {
if (mSearchRequest != null && mSearchRequest.getSearchUrlForPromotion() != null) {
TabModelSelector tabModelSelector = mActivity.getTabModelSelector();
tabModelSelector.openNewTab(new LoadUrlParams(mSearchRequest.getSearchUrlForPromotion()), TabLaunchType.FROM_LINK, tabModelSelector.getCurrentTab(), tabModelSelector.isIncognitoSelected());
}
}
use of org.chromium.chrome.browser.tabmodel.TabModelSelector in project AndroidChromium by JackyAndroid.
the class LayoutManagerDocument method initLayoutTabFromHost.
@Override
public void initLayoutTabFromHost(final int tabId) {
if (getTabModelSelector() == null || getActiveLayout() == null)
return;
TabModelSelector selector = getTabModelSelector();
Tab tab = selector.getTabById(tabId);
if (tab == null)
return;
LayoutTab layoutTab = mTabCache.get(tabId);
if (layoutTab == null)
return;
String url = tab.getUrl();
boolean isNativePage = url != null && url.startsWith(UrlConstants.CHROME_NATIVE_SCHEME);
int themeColor = tab.getThemeColor();
// TODO(xingliu): Remove this override themeColor for Blimp tabs. See crbug.com/644774.
if (tab.isBlimpTab() && tab.getBlimpContents() != null) {
themeColor = tab.getBlimpContents().getThemeColor();
}
boolean canUseLiveTexture = tab.isBlimpTab() || tab.getContentViewCore() != null && !tab.isShowingSadTab() && !isNativePage;
boolean needsUpdate = layoutTab.initFromHost(tab.getBackgroundColor(), tab.shouldStall(), canUseLiveTexture, themeColor, ColorUtils.getTextBoxColorForToolbarBackground(mContext.getResources(), tab, themeColor), ColorUtils.getTextBoxAlphaForToolbarBackground(tab));
if (needsUpdate)
requestUpdate();
mHost.requestRender();
}
use of org.chromium.chrome.browser.tabmodel.TabModelSelector in project AndroidChromium by JackyAndroid.
the class LayoutManagerDocumentTabSwitcher method init.
@Override
public void init(TabModelSelector selector, TabCreatorManager creator, TabContentManager content, ViewGroup androidContentContainer, ContextualSearchManagementDelegate contextualSearchDelegate, ReaderModeManagerDelegate readerModeManagerDelegate, DynamicResourceLoader dynamicResourceLoader) {
super.init(selector, creator, content, androidContentContainer, contextualSearchDelegate, readerModeManagerDelegate, dynamicResourceLoader);
mTitleCache = mHost.getTitleCache();
TabModelSelector documentTabSelector = ChromeApplication.getDocumentTabModelSelector();
mOverviewListLayout.setTabModelSelector(documentTabSelector, content);
mOverviewLayout.setTabModelSelector(documentTabSelector, content);
// TODO(changwan): do we really need this?
startShowing(getDefaultLayout(), false);
}
use of org.chromium.chrome.browser.tabmodel.TabModelSelector in project AndroidChromium by JackyAndroid.
the class ChromeDownloadDelegate method closeBlankTab.
/**
* Close a blank tab just opened for the download purpose.
* @return true iff the tab was (already) closed.
*/
private boolean closeBlankTab() {
if (mTab == null) {
// We do not want caller to dismiss infobar.
return true;
}
WebContents contents = mTab.getWebContents();
boolean isInitialNavigation = contents == null || contents.getNavigationController().isInitialNavigation();
if (isInitialNavigation) {
// Tab is created just for download, close it.
Activity activity = mTab.getWindowAndroid().getActivity().get();
if (!(activity instanceof ChromeActivity))
return true;
TabModelSelector selector = ((ChromeActivity) activity).getTabModelSelector();
return selector == null ? true : selector.closeTab(mTab);
}
return false;
}
Aggregations