Java Code Examples for org.chromium.chrome.browser.tab.Tab#getInfoBarContainer()

The following examples show how to use org.chromium.chrome.browser.tab.Tab#getInfoBarContainer() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReaderModeManager.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void onDestroyed(Tab tab) {
    if (tab == null) return;
    if (tab.getInfoBarContainer() != null) {
        tab.getInfoBarContainer().removeObserver(this);
    }
    // If the panel was not shown for the previous navigation, record it now.
    ReaderModeTabInfo info = mTabStatusMap.get(tab.getId());
    if (info != null && !info.isPanelShowRecorded()) {
        recordPanelVisibilityForNavigation(false);
    }
    removeTabState(tab.getId());
}
 
Example 2
Source File: ReaderModeManager.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void onContentChanged(Tab tab) {
    // Only listen to events on the currently active tab.
    if (tab.getId() != mTabId) return;
    closeReaderPanel(StateChangeReason.UNKNOWN, false);

    if (mTabStatusMap.containsKey(mTabId)) {
        // If the panel was closed using the "x" icon, don't show it again for this tab.
        if (mTabStatusMap.get(mTabId).isDismissed()) return;
        removeTabState(mTabId);
    }

    ReaderModeTabInfo tabInfo = new ReaderModeTabInfo();
    tabInfo.setStatus(NOT_POSSIBLE);
    tabInfo.setUrl(tab.getUrl());
    mTabStatusMap.put(tab.getId(), tabInfo);

    if (tab.getWebContents() != null) {
        tabInfo.setWebContentsObserver(createWebContentsObserver(tab.getWebContents()));
        if (DomDistillerUrlUtils.isDistilledPage(tab.getUrl())) {
            tabInfo.setStatus(STARTED);
            mReaderModePageUrl = tab.getUrl();
            closeReaderPanel(StateChangeReason.CONTENT_CHANGED, true);
        }
        // Make sure there is a distillability delegate set on the WebContents.
        setDistillabilityCallback(tab.getId());
    }

    if (tab.getInfoBarContainer() != null) tab.getInfoBarContainer().addObserver(this);
}
 
Example 3
Source File: ReaderModeManager.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Restore any infobars that may have been hidden by Reader Mode.
 */
private void restoreInfobars() {
    if (!mIsInfoBarContainerShown) return;

    Tab curTab = mTabModelSelector.getCurrentTab();
    if (curTab == null) return;

    InfoBarContainer container = curTab.getInfoBarContainer();
    if (container == null) return;

    container.setIsObscuredByOtherView(false);

    // Temporarily hides the reader mode button while the infobars are shown.
    closeReaderPanel(StateChangeReason.INFOBAR_SHOWN, false);
}
 
Example 4
Source File: ReaderModeManager.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void onDestroyed(Tab tab) {
    if (tab == null) return;
    if (tab.getInfoBarContainer() != null) {
        tab.getInfoBarContainer().removeObserver(this);
    }
    // If the panel was not shown for the previous navigation, record it now.
    ReaderModeTabInfo info = mTabStatusMap.get(tab.getId());
    if (info != null && !info.isPanelShowRecorded()) {
        recordPanelVisibilityForNavigation(false);
    }
    removeTabState(tab.getId());
}
 
Example 5
Source File: ReaderModeManager.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void onContentChanged(Tab tab) {
    // Only listen to events on the currently active tab.
    if (tab.getId() != mTabId) return;
    closeReaderPanel(StateChangeReason.UNKNOWN, false);

    if (mTabStatusMap.containsKey(mTabId)) {
        // If the panel was closed using the "x" icon, don't show it again for this tab.
        if (mTabStatusMap.get(mTabId).isDismissed()) return;
        removeTabState(mTabId);
    }

    ReaderModeTabInfo tabInfo = new ReaderModeTabInfo();
    tabInfo.setStatus(NOT_POSSIBLE);
    tabInfo.setUrl(tab.getUrl());
    mTabStatusMap.put(tab.getId(), tabInfo);

    if (tab.getWebContents() != null) {
        tabInfo.setWebContentsObserver(createWebContentsObserver(tab.getWebContents()));
        if (DomDistillerUrlUtils.isDistilledPage(tab.getUrl())) {
            tabInfo.setStatus(STARTED);
            mReaderModePageUrl = tab.getUrl();
            closeReaderPanel(StateChangeReason.CONTENT_CHANGED, true);
        }
        // Make sure there is a distillability delegate set on the WebContents.
        setDistillabilityCallback(tab.getId());
    }

    if (tab.getInfoBarContainer() != null) tab.getInfoBarContainer().addObserver(this);
}
 
Example 6
Source File: ReaderModeManager.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Restore any infobars that may have been hidden by Reader Mode.
 */
