use of org.chromium.content.browser.ContentView in project AndroidChromium by JackyAndroid.
the class OverlayPanelContent method createNewContentView.
/**
* Create a new ContentViewCore that will be managed by this panel.
*/
private void createNewContentView() {
if (mContentViewCore != null) {
// then there's no need to create a new one.
if (!mDidStartLoadingUrl)
return;
destroyContentView();
}
mContentViewCore = createContentViewCore(mActivity);
if (mContentViewClient == null) {
mContentViewClient = new ContentViewClient();
}
mContentViewCore.setContentViewClient(mContentViewClient);
ContentView cv = ContentView.createContentView(mActivity, mContentViewCore);
// Creates an initially hidden WebContents which gets shown when the panel is opened.
WebContents panelWebContents = WebContentsFactory.createWebContents(false, true);
// Dummny ViewAndroidDelegate since the container view for overlay panel is
// never added to the view hierarchy.
ViewAndroidDelegate delegate = new ViewAndroidDelegate() {
private ViewGroup mContainerView;
private ViewAndroidDelegate init(ViewGroup containerView) {
mContainerView = containerView;
return this;
}
@Override
public View acquireView() {
assert false : "Shold not reach here";
return null;
}
@Override
public void setViewPosition(View anchorView, float x, float y, float width, float height, float scale, int leftMargin, int topMargin) {
}
@Override
public void removeView(View anchorView) {
}
@Override
public ViewGroup getContainerView() {
return mContainerView;
}
}.init(cv);
mContentViewCore.initialize(delegate, cv, panelWebContents, mActivity.getWindowAndroid());
// Transfers the ownership of the WebContents to the native OverlayPanelContent.
nativeSetWebContents(mNativeOverlayPanelContentPtr, panelWebContents, mWebContentsDelegate);
mWebContentsObserver = new WebContentsObserver(panelWebContents) {
@Override
public void didStartLoading(String url) {
mContentDelegate.onContentLoadStarted(url);
}
@Override
public void navigationEntryCommitted() {
mContentDelegate.onNavigationEntryCommitted();
}
@Override
public void didStartProvisionalLoadForFrame(long frameId, long parentFrameId, boolean isMainFrame, String validatedUrl, boolean isErrorPage, boolean isIframeSrcdoc) {
if (isMainFrame) {
mContentDelegate.onMainFrameLoadStarted(validatedUrl, !TextUtils.equals(validatedUrl, mLoadedUrl));
}
}
@Override
public void didNavigateMainFrame(String url, String baseUrl, boolean isNavigationToDifferentPage, boolean isNavigationInPage, int httpResultCode) {
mIsProcessingPendingNavigation = false;
mContentDelegate.onMainFrameNavigation(url, !TextUtils.equals(url, mLoadedUrl), isHttpFailureCode(httpResultCode));
}
@Override
public void didFinishLoad(long frameId, String validatedUrl, boolean isMainFrame) {
mContentDelegate.onContentLoadFinished();
}
};
mInterceptNavigationDelegate = new InterceptNavigationDelegateImpl();
nativeSetInterceptNavigationDelegate(mNativeOverlayPanelContentPtr, mInterceptNavigationDelegate, panelWebContents);
mContentDelegate.onContentViewCreated(mContentViewCore);
}
use of org.chromium.content.browser.ContentView in project AndroidChromium by JackyAndroid.
the class Tab method swapWebContents.
/** This is currently called when committing a pre-rendered page. */
@VisibleForTesting
@CalledByNative
public void swapWebContents(WebContents webContents, boolean didStartLoad, boolean didFinishLoad) {
ContentViewCore cvc = new ContentViewCore(mThemedApplicationContext, PRODUCT_VERSION);
ContentView cv = ContentView.createContentView(mThemedApplicationContext, cvc);
cv.setContentDescription(mThemedApplicationContext.getResources().getString(R.string.accessibility_content_view));
cvc.initialize(ViewAndroidDelegate.createBasicDelegate(cv), cv, webContents, getWindowAndroid());
swapContentViewCore(cvc, false, didStartLoad, didFinishLoad);
}
use of org.chromium.content.browser.ContentView in project AndroidChromium by JackyAndroid.
the class Tab method initContentViewCore.
/**
* Creates and initializes the {@link ContentViewCore}.
*
* @param webContents The WebContents object that will be used to build the
* {@link ContentViewCore}.
*/
protected void initContentViewCore(WebContents webContents) {
ContentViewCore cvc = new ContentViewCore(mThemedApplicationContext, PRODUCT_VERSION);
ContentView cv = ContentView.createContentView(mThemedApplicationContext, cvc);
cv.setContentDescription(mThemedApplicationContext.getResources().getString(R.string.accessibility_content_view));
cvc.initialize(ViewAndroidDelegate.createBasicDelegate(cv), cv, webContents, getWindowAndroid());
setContentViewCore(cvc);
if (getTabModelSelector() instanceof SingleTabModelSelector) {
getContentViewCore().setFullscreenRequiredForOrientationLock(false);
}
}
use of org.chromium.content.browser.ContentView in project AndroidChromium by JackyAndroid.
the class Tab method showSadTab.
/**
* Constructs and shows a sad tab (Aw, Snap!).
*/
protected void showSadTab() {
if (getContentViewCore() != null) {
OnClickListener suggestionAction = new OnClickListener() {
@Override
public void onClick(View view) {
Activity activity = mWindowAndroid.getActivity().get();
assert activity != null;
HelpAndFeedback.getInstance(activity).show(activity, activity.getString(R.string.help_context_sad_tab), Profile.getLastUsedProfile(), null);
}
};
OnClickListener reloadButtonAction = new OnClickListener() {
@Override
public void onClick(View view) {
reload();
}
};
// Make sure we are not adding the "Aw, snap" view over an existing one.
assert mSadTabView == null;
mSadTabView = SadTabViewFactory.createSadTabView(mThemedApplicationContext, suggestionAction, reloadButtonAction);
// Show the sad tab inside ContentView.
getContentViewCore().getContainerView().addView(mSadTabView, new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
notifyContentChanged();
}
FullscreenManager fullscreenManager = getFullscreenManager();
if (fullscreenManager != null) {
fullscreenManager.setPositionsForTabToNonFullscreen();
}
}
Aggregations