use of org.chromium.content.browser.ContentViewCore in project AndroidChromium by JackyAndroid.
the class FullscreenHtmlApiHandler method enterFullscreen.
/**
* Handles hiding the system UI components to allow the content to take up the full screen.
* @param tab The tab that is entering fullscreen.
*/
public void enterFullscreen(final Tab tab) {
ContentViewCore contentViewCore = tab.getContentViewCore();
if (contentViewCore == null)
return;
final View contentView = contentViewCore.getContainerView();
int systemUiVisibility = contentView.getSystemUiVisibility();
systemUiVisibility |= SYSTEM_UI_FLAG_LOW_PROFILE;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
if ((systemUiVisibility & SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN) == SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN) {
systemUiVisibility |= SYSTEM_UI_FLAG_FULLSCREEN;
systemUiVisibility |= getExtraFullscreenUIFlags();
} else {
systemUiVisibility |= SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
}
} else {
mWindow.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
mWindow.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
}
if (mFullscreenOnLayoutChangeListener != null) {
contentView.removeOnLayoutChangeListener(mFullscreenOnLayoutChangeListener);
}
mFullscreenOnLayoutChangeListener = new OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
// height and always just trigger the next step of the fullscreen initialization.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
// Posting the message to set the fullscreen flag because setting it
// directly in the onLayoutChange would have no effect.
mHandler.sendEmptyMessage(MSG_ID_SET_FULLSCREEN_SYSTEM_UI_FLAGS);
}
if ((bottom - top) <= (oldBottom - oldTop))
return;
if (mDelegate.shouldShowNotificationToast()) {
showNotificationToast();
}
contentView.removeOnLayoutChangeListener(this);
}
};
contentView.addOnLayoutChangeListener(mFullscreenOnLayoutChangeListener);
contentView.setSystemUiVisibility(systemUiVisibility);
mContentViewCoreInFullscreen = contentViewCore;
mTabInFullscreen = tab;
}
use of org.chromium.content.browser.ContentViewCore in project AndroidChromium by JackyAndroid.
the class PaymentRequestFactory method createImpl.
@Override
public PaymentRequest createImpl() {
if (!ChromeFeatureList.isEnabled(ChromeFeatureList.WEB_PAYMENTS)) {
return new InvalidPaymentRequest();
}
if (mWebContents == null)
return new InvalidPaymentRequest();
ContentViewCore contentViewCore = ContentViewCore.fromWebContents(mWebContents);
if (contentViewCore == null)
return new InvalidPaymentRequest();
WindowAndroid window = contentViewCore.getWindowAndroid();
if (window == null)
return new InvalidPaymentRequest();
Activity context = window.getActivity().get();
if (context == null)
return new InvalidPaymentRequest();
if (mIsPaymentRequestRunning)
return new InvalidPaymentRequest();
mIsPaymentRequestRunning = true;
return new PaymentRequestImpl(context, mWebContents, this);
}
use of org.chromium.content.browser.ContentViewCore in project AndroidChromium by JackyAndroid.
the class Tab method initialize.
/**
* Initializes {@link Tab} with {@code webContents}. If {@code webContents} is {@code null} a
* new {@link WebContents} will be created for this {@link Tab}.
* @param webContents A {@link WebContents} object or {@code null} if one should be
* created.
* @param tabContentManager A {@link TabContentManager} instance or {@code null} if the web
* content will be managed/displayed manually.
* @param delegateFactory The {@link TabDelegateFactory} to be used for delegate creation.
* @param initiallyHidden Only used if {@code webContents} is {@code null}. Determines
* whether or not the newly created {@link WebContents} will be hidden
* or not.
* @param unfreeze Whether there should be an attempt to restore state at the end of
* the initialization.
*/
public final void initialize(WebContents webContents, TabContentManager tabContentManager, TabDelegateFactory delegateFactory, boolean initiallyHidden, boolean unfreeze) {
try {
TraceEvent.begin("Tab.initialize");
mDelegateFactory = delegateFactory;
initializeNative();
RevenueStats.getInstance().tabCreated(this);
mTopControlsVisibilityDelegate = mDelegateFactory.createTopControlsVisibilityDelegate(this);
mBlimp = BlimpClientContextFactory.getBlimpClientContextForProfile(Profile.getLastUsedProfile().getOriginalProfile()).isBlimpEnabled() && !mIncognito;
// Attach the TabContentManager if we have one. This will bind this Tab's content layer
// to this manager.
// TODO(dtrainor): Remove this and move to a pull model instead of pushing the layer.
attachTabContentManager(tabContentManager);
// WebContents.
if (getFrozenContentsState() != null || getPendingLoadParams() != null) {
if (unfreeze)
unfreezeContents();
return;
}
if (isBlimpTab() && getBlimpContents() == null) {
Profile profile = Profile.getLastUsedProfile();
if (mIncognito)
profile = profile.getOffTheRecordProfile();
mBlimpContents = nativeInitBlimpContents(mNativeTabAndroid, profile, mWindowAndroid.getNativePointer());
if (mBlimpContents != null) {
getBlimpContents().addObserver(new TabBlimpContentsObserver(this));
} else {
mBlimp = false;
}
}
boolean creatingWebContents = webContents == null;
if (creatingWebContents) {
webContents = WarmupManager.getInstance().takeSpareWebContents(isIncognito(), initiallyHidden);
if (webContents == null) {
webContents = WebContentsFactory.createWebContents(isIncognito(), initiallyHidden);
}
}
ContentViewCore contentViewCore = ContentViewCore.fromWebContents(webContents);
if (contentViewCore == null) {
initContentViewCore(webContents);
} else {
setContentViewCore(contentViewCore);
}
if (!creatingWebContents && webContents.isLoadingToDifferentDocument()) {
didStartPageLoad(webContents.getUrl(), false);
}
getAppBannerManager().setIsEnabledForTab(mDelegateFactory.canShowAppBanners(this));
} finally {
if (mTimestampMillis == INVALID_TIMESTAMP) {
mTimestampMillis = System.currentTimeMillis();
}
TraceEvent.end("Tab.initialize");
}
}
use of org.chromium.content.browser.ContentViewCore 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.ContentViewCore in project AndroidChromium by JackyAndroid.
the class TabWebContentsDelegateAndroid method getContentVideoViewEmbedder.
@Override
public ContentVideoViewEmbedder getContentVideoViewEmbedder() {
return new ActivityContentVideoViewEmbedder(mTab.getActivity()) {
@Override
public void enterFullscreenVideo(View view, boolean isVideoLoaded) {
super.enterFullscreenVideo(view, isVideoLoaded);
FullscreenManager fullscreenManager = mTab.getFullscreenManager();
if (fullscreenManager != null) {
fullscreenManager.setOverlayVideoMode(true);
// Disable double tap for video.
ContentViewCore cvc = mTab.getContentViewCore();
if (cvc != null) {
cvc.updateDoubleTapSupport(false);
}
}
}
@Override
public void exitFullscreenVideo() {
FullscreenManager fullscreenManager = mTab.getFullscreenManager();
if (fullscreenManager != null) {
fullscreenManager.setOverlayVideoMode(false);
// Disable double tap for video.
ContentViewCore cvc = mTab.getContentViewCore();
if (cvc != null) {
cvc.updateDoubleTapSupport(true);
}
}
super.exitFullscreenVideo();
}
};
}
Aggregations