Search in sources :

Example 1 with NativePage

use of org.chromium.chrome.browser.NativePage in project AndroidChromium by JackyAndroid.

the class Tab method showNativePage.

/**
     * Shows the given {@code nativePage} if it's not already showing.
     * @param nativePage The {@link NativePage} to show.
     */
private void showNativePage(NativePage nativePage) {
    if (mNativePage == nativePage)
        return;
    NativePage previousNativePage = mNativePage;
    mNativePage = nativePage;
    pushNativePageStateToNavigationEntry();
    // Notifying of theme color change before content change because some of
    // the observers depend on the theme information being correct in
    // onContentChanged().
    updateThemeColorIfNeeded(false);
    notifyContentChanged();
    destroyNativePageInternal(previousNativePage);
}
Also used : NativePage(org.chromium.chrome.browser.NativePage) FrozenNativePage(org.chromium.chrome.browser.FrozenNativePage)

Example 2 with NativePage

use of org.chromium.chrome.browser.NativePage in project AndroidChromium by JackyAndroid.

the class Tab method showRenderedPage.

/**
     * Hides the current {@link NativePage}, if any, and shows the {@link ContentViewCore}'s view.
     */
protected void showRenderedPage() {
    updateTitle();
    if (mNativePage == null)
        return;
    NativePage previousNativePage = mNativePage;
    mNativePage = null;
    notifyContentChanged();
    destroyNativePageInternal(previousNativePage);
}
Also used : NativePage(org.chromium.chrome.browser.NativePage) FrozenNativePage(org.chromium.chrome.browser.FrozenNativePage)

Example 3 with NativePage

use of org.chromium.chrome.browser.NativePage in project AndroidChromium by JackyAndroid.

the class Tab method swapContentViewCore.

/**
     * Called to swap out the current view with the one passed in.
     *
     * @param newContentViewCore The content view that should be swapped into the tab.
     * @param deleteOldNativeWebContents Whether to delete the native web
     *         contents of old view.
     * @param didStartLoad Whether
     *         WebContentsObserver::DidStartProvisionalLoadForFrame() has
     *         already been called.
     * @param didFinishLoad Whether WebContentsObserver::DidFinishLoad() has
     *         already been called.
     */
public void swapContentViewCore(ContentViewCore newContentViewCore, boolean deleteOldNativeWebContents, boolean didStartLoad, boolean didFinishLoad) {
    int originalWidth = 0;
    int originalHeight = 0;
    if (mContentViewCore != null) {
        originalWidth = mContentViewCore.getViewportWidthPix();
        originalHeight = mContentViewCore.getViewportHeightPix();
        mContentViewCore.onHide();
    }
    Rect bounds = new Rect();
    if (originalWidth == 0 && originalHeight == 0) {
        bounds = ExternalPrerenderHandler.estimateContentSize((Application) getApplicationContext(), false);
        originalWidth = bounds.right - bounds.left;
        originalHeight = bounds.bottom - bounds.top;
    }
    destroyContentViewCore(deleteOldNativeWebContents);
    NativePage previousNativePage = mNativePage;
    mNativePage = null;
    // Size of the new ContentViewCore is zero at this point. If we don't call onSizeChanged(),
    // next onShow() call would send a resize message with the current ContentViewCore size
    // (zero) to the renderer process, although the new size will be set soon.
    // However, this size fluttering may confuse Blink and rendered result can be broken
    // (see http://crbug.com/340987).
    newContentViewCore.onSizeChanged(originalWidth, originalHeight, 0, 0);
    if (!bounds.isEmpty()) {
        newContentViewCore.onPhysicalBackingSizeChanged(bounds.right, bounds.bottom);
    }
    newContentViewCore.onShow();
    setContentViewCore(newContentViewCore);
    mContentViewCore.attachImeAdapter();
    // See crbug.com/537671
    if (!mContentViewCore.getWebContents().getLastCommittedUrl().equals("")) {
        ChildProcessLauncher.determinedVisibility(mContentViewCore.getCurrentRenderProcessId());
    }
    destroyNativePageInternal(previousNativePage);
    for (TabObserver observer : mObservers) {
        observer.onWebContentsSwapped(this, didStartLoad, didFinishLoad);
    }
}
Also used : NativePage(org.chromium.chrome.browser.NativePage) FrozenNativePage(org.chromium.chrome.browser.FrozenNativePage) Rect(android.graphics.Rect) ChromeApplication(org.chromium.chrome.browser.ChromeApplication) Application(android.app.Application) SuppressLint(android.annotation.SuppressLint)

Example 4 with NativePage

use of org.chromium.chrome.browser.NativePage in project AndroidChromium by JackyAndroid.

the class Tab method destroy.

/**
     * Cleans up all internal state, destroying any {@link NativePage} or {@link ContentViewCore}
     * currently associated with this {@link Tab}.  This also destroys the native counterpart
     * to this class, which means that all subclasses should erase their native pointers after
     * this method is called.  Once this call is made this {@link Tab} should no longer be used.
     */
public void destroy() {
    mIsInitialized = false;
    // Update the title before destroying the tab. http://b/5783092
    updateTitle();
    if (mTabUma != null)
        mTabUma.onDestroy();
    for (TabObserver observer : mObservers) observer.onDestroyed(this);
    mObservers.clear();
    NativePage currentNativePage = mNativePage;
    mNativePage = null;
    destroyNativePageInternal(currentNativePage);
    destroyContentViewCore(true);
    // Native part of BlimpContents is destroyed on the subsequent call to nativeDestroy.
    mBlimpContents = null;
    // expects all infobars to be cleaned up before its own destruction.
    assert mNativeTabAndroid != 0;
    nativeDestroy(mNativeTabAndroid);
    assert mNativeTabAndroid == 0;
    if (mInfoBarContainer != null) {
        mInfoBarContainer.destroy();
        mInfoBarContainer = null;
    }
    mPreviousFullscreenTopControlsOffsetY = Float.NaN;
    mPreviousFullscreenContentOffsetY = Float.NaN;
    mNeedsReload = false;
    // Remove pending handler actions to prevent memory leaks.
    mHandler.removeCallbacksAndMessages(null);
}
Also used : NativePage(org.chromium.chrome.browser.NativePage) FrozenNativePage(org.chromium.chrome.browser.FrozenNativePage)

