Search in sources :

Example 26 with ContentViewCore

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;
}
Also used : ContentViewCore(org.chromium.content.browser.ContentViewCore) OnLayoutChangeListener(android.view.View.OnLayoutChangeListener) View(android.view.View)

Example 27 with ContentViewCore

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);
}
Also used : ContentViewCore(org.chromium.content.browser.ContentViewCore) Activity(android.app.Activity) WindowAndroid(org.chromium.ui.base.WindowAndroid)

Example 28 with ContentViewCore

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");
    }
}
Also used : ContentViewCore(org.chromium.content.browser.ContentViewCore) Profile(org.chromium.chrome.browser.profiles.Profile)

Example 29 with ContentViewCore

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);
    }
}
Also used : ContentViewCore(org.chromium.content.browser.ContentViewCore) ContentView(org.chromium.content.browser.ContentView) SingleTabModelSelector(org.chromium.chrome.browser.tabmodel.SingleTabModelSelector)

Example 30 with ContentViewCore

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();
        }
    };
}
Also used : FullscreenManager(org.chromium.chrome.browser.fullscreen.FullscreenManager) ContentViewCore(org.chromium.content.browser.ContentViewCore) ActivityContentVideoViewEmbedder(org.chromium.content.browser.ActivityContentVideoViewEmbedder) View(android.view.View)

Aggregations

ContentViewCore (org.chromium.content.browser.ContentViewCore)32 View (android.view.View)5 Tab (org.chromium.chrome.browser.tab.Tab)4 WindowAndroid (org.chromium.ui.base.WindowAndroid)4 ViewGroup (android.view.ViewGroup)3 ContentView (org.chromium.content.browser.ContentView)3 Paint (android.graphics.Paint)2 FrameLayout (android.widget.FrameLayout)2 CalledByNative (org.chromium.base.annotations.CalledByNative)2 LayoutTab (org.chromium.chrome.browser.compositor.layouts.components.LayoutTab)2 StackLayout (org.chromium.chrome.browser.compositor.layouts.phone.StackLayout)2 WebContents (org.chromium.content_public.browser.WebContents)2 SuppressLint (android.annotation.SuppressLint)1 Activity (android.app.Activity)1 Nullable (android.support.annotation.Nullable)1 CoordinatorLayout (android.support.design.widget.CoordinatorLayout)1 MotionEvent (android.view.MotionEvent)1 SurfaceView (android.view.SurfaceView)1 OnLayoutChangeListener (android.view.View.OnLayoutChangeListener)1 LayoutParams (android.view.ViewGroup.LayoutParams)1