private void restoreInfobars() {
    if (!mIsInfoBarContainerShown) return;

    Tab curTab = mTabModelSelector.getCurrentTab();
    if (curTab == null) return;

    InfoBarContainer container = curTab.getInfoBarContainer();
    if (container == null) return;

    container.setIsObscuredByOtherView(false);

    // Temporarily hides the reader mode button while the infobars are shown.
    closeReaderPanel(StateChangeReason.INFOBAR_SHOWN, false);
}
 
Example 7
Source File: ReaderModeManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void onDestroyed(Tab tab) {
    if (tab == null) return;
    if (tab.getInfoBarContainer() != null) {
        tab.getInfoBarContainer().removeObserver(this);
    }
    // If the panel was not shown for the previous navigation, record it now.
    ReaderModeTabInfo info = mTabStatusMap.get(tab.getId());
    if (info != null && !info.isPanelShowRecorded()) {
        recordPanelVisibilityForNavigation(false);
    }
    removeTabState(tab.getId());
}
 
Example 8
Source File: ReaderModeManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void onContentChanged(Tab tab) {
    // Only listen to events on the currently active tab.
    if (tab.getId() != mTabId) return;
    closeReaderPanel(StateChangeReason.UNKNOWN, false);

    if (mTabStatusMap.containsKey(mTabId)) {
        // If the panel was closed using the "x" icon, don't show it again for this tab.
        if (mTabStatusMap.get(mTabId).isDismissed()) return;
        removeTabState(mTabId);
    }

    ReaderModeTabInfo tabInfo = new ReaderModeTabInfo();
    tabInfo.setStatus(NOT_POSSIBLE);
    tabInfo.setUrl(tab.getUrl());
    mTabStatusMap.put(tab.getId(), tabInfo);

    if (tab.getWebContents() != null) {
        tabInfo.setWebContentsObserver(createWebContentsObserver(tab.getWebContents()));
        if (DomDistillerUrlUtils.isDistilledPage(tab.getUrl())) {
            tabInfo.setStatus(STARTED);
            mReaderModePageUrl = tab.getUrl();
            closeReaderPanel(StateChangeReason.CONTENT_CHANGED, true);
        }
        // Make sure there is a distillability delegate set on the WebContents.
        setDistillabilityCallback(tab.getId());
    }

    if (tab.getInfoBarContainer() != null) tab.getInfoBarContainer().addObserver(this);
}
 
Example 9
Source File: ReaderModeManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Restore any infobars that may have been hidden by Reader Mode.
 */
private void restoreInfobars() {
    if (!mIsInfoBarContainerShown) return;

    Tab curTab = mTabModelSelector.getCurrentTab();
    if (curTab == null) return;

    InfoBarContainer container = curTab.getInfoBarContainer();
    if (container == null) return;

    container.setIsObscuredByOtherView(false);

    // Temporarily hides the reader mode button while the infobars are shown.
    closeReaderPanel(StateChangeReason.INFOBAR_SHOWN, false);
}
 
Example 10
Source File: ReaderModeManager.java    From delion with Apache License 2.0 4 votes vote down vote up
@Override
public void onShown(Tab shownTab) {
    int shownTabId = shownTab.getId();
    Tab previousTab = mTabModelSelector.getTabById(mTabId);
    mTabId = shownTabId;

    // If the reader panel was dismissed, stop here.
    if (mTabStatusMap.containsKey(shownTabId)
            && mTabStatusMap.get(shownTabId).isDismissed()) {
        return;
    }

    // Set this manager as the active one for the UI utils.
    DomDistillerUIUtils.setReaderModeManagerDelegate(this);

    // Update infobar state based on current tab.
    if (shownTab.getInfoBarContainer() != null) {
        mIsInfoBarContainerShown = shownTab.getInfoBarContainer().hasInfoBars();
    }

    // Remove the infobar observer from the previous tab and attach it to the current one.
    if (previousTab != null && previousTab.getInfoBarContainer() != null) {
        previousTab.getInfoBarContainer().removeObserver(this);
    }

    if (shownTab.getInfoBarContainer() != null) {
        shownTab.getInfoBarContainer().addObserver(this);
    }

    // If there is no state info for this tab, create it.
    ReaderModeTabInfo tabInfo = mTabStatusMap.get(shownTabId);
    if (tabInfo == null) {
        tabInfo = new ReaderModeTabInfo();
        tabInfo.setStatus(NOT_POSSIBLE);
        tabInfo.setUrl(shownTab.getUrl());
        mTabStatusMap.put(shownTabId, tabInfo);
    }

    // Make sure there is a WebContentsObserver on this tab's WebContents.
    if (tabInfo.getWebContentsObserver() == null) {
        tabInfo.setWebContentsObserver(createWebContentsObserver(shownTab.getWebContents()));
    }

    // Make sure there is a distillability delegate set on the WebContents.
    setDistillabilityCallback(shownTabId);

    requestReaderPanelShow(StateChangeReason.UNKNOWN);
}
 
