use of org.chromium.chrome.browser.tab.Tab in project AndroidChromium by JackyAndroid.
the class BarOverlapTapSuppression method getContentHeightPx.
/**
* @return The height of the content view area of the base page in pixels, or 0 if the
* Height cannot be reliably obtained.
*/
private float getContentHeightPx() {
Tab currentTab = mActivity.getActivityTab();
ChromeFullscreenManager fullscreenManager = mActivity.getFullscreenManager();
if (fullscreenManager == null || currentTab == null)
return 0.f;
float controlsOffset = fullscreenManager.getControlOffset();
float controlsHeight = fullscreenManager.getTopControlsHeight();
float tabHeight = currentTab.getHeight();
return tabHeight - (controlsHeight + controlsOffset);
}
use of org.chromium.chrome.browser.tab.Tab 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.tab.Tab in project AndroidChromium by JackyAndroid.
the class LayoutManagerChrome method tabCreated.
/**
* Should be called when a tab created event is triggered.
* @param id The id of the tab that was created.
* @param sourceId The id of the creating tab if any.
* @param launchType How the tab was launched.
* @param incognito Whether or not the created tab is incognito.
* @param willBeSelected Whether or not the created tab will be selected.
* @param originX The x coordinate of the action that created this tab in dp.
* @param originY The y coordinate of the action that created this tab in dp.
*/
protected void tabCreated(int id, int sourceId, TabLaunchType launchType, boolean incognito, boolean willBeSelected, float originX, float originY) {
Tab newTab = TabModelUtils.getTabById(getTabModelSelector().getModel(incognito), id);
mCreatingNtp = newTab != null && newTab.isNativePage();
int newIndex = TabModelUtils.getTabIndexById(getTabModelSelector().getModel(incognito), id);
getActiveLayout().onTabCreated(time(), id, newIndex, sourceId, incognito, !willBeSelected, originX, originY);
}
use of org.chromium.chrome.browser.tab.Tab 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.tab.Tab in project AndroidChromium by JackyAndroid.
the class LayoutManagerDocument method init.
@Override
public void init(TabModelSelector selector, TabCreatorManager creator, TabContentManager content, ViewGroup androidContentContainer, ContextualSearchManagementDelegate contextualSearchDelegate, ReaderModeManagerDelegate readerModeDelegate, DynamicResourceLoader dynamicResourceLoader) {
// Add any SceneOverlays to a layout.
addAllSceneOverlays();
// Save state
mContextualSearchDelegate = contextualSearchDelegate;
// Initialize Event Filters
mStaticEdgeEventFilter.setTabModelSelector(selector);
// Initialize Layouts
mStaticLayout.setTabModelSelector(selector, content);
// Initialize Contextual Search Panel
mContextualSearchPanel.setManagementDelegate(contextualSearchDelegate);
// Set back flow communication
if (contextualSearchDelegate != null) {
contextualSearchDelegate.setContextualSearchPanel(mContextualSearchPanel);
}
mReaderModePanel.setManagerDelegate(readerModeDelegate);
if (readerModeDelegate != null) {
readerModeDelegate.setReaderModePanel(mReaderModePanel);
}
// Set the dynamic resource loader for all overlay panels.
mOverlayPanelManager.setDynamicResourceLoader(dynamicResourceLoader);
mOverlayPanelManager.setContainerView(androidContentContainer);
mTabModelSelectorTabObserver = new TabModelSelectorTabObserver(selector) {
@Override
public void onContentChanged(Tab tab) {
initLayoutTabFromHost(tab.getId());
}
@Override
public void onBackgroundColorChanged(Tab tab, int color) {
initLayoutTabFromHost(tab.getId());
}
@Override
public void onDidChangeThemeColor(Tab tab, int color) {
initLayoutTabFromHost(tab.getId());
}
};
super.init(selector, creator, content, androidContentContainer, contextualSearchDelegate, readerModeDelegate, dynamicResourceLoader);
}
Aggregations