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

The following examples show how to use org.chromium.chrome.browser.tab.Tab#getContentViewCore() . 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: UrlBar.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {
    if (!mFocused) {
        mGestureDetector.onTouchEvent(event);
        return true;
    }

    if (event.getActionMasked() == MotionEvent.ACTION_DOWN) mDownEventHadFocus = mFocused;

    Tab currentTab = mUrlBarDelegate.getCurrentTab();
    if (event.getAction() == MotionEvent.ACTION_DOWN && currentTab != null) {
        // Make sure to hide the current ContentView ActionBar.
        ContentViewCore viewCore = currentTab.getContentViewCore();
        if (viewCore != null) viewCore.destroySelectActionMode();
    }

    return super.onTouchEvent(event);
}
 
Example 2
Source File: LayoutManagerDocument.java    From delion with Apache License 2.0 6 votes vote down vote up
@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();
    boolean canUseLiveTexture =
            tab.getContentViewCore() != null && !tab.isShowingSadTab() && !isNativePage;
    layoutTab.initFromHost(tab.getBackgroundColor(), tab.shouldStall(), canUseLiveTexture,
            themeColor, ColorUtils.getTextBoxColorForToolbarBackground(
                                mContext.getResources(), tab, themeColor),
            ColorUtils.getTextBoxAlphaForToolbarBackground(tab));

    mHost.requestRender();
}
 
Example 3
Source File: ContextualSearchTabHelper.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public void onPageLoadStarted(Tab tab, String url) {
    if (tab.getContentViewCore() == null) {
        // Nothing to do yet.
        return;
    }

    mBaseContentViewCore = tab.getContentViewCore();
    // Add Contextual Search here in case it couldn't get added in onContentChanged() due to
    // being too early in initialization of Chrome (ContextualSearchManager being null).
    updateContextualSearchHooks(mBaseContentViewCore);

    ContextualSearchManager manager = getContextualSearchManager();
    if (manager != null) {
        manager.onBasePageLoadStarted();
    }
}
 
Example 4
Source File: ContextualSearchTabHelper.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public void onPageLoadStarted(Tab tab, String url) {
    if (tab.getContentViewCore() == null) {
        // Nothing to do yet.
        return;
    }

    mBaseContentViewCore = tab.getContentViewCore();
    // Add Contextual Search here in case it couldn't get added in onContentChanged() due to
    // being too early in initialization of Chrome (ContextualSearchManager being null).
    updateContextualSearchHooks(mBaseContentViewCore);

    ContextualSearchManager manager = getContextualSearchManager();
    if (manager != null) {
        manager.onBasePageLoadStarted();
    }
}
 
Example 5
Source File: UrlBar.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onTouchEvent(MotionEvent event) {
    if (!mFocused) {
        mGestureDetector.onTouchEvent(event);
        return true;
    }

    Tab currentTab = mUrlBarDelegate.getCurrentTab();
    if (event.getAction() == MotionEvent.ACTION_DOWN && currentTab != null) {
        // Make sure to hide the current ContentView ActionBar.
        ContentViewCore viewCore = currentTab.getContentViewCore();
        if (viewCore != null) viewCore.destroySelectActionMode();
    }

    return super.onTouchEvent(event);
}
 
Example 6
Source File: ChromeTabbedActivity.java    From delion with Apache License 2.0 5 votes vote down vote up
private void toggleOverview() {
    Tab currentTab = getActivityTab();
    ContentViewCore contentViewCore =
            currentTab != null ? currentTab.getContentViewCore() : null;

    if (!mLayoutManager.overviewVisible()) {
        getCompositorViewHolder().hideKeyboard(new Runnable() {
            @Override
            public void run() {
                mLayoutManager.showOverview(true);
            }
        });
        if (contentViewCore != null) {
            contentViewCore.setAccessibilityState(false);
        }
    } else {
        Layout activeLayout = mLayoutManager.getActiveLayout();
        if (activeLayout instanceof StackLayout) {
            ((StackLayout) activeLayout).commitOutstandingModelState(LayoutManager.time());
        }
        if (getCurrentTabModel().getCount() != 0) {
            // Don't hide overview if current tab stack is empty()
            mLayoutManager.hideOverview(true);

            // hideOverview could change the current tab.  Update the local variables.
            currentTab = getActivityTab();
            contentViewCore = currentTab != null ? currentTab.getContentViewCore() : null;

            if (contentViewCore != null) {
                contentViewCore.setAccessibilityState(true);
            }
        }
    }
}
 
Example 7
Source File: LayerTitleCache.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public String getUpdatedTitle(Tab tab, String defaultTitle) {
    // If content view core is null, tab does not have direct access to the favicon, and we
    // will initially show default favicon. But favicons are stored in the history database, so
    // we will fetch favicons asynchronously from database.
    boolean fetchFaviconFromHistory = tab.getContentViewCore() == null;

    String titleString = getTitleForTab(tab, defaultTitle);
    getUpdatedTitleInternal(tab, titleString, fetchFaviconFromHistory);
    if (fetchFaviconFromHistory) fetchFaviconForTab(tab);
    return titleString;
}
 