Example 11
Source File: ContextualSearchManager.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * Accessor for the {@code InfoBarContainer} currently attached to the {@code Tab}.
 */
private InfoBarContainer getInfoBarContainer() {
    Tab tab = mActivity.getActivityTab();
    return tab == null ? null : tab.getInfoBarContainer();
}
 
Example 12
Source File: ReaderModeManager.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@Override
public void onShown(Tab shownTab) {
    int shownTabId = shownTab.getId();
    Tab previousTab = mTabModelSelector.getTabById(mTabId);
    mTabId = shownTabId;

    // If the reader panel was dismissed, stop here.
    if (mTabStatusMap.containsKey(shownTabId)
            && mTabStatusMap.get(shownTabId).isDismissed()) {
        return;
    }

    // Set this manager as the active one for the UI utils.
    DomDistillerUIUtils.setReaderModeManagerDelegate(this);

    // Update infobar state based on current tab.
    if (shownTab.getInfoBarContainer() != null) {
        mIsInfoBarContainerShown = shownTab.getInfoBarContainer().hasInfoBars();
    }

    // Remove the infobar observer from the previous tab and attach it to the current one.
    if (previousTab != null && previousTab.getInfoBarContainer() != null) {
        previousTab.getInfoBarContainer().removeObserver(this);
    }

    if (shownTab.getInfoBarContainer() != null) {
        shownTab.getInfoBarContainer().addObserver(this);
    }

    // If there is no state info for this tab, create it.
    ReaderModeTabInfo tabInfo = mTabStatusMap.get(shownTabId);
    if (tabInfo == null) {
        tabInfo = new ReaderModeTabInfo();
        tabInfo.setStatus(NOT_POSSIBLE);
        tabInfo.setUrl(shownTab.getUrl());
        mTabStatusMap.put(shownTabId, tabInfo);
    }

    // Make sure there is a WebContentsObserver on this tab's WebContents.
    if (tabInfo.getWebContentsObserver() == null) {
        tabInfo.setWebContentsObserver(createWebContentsObserver(shownTab.getWebContents()));
    }

    // Make sure there is a distillability delegate set on the WebContents.
    setDistillabilityCallback(shownTabId);

    requestReaderPanelShow(StateChangeReason.UNKNOWN);
}
 
Example 13
Source File: ContextualSearchManager.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * Accessor for the {@code InfoBarContainer} currently attached to the {@code Tab}.
 */
private InfoBarContainer getInfoBarContainer() {
    Tab tab = mActivity.getActivityTab();
    return tab == null ? null : tab.getInfoBarContainer();
}
 
Example 14
Source File: ReaderModeManager.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
public void onShown(Tab shownTab) {
    if (mTabModelSelector == null) return;

    int shownTabId = shownTab.getId();
    Tab previousTab = mTabModelSelector.getTabById(mTabId);
    mTabId = shownTabId;

    // If the reader panel was dismissed, stop here.
    if (mTabStatusMap.containsKey(shownTabId)
            && mTabStatusMap.get(shownTabId).isDismissed()) {
        return;
    }

    // Set this manager as the active one for the UI utils.
    DomDistillerUIUtils.setReaderModeManagerDelegate(this);

    // Update infobar state based on current tab.
    if (shownTab.getInfoBarContainer() != null) {
        mIsInfoBarContainerShown = shownTab.getInfoBarContainer().hasInfoBars();
    }

    // Remove the infobar observer from the previous tab and attach it to the current one.
    if (previousTab != null && previousTab.getInfoBarContainer() != null) {
        previousTab.getInfoBarContainer().removeObserver(this);
    }

    if (shownTab.getInfoBarContainer() != null) {
        shownTab.getInfoBarContainer().addObserver(this);
    }

    // If there is no state info for this tab, create it.
    ReaderModeTabInfo tabInfo = mTabStatusMap.get(shownTabId);
    if (tabInfo == null) {
        tabInfo = new ReaderModeTabInfo();
        tabInfo.setStatus(NOT_POSSIBLE);
        tabInfo.setUrl(shownTab.getUrl());
        mTabStatusMap.put(shownTabId, tabInfo);
    }

    // Make sure there is a WebContentsObserver on this tab's WebContents.
    if (tabInfo.getWebContentsObserver() == null) {
        tabInfo.setWebContentsObserver(createWebContentsObserver(shownTab.getWebContents()));
    }

    // Make sure there is a distillability delegate set on the WebContents.
    setDistillabilityCallback(shownTabId);

    requestReaderPanelShow(StateChangeReason.UNKNOWN);
}
 
Example 15
Source File: ContextualSearchManager.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/** Accessor for the {@code InfoBarContainer} currently attached to the {@code Tab}. */
private InfoBarContainer getInfoBarContainer() {
    Tab tab = mActivity.getActivityTab();
    return tab == null ? null : tab.getInfoBarContainer();
}