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);
}
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);
}
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);
}
}
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);
}
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");
}
}
Aggregations