Example 8
Source File: ChromeTabbedActivity.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private void toggleOverview() {
    Tab currentTab = getActivityTab();
    ContentViewCore contentViewCore =
            currentTab != null ? currentTab.getContentViewCore() : null;

    if (!mLayoutManager.overviewVisible()) {
        getCompositorViewHolder().hideKeyboard(new Runnable() {
            @Override
            public void run() {
                mLayoutManager.showOverview(true);
            }
        });
        if (contentViewCore != null) {
            contentViewCore.setAccessibilityState(false);
        }
    } else {
        Layout activeLayout = mLayoutManager.getActiveLayout();
        if (activeLayout instanceof StackLayout) {
            ((StackLayout) activeLayout).commitOutstandingModelState(LayoutManager.time());
        }
        if (getCurrentTabModel().getCount() != 0) {
            // Don't hide overview if current tab stack is empty()
            mLayoutManager.hideOverview(true);

            // hideOverview could change the current tab.  Update the local variables.
            currentTab = getActivityTab();
            contentViewCore = currentTab != null ? currentTab.getContentViewCore() : null;

            if (contentViewCore != null) {
                contentViewCore.setAccessibilityState(true);
            }
        }
    }
}
 
Example 9
Source File: ContextualSearchSelectionController.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * @return The Base Page's {@link WebContents}, or {@code null} if there is no current tab or
 *         the current tab has no {@link ContentViewCore}.
 */
WebContents getBaseWebContents() {
    Tab currentTab = mActivity.getActivityTab();
    if (currentTab == null) return null;

    ContentViewCore contentViewCore = currentTab.getContentViewCore();
    if (contentViewCore == null) return null;

    return contentViewCore.getWebContents();
}
 
Example 10
Source File: TabModelUtils.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * @param model The {@link TabModel} to act on.
 * @return      The currently active {@link ContentViewCore}, or {@code null} if no {@link Tab}
 *              is selected or the selected {@link Tab} has no current {@link ContentViewCore}.
 */
public static ContentViewCore getCurrentContentViewCore(TabList model) {
    Tab tab = getCurrentTab(model);
    if (tab == null) return null;

    return tab.getContentViewCore();
}
 
Example 11
Source File: TabModelUtils.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * @param model The {@link TabModel} to act on.
 * @return      The currently active {@link ContentViewCore}, or {@code null} if no {@link Tab}
 *              is selected or the selected {@link Tab} has no current {@link ContentViewCore}.
 */
public static ContentViewCore getCurrentContentViewCore(TabList model) {
    Tab tab = getCurrentTab(model);
    if (tab == null) return null;

    return tab.getContentViewCore();
}
 
Example 12
Source File: ChromeActivity.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
private ContentViewCore getContentViewCore() {
    Tab tab = getActivityTab();
    if (tab == null) return null;
    return tab.getContentViewCore();
}
 
Example 13
Source File: OverlayPanelContent.java    From 365browser with Apache License 2.0 4 votes vote down vote up
public InterceptNavigationDelegateImpl() {
    Tab tab = mActivity.getActivityTab();
    mExternalNavHandler = (tab != null && tab.getContentViewCore() != null)
            ? new ExternalNavigationHandler(tab) : null;
}
 
Example 14
Source File: ContextualSearchSelectionController.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * Gets the base page ContentViewCore.
 * Deprecated, use getBaseWebContents instead.
 * @return The Base Page's {@link ContentViewCore}, or {@code null} if there is no current tab.
 */
@Deprecated
ContentViewCore getBaseContentView() {
    Tab currentTab = mActivity.getActivityTab();
    return currentTab != null ? currentTab.getContentViewCore() : null;
}
 
Example 15
Source File: ChromeActivity.java    From delion with Apache License 2.0 4 votes vote down vote up
private ContentViewCore getContentViewCore() {
    Tab tab = getActivityTab();
    if (tab == null) return null;
    return tab.getContentViewCore();
}
 
Example 16
Source File: ContextualSearchTabHelper.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/**
 * Should be called whenever the Tab's ContentViewCore changes. Removes hooks from the
 * existing ContentViewCore, if necessary and then adds hooks for the new ContentViewCore.
 * @param tab
 */
private void updateHooksForNewContentViewCore(Tab tab) {
    removeContextualSearchHooks(mBaseContentViewCore);
    mBaseContentViewCore = tab.getContentViewCore();
    updateContextualSearchHooks(mBaseContentViewCore);
}
 
Example 17
Source File: ContextualSearchSelectionController.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * @return The Base Page's {@link ContentViewCore}, or {@code null} if there is no current tab.
 */
ContentViewCore getBaseContentView() {
    Tab currentTab = mActivity.getActivityTab();
    return currentTab != null ? currentTab.getContentViewCore() : null;
}
 
Example 18
Source File: ContextualSearchTabHelper.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * Should be called whenever the Tab's ContentViewCore changes. Removes hooks from the
 * existing ContentViewCore, if necessary and then adds hooks for the new ContentViewCore.
 * @param tab
 */
private void updateHooksForNewContentViewCore(Tab tab) {
    removeContextualSearchHooks(mBaseContentViewCore);
    mBaseContentViewCore = tab.getContentViewCore();
    updateContextualSearchHooks(mBaseContentViewCore);
}
 
Example 19
Source File: ContextualSearchSelectionController.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * @return The Base Page's {@link ContentViewCore}, or {@code null} if there is no current tab.
 */
ContentViewCore getBaseContentView() {
    Tab currentTab = mActivity.getActivityTab();
    return currentTab != null ? currentTab.getContentViewCore() : null;
}
 
Example 20
Source File: ChromeActivity.java    From 365browser with Apache License 2.0 4 votes vote down vote up
private ContentViewCore getContentViewCore() {
    Tab tab = getActivityTab();
    if (tab == null) return null;
    return tab.getContentViewCore();
}