Search in sources :

Example 11 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 12 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 13 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 14 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)

Example 15 with ContentViewCore

use of org.chromium.content.browser.ContentViewCore in project AndroidChromium by JackyAndroid.

the class TopControlsVisibilityDelegate method isHidingTopControlsEnabled.

/**
     * @return Whether hiding top controls is enabled or not.
     */
public boolean isHidingTopControlsEnabled() {
    WebContents webContents = mTab.getWebContents();
    if (webContents == null || webContents.isDestroyed())
        return false;
    String url = mTab.getUrl();
    boolean enableHidingTopControls = url != null;
    enableHidingTopControls &= !url.startsWith(UrlConstants.CHROME_SCHEME);
    enableHidingTopControls &= !url.startsWith(UrlConstants.CHROME_NATIVE_SCHEME);
    int securityState = mTab.getSecurityLevel();
    enableHidingTopControls &= (securityState != ConnectionSecurityLevel.DANGEROUS && securityState != ConnectionSecurityLevel.SECURITY_WARNING);
    enableHidingTopControls &= !AccessibilityUtil.isAccessibilityEnabled(mTab.getApplicationContext());
    ContentViewCore cvc = mTab.getContentViewCore();
    enableHidingTopControls &= cvc == null || !cvc.isFocusedNodeEditable();
    enableHidingTopControls &= !mTab.isShowingErrorPage();
    enableHidingTopControls &= !webContents.isShowingInterstitialPage();
    enableHidingTopControls &= (mTab.getFullscreenManager() != null);
    enableHidingTopControls &= DeviceClassManager.enableFullscreen();
    enableHidingTopControls &= !mTab.isFullscreenWaitingForLoad();
    return enableHidingTopControls;
}
Also used : WebContents(org.chromium.content_public.browser.WebContents) ContentViewCore(org.chromium.content.browser.ContentViewCore)

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