Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / android_webview / java / src / org / chromium / android_webview / AwWebContentsDelegateAdapter.java
index e0a7a94..3f2c707 100644 (file)
@@ -19,8 +19,6 @@ import android.webkit.ValueCallback;
 
 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.
@@ -30,15 +28,19 @@ import org.chromium.content.browser.ContentViewCore;
 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) {
@@ -79,8 +81,8 @@ class AwWebContentsDelegateAdapter extends AwWebContentsDelegate {
     @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);
@@ -135,7 +137,7 @@ class AwWebContentsDelegateAdapter extends AwWebContentsDelegate {
     }
 
     @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.
@@ -147,15 +149,15 @@ class AwWebContentsDelegateAdapter extends AwWebContentsDelegate {
         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:
@@ -212,9 +214,10 @@ class AwWebContentsDelegateAdapter extends AwWebContentsDelegate {
 
     @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();
         }
     }