Example 5 with NativePage

use of org.chromium.chrome.browser.NativePage in project AndroidChromium by JackyAndroid.

the class Tab method setContentViewCore.

/**
     * Completes the {@link ContentViewCore} specific initialization around a native WebContents
     * pointer. {@link #getNativePage()} will still return the {@link NativePage} if there is one.
     * All initialization that needs to reoccur after a web contents swap should be added here.
     * <p />
     * NOTE: If you attempt to pass a native WebContents that does not have the same incognito
     * state as this tab this call will fail.
     *
     * @param cvc The content view core that needs to be set as active view for the tab.
     */
private void setContentViewCore(ContentViewCore cvc) {
    try {
        TraceEvent.begin("ChromeTab.setContentViewCore");
        NativePage previousNativePage = mNativePage;
        mNativePage = null;
        destroyNativePageInternal(previousNativePage);
        if (mContentViewCore != null) {
            mContentViewCore.setObscuredByAnotherView(false);
        }
        mContentViewCore = cvc;
        cvc.getContainerView().setOnHierarchyChangeListener(this);
        cvc.getContainerView().setOnSystemUiVisibilityChangeListener(this);
        // accessibility. http://crbug.com/416663
        if (mContentViewParent != null) {
            assert false;
            mContentViewParent.removeAllViews();
        }
        mContentViewParent = new TabContentViewParent(mThemedApplicationContext, this);
        mContentViewParent.addView(cvc.getContainerView(), 0, new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        mWebContentsDelegate = mDelegateFactory.createWebContentsDelegate(this);
        mWebContentsObserver = new TabWebContentsObserver(mContentViewCore.getWebContents(), this);
        if (mContentViewClient != null) {
            mContentViewCore.setContentViewClient(mContentViewClient);
        }
        mDownloadDelegate = new ChromeDownloadDelegate(mThemedApplicationContext, this);
        assert mNativeTabAndroid != 0;
        nativeInitWebContents(mNativeTabAndroid, mIncognito, mContentViewCore.getWebContents(), mWebContentsDelegate, new TabContextMenuPopulator(mDelegateFactory.createContextMenuPopulator(this), this));
        // valid infobar container, no need to recreate one.
        if (mInfoBarContainer == null) {
            // The InfoBarContainer needs to be created after the ContentView has been natively
            // initialized.
            mInfoBarContainer = new InfoBarContainer(mThemedApplicationContext, getId(), mContentViewParent, this);
        } else {
            mInfoBarContainer.onParentViewChanged(getId(), mContentViewParent);
        }
        mInfoBarContainer.setContentViewCore(mContentViewCore);
        mSwipeRefreshHandler = new SwipeRefreshHandler(mThemedApplicationContext, this);
        updateThemeColorIfNeeded(false);
        notifyContentChanged();
        // For browser tabs, we want to set accessibility focus to the page
        // when it loads. This is not the default behavior for embedded
        // web views.
        mContentViewCore.setShouldSetAccessibilityFocusOnPageLoad(true);
        setInterceptNavigationDelegate(mDelegateFactory.createInterceptNavigationDelegate(this));
        if (mGestureStateListener == null) {
            mGestureStateListener = createGestureStateListener();
        }
        cvc.addGestureStateListener(mGestureStateListener);
    } finally {
        TraceEvent.end("ChromeTab.setContentViewCore");
    }
}
Also used : NativePage(org.chromium.chrome.browser.NativePage) FrozenNativePage(org.chromium.chrome.browser.FrozenNativePage) LayoutParams(android.widget.FrameLayout.LayoutParams) SwipeRefreshHandler(org.chromium.chrome.browser.SwipeRefreshHandler) InfoBarContainer(org.chromium.chrome.browser.infobar.InfoBarContainer) FrameLayout(android.widget.FrameLayout) ChromeDownloadDelegate(org.chromium.chrome.browser.download.ChromeDownloadDelegate)

Aggregations

NativePage (org.chromium.chrome.browser.NativePage)10 FrozenNativePage (org.chromium.chrome.browser.FrozenNativePage)7 SuppressLint (android.annotation.SuppressLint)1 Application (android.app.Application)1 Context (android.content.Context)1 Bitmap (android.graphics.Bitmap)1 Canvas (android.graphics.Canvas)1 Rect (android.graphics.Rect)1 View (android.view.View)1 FrameLayout (android.widget.FrameLayout)1 LayoutParams (android.widget.FrameLayout.LayoutParams)1 VisibleForTesting (org.chromium.base.VisibleForTesting)1 ChromeApplication (org.chromium.chrome.browser.ChromeApplication)1 SwipeRefreshHandler (org.chromium.chrome.browser.SwipeRefreshHandler)1 ChromeDownloadDelegate (org.chromium.chrome.browser.download.ChromeDownloadDelegate)1 InfoBarContainer (org.chromium.chrome.browser.infobar.InfoBarContainer)1 IncognitoNewTabPage (org.chromium.chrome.browser.ntp.IncognitoNewTabPage)1 NewTabPage (org.chromium.chrome.browser.ntp.NewTabPage)1 Tab (org.chromium.chrome.browser.tab.Tab)1