org.chromium.content.browser.ContentViewClient Java Examples

The following examples show how to use org.chromium.content.browser.ContentViewClient. 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: CompositorViewHolder.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Adjusts the physical backing size of a given ContentViewCore. This method will first check
 * if the ContentViewCore's client wants to override the size and, if so, it will use the
 * values provided by the {@link ContentViewClient#getDesiredWidthMeasureSpec()} and
 * {@link ContentViewClient#getDesiredHeightMeasureSpec()} methods. If no value is provided
 * in one of these methods, the values from the |width| and |height| arguments will be
 * used instead.
 *
 * @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) {
    ContentViewClient client = contentViewCore.getContentViewClient();

    int desiredWidthMeasureSpec = client.getDesiredWidthMeasureSpec();
    if (MeasureSpec.getMode(desiredWidthMeasureSpec) != MeasureSpec.UNSPECIFIED) {
        width = MeasureSpec.getSize(desiredWidthMeasureSpec);
    }

    int desiredHeightMeasureSpec = client.getDesiredHeightMeasureSpec();
    if (MeasureSpec.getMode(desiredHeightMeasureSpec) != MeasureSpec.UNSPECIFIED) {
        height = MeasureSpec.getSize(desiredHeightMeasureSpec);
    }

    contentViewCore.onPhysicalBackingSizeChanged(width, height);
}
 
Example #2
Source File: AwContents.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private static ContentViewCore createAndInitializeContentViewCore(ViewGroup containerView,
        InternalAccessDelegate internalDispatcher, int nativeWebContents,
        ContentViewCore.GestureStateListener pinchGestureStateListener,
        ContentViewClient contentViewClient,
        ContentViewCore.ZoomControlsDelegate zoomControlsDelegate) {
  Context context = containerView.getContext();
  ContentViewCore contentViewCore = new ContentViewCore(context);
  // Note INPUT_EVENTS_DELIVERED_IMMEDIATELY is passed to avoid triggering vsync in the
  // compositor, not because input events are delivered immediately.
  contentViewCore.initialize(containerView, internalDispatcher, nativeWebContents,
          context instanceof Activity ?
                  new ActivityWindowAndroid((Activity) context) : new WindowAndroid(context),
            ContentViewCore.INPUT_EVENTS_DELIVERED_IMMEDIATELY);
  contentViewCore.setGestureStateListener(pinchGestureStateListener);
  contentViewCore.setContentViewClient(contentViewClient);
  contentViewCore.setZoomControlsDelegate(zoomControlsDelegate);
  return contentViewCore;
}
 
Example #3
Source File: Tab.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * @param client The {@link ContentViewClient} to be bound to any current or new
 *               {@link ContentViewCore}s associated with this {@link Tab}.
 */
private void setContentViewClient(ContentViewClient client) {
    if (mContentViewClient == client) return;

    ContentViewClient oldClient = mContentViewClient;
    mContentViewClient = client;

    if (mContentViewCore == null) return;

    if (mContentViewClient != null) {
        mContentViewCore.setContentViewClient(mContentViewClient);
    } else if (oldClient != null) {
        // We can't set a null client, but we should clear references to the last one.
        mContentViewCore.setContentViewClient(new ContentViewClient());
    }
}
 
Example #4
Source File: CompositorViewHolder.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Adjusts the physical backing size of a given ContentViewCore. This method will first check
 * if the ContentViewCore's client wants to override the size and, if so, it will use the
 * values provided by the {@link ContentViewClient#getDesiredWidthMeasureSpec()} and
 * {@link ContentViewClient#getDesiredHeightMeasureSpec()} methods. If no value is provided
 * in one of these methods, the values from the |width| and |height| arguments will be
 * used instead.
 *
 * @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) {
    ContentViewClient client = contentViewCore.getContentViewClient();

    int desiredWidthMeasureSpec = client.getDesiredWidthMeasureSpec();
    if (MeasureSpec.getMode(desiredWidthMeasureSpec) != MeasureSpec.UNSPECIFIED) {
        width = MeasureSpec.getSize(desiredWidthMeasureSpec);
    }

    int desiredHeightMeasureSpec = client.getDesiredHeightMeasureSpec();
    if (MeasureSpec.getMode(desiredHeightMeasureSpec) != MeasureSpec.UNSPECIFIED) {
        height = MeasureSpec.getSize(desiredHeightMeasureSpec);
    }

    contentViewCore.onPhysicalBackingSizeChanged(width, height);
}
 
Example #5
Source File: TabBase.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * @param client The {@link ContentViewClient} to be bound to any current or new
 *               {@link ContentViewCore}s associated with this {@link TabBase}.
 */
protected void setContentViewClient(ContentViewClient client) {
    if (mContentViewClient == client) return;

    ContentViewClient oldClient = mContentViewClient;
    mContentViewClient = client;

    if (mContentViewCore == null) return;

    if (mContentViewClient != null) {
        mContentViewCore.setContentViewClient(mContentViewClient);
    } else if (oldClient != null) {
        // We can't set a null client, but we should clear references to the last one.
        mContentViewCore.setContentViewClient(new ContentViewClient());
    }
}
 
Example #6
Source File: Tab.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * @param client The {@link ContentViewClient} to be bound to any current or new
 *               {@link ContentViewCore}s associated with this {@link Tab}.
 */
private void setContentViewClient(ContentViewClient client) {
    if (mContentViewClient == client) return;

    ContentViewClient oldClient = mContentViewClient;
    mContentViewClient = client;

    if (mContentViewCore == null) return;

    if (mContentViewClient != null) {
        mContentViewCore.setContentViewClient(mContentViewClient);
    } else if (oldClient != null) {
        // We can't set a null client, but we should clear references to the last one.
        mContentViewCore.setContentViewClient(new ContentViewClient());
    }
}
 
Example #7
Source File: AwContents.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private static ContentViewCore createAndInitializeContentViewCore(ViewGroup containerView,
        InternalAccessDelegate internalDispatcher, int nativeWebContents,
        ContentViewCore.GestureStateListener pinchGestureStateListener,
        ContentViewClient contentViewClient,
        ContentViewCore.ZoomControlsDelegate zoomControlsDelegate) {
  Context context = containerView.getContext();
  ContentViewCore contentViewCore = new ContentViewCore(context);
  // Note INPUT_EVENTS_DELIVERED_IMMEDIATELY is passed to avoid triggering vsync in the
  // compositor, not because input events are delivered immediately.
  contentViewCore.initialize(containerView, internalDispatcher, nativeWebContents,
          context instanceof Activity ?
                  new ActivityWindowAndroid((Activity) context) : new WindowAndroid(context),
            ContentViewCore.INPUT_EVENTS_DELIVERED_IMMEDIATELY);
  contentViewCore.setGestureStateListener(pinchGestureStateListener);
  contentViewCore.setContentViewClient(contentViewClient);
  contentViewCore.setZoomControlsDelegate(zoomControlsDelegate);
  return contentViewCore;
}
 
Example #8
Source File: TabBase.java    From android-chromium with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * @param client The {@link ContentViewClient} to be bound to any current or new
 *               {@link ContentViewCore}s associated with this {@link TabBase}.
 */
protected void setContentViewClient(ContentViewClient client) {
    if (mContentViewClient == client) return;

    ContentViewClient oldClient = mContentViewClient;
    mContentViewClient = client;

    if (mContentViewCore == null) return;

    if (mContentViewClient != null) {
        mContentViewCore.setContentViewClient(mContentViewClient);
    } else if (oldClient != null) {
        // We can't set a null client, but we should clear references to the last one.
        mContentViewCore.setContentViewClient(new ContentViewClient());
    }
}
 
Example #9
Source File: ContentShellActivity.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void finishInitialization(Bundle savedInstanceState) {
    String shellUrl = ShellManager.DEFAULT_SHELL_URL;
    if (savedInstanceState != null
            && savedInstanceState.containsKey(ACTIVE_SHELL_URL_KEY)) {
        shellUrl = savedInstanceState.getString(ACTIVE_SHELL_URL_KEY);
    }
    mShellManager.launchShell(shellUrl);
    getActiveContentView().setContentViewClient(new ContentViewClient() {
        @Override
        public ContentVideoViewClient getContentVideoViewClient() {
            return new ActivityContentVideoViewClient(ContentShellActivity.this);
        }
    });
}
 
Example #10
Source File: ChromiumTestShellActivity.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Creates a {@link TestShellTab} with a URL specified by {@code url}.
 *
 * @param url The URL the new {@link TestShellTab} should start with.
 */
public void createTab(String url) {
    mTabManager.createTab(url);
    getActiveContentView().setContentViewClient(new ContentViewClient() {
        @Override
        public ContentVideoViewClient getContentVideoViewClient() {
            return new ActivityContentVideoViewClient(ChromiumTestShellActivity.this);
        }
    });
}
 
Example #11
Source File: ContentShellActivity.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void finishInitialization(Bundle savedInstanceState) {
    String shellUrl = ShellManager.DEFAULT_SHELL_URL;
    if (savedInstanceState != null
            && savedInstanceState.containsKey(ACTIVE_SHELL_URL_KEY)) {
        shellUrl = savedInstanceState.getString(ACTIVE_SHELL_URL_KEY);
    }
    mShellManager.launchShell(shellUrl);
    getActiveContentView().setContentViewClient(new ContentViewClient() {
        @Override
        public ContentVideoViewClient getContentVideoViewClient() {
            return new ActivityContentVideoViewClient(ContentShellActivity.this);
        }
    });
}
 
Example #12
Source File: ChromiumTestShellActivity.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Creates a {@link TestShellTab} with a URL specified by {@code url}.
 *
 * @param url The URL the new {@link TestShellTab} should start with.
 */
public void createTab(String url) {
    mTabManager.createTab(url);
    getActiveContentView().setContentViewClient(new ContentViewClient() {
        @Override
        public ContentVideoViewClient getContentVideoViewClient() {
            return new ActivityContentVideoViewClient(ChromiumTestShellActivity.this);
        }
    });
}
 
Example #13
Source File: OverlayPanel.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Add any other objects that depend on the OverlayPanelContent having already been created.
 */
private OverlayPanelContent createNewOverlayPanelContentInternal() {
    OverlayPanelContent content = mContentFactory.createNewOverlayPanelContent();

    content.setContentViewClient(new ContentViewClient() {
        @Override
        public int getDesiredWidthMeasureSpec() {
            if (isFullWidthSizePanel()) {
                return super.getDesiredWidthMeasureSpec();
            } else {
                return MeasureSpec.makeMeasureSpec(
                        getContentViewWidthPx(),
                        MeasureSpec.EXACTLY);
            }
        }

        @Override
        public int getDesiredHeightMeasureSpec() {
            if (isFullWidthSizePanel()) {
                return super.getDesiredHeightMeasureSpec();
            } else {
                return MeasureSpec.makeMeasureSpec(
                        getContentViewHeightPx(),
                        MeasureSpec.EXACTLY);
            }
        }
    });
    return content;
}
 
Example #14
Source File: OverlayPanelContent.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Set a ContentViewClient for this panel to use (will be reused for each new ContentViewCore).
 * @param viewClient The ContentViewClient to use.
 */
public void setContentViewClient(ContentViewClient viewClient) {
    mContentViewClient = viewClient;
    if (mContentViewCore != null) {
        mContentViewCore.setContentViewClient(mContentViewClient);
    }
}
 
Example #15
Source File: OverlayPanelContent.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Set a ContentViewClient for this panel to use (will be reused for each new ContentViewCore).
 * @param viewClient The ContentViewClient to use.
 */
public void setContentViewClient(ContentViewClient viewClient) {
    mContentViewClient = viewClient;
    if (mContentViewCore != null) {
        mContentViewCore.setContentViewClient(mContentViewClient);
    }
}
 
Example #16
Source File: AwContentsClient.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
final ContentViewClient getContentViewClient() {
    return mContentViewClient;
}
 
Example #17
Source File: OverlayPanel.java    From delion with Apache License 2.0 4 votes vote down vote up
/**
 * Add any other objects that depend on the OverlayPanelContent having already been created.
 */
private OverlayPanelContent createNewOverlayPanelContentInternal() {
    OverlayPanelContent content = mContentFactory.createNewOverlayPanelContent();

    content.setContentViewClient(new ContentViewClient() {
        @Override
        public int getDesiredWidthMeasureSpec() {
            if (isFullWidthSizePanel()) {
                return super.getDesiredWidthMeasureSpec();
            } else {
                return MeasureSpec.makeMeasureSpec(
                        getContentViewWidthPx(),
                        MeasureSpec.EXACTLY);
            }
        }

        @Override
        public int getDesiredHeightMeasureSpec() {
            if (isFullWidthSizePanel()) {
                return super.getDesiredHeightMeasureSpec();
            } else {
                return MeasureSpec.makeMeasureSpec(
                        getContentViewHeightPx(),
                        MeasureSpec.EXACTLY);
            }
        }

        @Override
        public ContentVideoViewEmbedder getContentVideoViewEmbedder() {
            // TODO(mdjones): Possibly enable fullscreen video in overlay panels rather than
            // passing an empty implementation.
            return new ContentVideoViewEmbedder() {
                @Override
                public void enterFullscreenVideo(View view) {}

                @Override
                public void exitFullscreenVideo() {}

                @Override
                public View getVideoLoadingProgressView() {
                    return null;
                }

                @Override
                public void setSystemUiVisibility(boolean enterFullscreen) {}
            };
        }
    });

    return content;
}
 
Example #18
Source File: AwContentsClient.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
final ContentViewClient getContentViewClient() {
    return mContentViewClient;
}
 
Example #19
Source File: TabBase.java    From android-chromium with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * @return The {@link ContentViewClient} currently bound to any {@link ContentViewCore}
 *         associated with the current page.  There can still be a {@link ContentViewClient}
 *         even when there is no {@link ContentViewCore}.
 */
protected ContentViewClient getContentViewClient() {
    return mContentViewClient;
}
 
Example #20
Source File: TabBase.java    From android-chromium with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * @return The {@link ContentViewClient} currently bound to any {@link ContentViewCore}
 *         associated with the current page.  There can still be a {@link ContentViewClient}
 *         even when there is no {@link ContentViewCore}.
 */
protected ContentViewClient getContentViewClient() {
    return mContentViewClient;
}