import org.chromium.base.ContentUriUtils;
import org.chromium.base.ThreadUtils;
-import org.chromium.content.browser.ContentVideoView;
-import org.chromium.content.browser.ContentViewCore;
/**
* Adapts the AwWebContentsDelegate interface to the AwContentsClient interface.
class AwWebContentsDelegateAdapter extends AwWebContentsDelegate {
private static final String TAG = "AwWebContentsDelegateAdapter";
- final AwContentsClient mContentsClient;
- View mContainerView;
- final Context mContext;
+ private final AwContents mAwContents;
+ private final AwContentsClient mContentsClient;
+ private final AwContentViewClient mContentViewClient;
+ private final Context mContext;
+ private View mContainerView;
- public AwWebContentsDelegateAdapter(AwContentsClient contentsClient,
- View containerView, Context context) {
+ public AwWebContentsDelegateAdapter(AwContents awContents, AwContentsClient contentsClient,
+ AwContentViewClient contentViewClient, Context context, View containerView) {
+ mAwContents = awContents;
mContentsClient = contentsClient;
- setContainerView(containerView);
+ mContentViewClient = contentViewClient;
mContext = context;
+ setContainerView(containerView);
}
public void setContainerView(View containerView) {
@Override
public boolean takeFocus(boolean reverse) {
int direction =
- (reverse == (mContainerView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL)) ?
- View.FOCUS_RIGHT : View.FOCUS_LEFT;
+ (reverse == (mContainerView.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL))
+ ? View.FOCUS_RIGHT : View.FOCUS_LEFT;
if (tryToMoveFocus(direction)) return true;
direction = reverse ? View.FOCUS_UP : View.FOCUS_DOWN;
return tryToMoveFocus(direction);
}
@Override
- public void showRepostFormWarningDialog(final ContentViewCore contentViewCore) {
+ public void showRepostFormWarningDialog() {
// TODO(mkosiba) We should be using something akin to the JsResultReceiver as the
// callback parameter (instead of ContentViewCore) and implement a way of converting
// that to a pair of messages.
final Handler handler = new Handler(ThreadUtils.getUiThreadLooper()) {
@Override
public void handleMessage(Message msg) {
+ if (mAwContents.getNavigationController() == null) return;
+
switch(msg.what) {
case msgContinuePendingReload: {
- contentViewCore.getWebContents().getNavigationController()
- .continuePendingReload();
+ mAwContents.getNavigationController().continuePendingReload();
break;
}
case msgCancelPendingReload: {
- contentViewCore.getWebContents().getNavigationController()
- .cancelPendingReload();
+ mAwContents.getNavigationController().cancelPendingReload();
break;
}
default:
@Override
public void toggleFullscreenModeForTab(boolean enterFullscreen) {
- if (!enterFullscreen) {
- ContentVideoView videoView = ContentVideoView.getContentVideoView();
- if (videoView != null) videoView.exitFullscreen(false);
+ if (enterFullscreen) {
+ mContentViewClient.enterFullscreen();
+ } else {
+ mContentViewClient.exitFullscreen();
}
}