org.chromium.content.browser.ContentView Java Examples

The following examples show how to use org.chromium.content.browser.ContentView. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestShellTab.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Navigates this Tab's {@link ContentView} to a sanitized version of {@code url}.
 * @param url The potentially unsanitized URL to navigate to.
 * @param postData Optional data to be sent via POST.
 */
public void loadUrlWithSanitization(String url, byte[] postData) {
    if (url == null) return;

    // Sanitize the URL.
    url = nativeFixupUrl(mNativeTestShellTab, url);

    // Invalid URLs will just return empty.
    if (TextUtils.isEmpty(url)) return;

    ContentView contentView = getContentView();
    if (TextUtils.equals(url, contentView.getUrl())) {
        contentView.getContentViewCore().reload(true);
    } else {
        if (postData == null) {
            contentView.loadUrl(new LoadUrlParams(url));
        } else {
            contentView.loadUrl(LoadUrlParams.createLoadHttpPostParams(url, postData));
        }
    }
}
 
Example #2
Source File: ShellManager.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@SuppressWarnings("unused")
@CalledByNative
private Object createShell() {
    LayoutInflater inflater =
            (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    Shell shellView = (Shell) inflater.inflate(R.layout.shell_view, null);
    shellView.setWindow(mWindow);

    if (mActiveShell != null) closeShell(mActiveShell);

    shellView.setContentViewRenderView(mContentViewRenderView);
    addView(shellView, new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
    mActiveShell = shellView;
    ContentView contentView = mActiveShell.getContentView();
    if (contentView != null) {
        mContentViewRenderView.setCurrentContentView(contentView);
        contentView.onShow();
    }

    return shellView;
}
 
Example #3
Source File: TestShellTab.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Navigates this Tab's {@link ContentView} to a sanitized version of {@code url}.
 * @param url The potentially unsanitized URL to navigate to.
 * @param postData Optional data to be sent via POST.
 */
public void loadUrlWithSanitization(String url, byte[] postData) {
    if (url == null) return;

    // Sanitize the URL.
    url = nativeFixupUrl(mNativeTestShellTab, url);

    // Invalid URLs will just return empty.
    if (TextUtils.isEmpty(url)) return;

    ContentView contentView = getContentView();
    if (TextUtils.equals(url, contentView.getUrl())) {
        contentView.getContentViewCore().reload(true);
    } else {
        if (postData == null) {
            contentView.loadUrl(new LoadUrlParams(url));
        } else {
            contentView.loadUrl(LoadUrlParams.createLoadHttpPostParams(url, postData));
        }
    }
}
 
Example #4
Source File: ShellManager.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@SuppressWarnings("unused")
@CalledByNative
private Object createShell() {
    LayoutInflater inflater =
            (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    Shell shellView = (Shell) inflater.inflate(R.layout.shell_view, null);
    shellView.setWindow(mWindow);

    if (mActiveShell != null) closeShell(mActiveShell);

    shellView.setContentViewRenderView(mContentViewRenderView);
    addView(shellView, new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
    mActiveShell = shellView;
    ContentView contentView = mActiveShell.getContentView();
    if (contentView != null) {
        mContentViewRenderView.setCurrentContentView(contentView);
        contentView.onShow();
    }

    return shellView;
}
 
Example #5
Source File: ContentShellActivity.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
protected void onStart() {
    super.onStart();

    ContentView view = getActiveContentView();
    if (view != null) view.onShow();
}
 
Example #6
Source File: ChromiumTestShellActivity.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
protected void onStart() {
    super.onStart();

    ContentView view = getActiveContentView();
    if (view != null) view.onShow();

    if (mSyncController != null) {
        mSyncController.onStart();
    }
}
 
Example #7
Source File: ChromiumTestShellActivity.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
protected void onStop() {
    super.onStop();

    ContentView view = getActiveContentView();
    if (view != null) view.onHide();
}
 
Example #8
Source File: ShellManager.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@SuppressWarnings("unused")
@CalledByNative
private void closeShell(Shell shellView) {
    if (shellView == mActiveShell) mActiveShell = null;
    ContentView contentView = shellView.getContentView();
    if (contentView != null) contentView.onHide();
    shellView.setContentViewRenderView(null);
    shellView.setWindow(null);
    removeView(shellView);
}
 
Example #9
Source File: Shell.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Initializes the ContentView based on the native tab contents pointer passed in.
 * @param nativeTabContents The pointer to the native tab contents object.
 */
@SuppressWarnings("unused")
@CalledByNative
private void initFromNativeTabContents(int nativeTabContents) {
    mContentView = ContentView.newInstance(getContext(), nativeTabContents, mWindow);
    if (mContentView.getUrl() != null) mUrlTextView.setText(mContentView.getUrl());
    ((FrameLayout) findViewById(R.id.contentview_holder)).addView(mContentView,
            new FrameLayout.LayoutParams(
                    FrameLayout.LayoutParams.MATCH_PARENT,
                    FrameLayout.LayoutParams.MATCH_PARENT));
    mContentView.requestFocus();
    mContentViewRenderView.setCurrentContentView(mContentView);
}
 
Example #10
Source File: ContentShellActivity.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
protected void onStop() {
    super.onStop();

    ContentView view = getActiveContentView();
    if (view != null) view.onHide();
}
 
Example #11
Source File: ContentShellActivity.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
protected void onStart() {
    super.onStart();

    ContentView view = getActiveContentView();
    if (view != null) view.onShow();
}
 
Example #12
Source File: ContentShellActivity.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
protected void onStop() {
    super.onStop();

    ContentView view = getActiveContentView();
    if (view != null) view.onHide();
}
 
Example #13
Source File: ShellManager.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@SuppressWarnings("unused")
@CalledByNative
private void closeShell(Shell shellView) {
    if (shellView == mActiveShell) mActiveShell = null;
    ContentView contentView = shellView.getContentView();
    if (contentView != null) contentView.onHide();
    shellView.setContentViewRenderView(null);
    shellView.setWindow(null);
    removeView(shellView);
}
 
Example #14
Source File: Shell.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Initializes the ContentView based on the native tab contents pointer passed in.
 * @param nativeTabContents The pointer to the native tab contents object.
 */
@SuppressWarnings("unused")
@CalledByNative
private void initFromNativeTabContents(int nativeTabContents) {
    mContentView = ContentView.newInstance(getContext(), nativeTabContents, mWindow);
    if (mContentView.getUrl() != null) mUrlTextView.setText(mContentView.getUrl());
    ((FrameLayout) findViewById(R.id.contentview_holder)).addView(mContentView,
            new FrameLayout.LayoutParams(
                    FrameLayout.LayoutParams.MATCH_PARENT,
                    FrameLayout.LayoutParams.MATCH_PARENT));
    mContentView.requestFocus();
    mContentViewRenderView.setCurrentContentView(mContentView);
}
 
Example #15
Source File: ChromiumTestShellActivity.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
protected void onStart() {
    super.onStart();

    ContentView view = getActiveContentView();
    if (view != null) view.onShow();

    if (mSyncController != null) {
        mSyncController.onStart();
    }
}
 
Example #16
Source File: ChromiumTestShellActivity.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
protected void onStop() {
    super.onStop();

    ContentView view = getActiveContentView();
    if (view != null) view.onHide();
}
 
Example #17
Source File: Tab.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private ContentViewCore createContentViewCore(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(new TabViewAndroidDelegate(this, cv), cv, webContents, getWindowAndroid());
    ChromeActionModeCallback actionModeCallback = new ChromeActionModeCallback(
            mThemedApplicationContext, this, cvc.getActionModeCallbackHelper());
    cvc.setActionModeCallback(actionModeCallback);
    return cvc;
}
 
Example #18
Source File: CompositorViewHolder.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Adjusts the physical backing size of a given ContentViewCore. This method checks
 * the associated container view to see if the size needs to be overriden, such as when used for
 * {@link OverlayPanel}.
 * @param contentViewCore The {@link ContentViewCore} to resize.
 * @param width The default width.
 * @param height The default height.
 */
private void adjustPhysicalBackingSize(ContentViewCore contentViewCore, int width, int height) {
    ContentView contentView = (ContentView) contentViewCore.getContainerView();
    if (contentView == mOverlayContentView) {
        width = MeasureSpec.getSize(mOverlayContentWidthMeasureSpec);
        height = MeasureSpec.getSize(mOverlayContentHeightMeasureSpec);
    }
    mCompositorView.onPhysicalBackingSizeChanged(
            contentViewCore.getWebContents(), width, height);
}
 
Example #19
Source File: Tab.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
    ContentView cv = ContentView.createContentView(mThemedApplicationContext, cvc);
    cv.setContentDescription(mThemedApplicationContext.getResources().getString(
            R.string.accessibility_content_view));
    cvc.initialize(cv, cv, webContents, getWindowAndroid());
    setContentViewCore(cvc);
    if (getTabModelSelector() instanceof SingleTabModelSelector) {
        getContentViewCore().setFullscreenRequiredForOrientationLock(false);
    }
}
 
Example #20
Source File: Tab.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private ContentViewCore createContentViewCore(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());
    ChromeActionModeCallback actionModeCallback = new ChromeActionModeCallback(
            mThemedApplicationContext, this, cvc.getActionModeCallbackHelper());
    cvc.setActionModeCallback(actionModeCallback);
    return cvc;
}
 
Example #21
Source File: Tab.java    From delion with Apache License 2.0 5 votes vote down vote up
/** 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);
    ContentView cv = ContentView.createContentView(mThemedApplicationContext, cvc);
    cv.setContentDescription(mThemedApplicationContext.getResources().getString(
            R.string.accessibility_content_view));
    cvc.initialize(cv, cv, webContents, getWindowAndroid());
    swapContentViewCore(cvc, false, didStartLoad, didFinishLoad);
}
 
Example #22
Source File: Shell.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * @return The {@link ContentView} currently shown by this Shell.
 */
public ContentView getContentView() {
    return mContentView;
}
 
Example #23
Source File: ContentShellActivity.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * @return The {@link ContentView} owned by the currently visible {@link Shell} or null if one
 *         is not showing.
 */
public ContentView getActiveContentView() {
    Shell shell = getActiveShell();
    return shell != null ? shell.getContentView() : null;
}
 
Example #24
Source File: ChromiumTestShellActivity.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * @return The ContentView of the active tab.
 */
public ContentView getActiveContentView() {
    TestShellTab tab = getActiveTab();
    return tab != null ? tab.getContentView() : null;
}
 
Example #25
Source File: Shell.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * @return The {@link ContentView} currently shown by this Shell.
 */
public ContentView getContentView() {
    return mContentView;
}
 
Example #26
Source File: ContentShellActivity.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * @return The {@link ContentView} owned by the currently visible {@link Shell} or null if one
 *         is not showing.
 */
public ContentView getActiveContentView() {
    Shell shell = getActiveShell();
    return shell != null ? shell.getContentView() : null;
}
 
Example #27
Source File: ChromiumTestShellActivity.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * @return The ContentView of the active tab.
 */
public ContentView getActiveContentView() {
    TestShellTab tab = getActiveTab();
    return tab != null ? tab.getContentView() : null;
}
 
Example #28
Source File: TabBase.java    From android-chromium with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * @return The {@link ContentView} associated with the current page, or {@code null} if
 *         there is no current page or the current page is displayed using something besides a
 *         {@link ContentView}.
 */
public ContentView getContentView() {
    return mNativePage == null ? mContentView : null;
}
 
Example #29
Source File: TabBase.java    From android-chromium with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Gives subclasses the chance to clean up some state associated with this {@link ContentView}.
 * This is because {@link #getContentView()} can return {@code null} if a {@link NativePage}
 * is showing.
 * @param contentView The {@link ContentView} that should have associated state cleaned up.
 */
protected void destroyContentViewInternal(ContentView contentView) {
}
 
Example #30
Source File: TabBase.java    From android-chromium with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Gives subclasses the chance to clean up some state associated with this {@link ContentView}.
 * This is because {@link #getContentView()} can return {@code null} if a {@link NativePage}
 * is showing.
 * @param contentView The {@link ContentView} that should have associated state cleaned up.
 */
protected void destroyContentViewInternal(ContentView contentView) {
}