Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / content / shell / android / java / src / org / chromium / content_shell / Shell.java
index 5ac955f..99caca8 100644 (file)
@@ -10,6 +10,7 @@ import android.text.TextUtils;
 import android.util.AttributeSet;
 import android.view.KeyEvent;
 import android.view.View;
+import android.view.ViewGroup;
 import android.view.inputmethod.EditorInfo;
 import android.view.inputmethod.InputMethodManager;
 import android.widget.EditText;
@@ -23,6 +24,7 @@ import org.chromium.base.CalledByNative;
 import org.chromium.base.JNINamespace;
 import org.chromium.content.browser.ContentView;
 import org.chromium.content.browser.ContentViewClient;
+import org.chromium.content.browser.ContentViewCore;
 import org.chromium.content.browser.ContentViewRenderView;
 import org.chromium.content.browser.LoadUrlParams;
 import org.chromium.ui.base.WindowAndroid;
@@ -42,8 +44,8 @@ public class Shell extends LinearLayout {
         }
     };
 
-    // TODO(jrg): a mContentView.destroy() call is needed, both upstream and downstream.
     private ContentView mContentView;
+    private ContentViewCore mContentViewCore;
     private ContentViewClient mContentViewClient;
     private EditText mUrlTextView;
     private ImageButton mPrevButton;
@@ -109,7 +111,7 @@ public class Shell extends LinearLayout {
     private void onNativeDestroyed() {
         mWindow = null;
         mNativeShell = 0;
-        mContentView.destroy();
+        mContentViewCore.destroy();
     }
 
     /**
@@ -159,7 +161,7 @@ public class Shell extends LinearLayout {
                 mNextButton.setVisibility(hasFocus ? GONE : VISIBLE);
                 mPrevButton.setVisibility(hasFocus ? GONE : VISIBLE);
                 if (!hasFocus) {
-                    mUrlTextView.setText(mContentView.getUrl());
+                    mUrlTextView.setText(mContentViewCore.getUrl());
                 }
             }
         });
@@ -174,10 +176,10 @@ public class Shell extends LinearLayout {
     public void loadUrl(String url) {
         if (url == null) return;
 
-        if (TextUtils.equals(url, mContentView.getUrl())) {
-            mContentView.getContentViewCore().reload(true);
+        if (TextUtils.equals(url, mContentViewCore.getUrl())) {
+            mContentViewCore.reload(true);
         } else {
-            mContentView.loadUrl(new LoadUrlParams(sanitizeUrl(url)));
+            mContentViewCore.loadUrl(new LoadUrlParams(sanitizeUrl(url)));
         }
         mUrlTextView.clearFocus();
         // TODO(aurimas): Remove this when crbug.com/174541 is fixed.
@@ -201,7 +203,7 @@ public class Shell extends LinearLayout {
         mPrevButton.setOnClickListener(new OnClickListener() {
             @Override
             public void onClick(View v) {
-                if (mContentView.canGoBack()) mContentView.goBack();
+                if (mContentViewCore.canGoBack()) mContentViewCore.goBack();
             }
         });
 
@@ -209,7 +211,7 @@ public class Shell extends LinearLayout {
         mNextButton.setOnClickListener(new OnClickListener() {
             @Override
             public void onClick(View v) {
-                if (mContentView.canGoForward()) mContentView.goForward();
+                if (mContentViewCore.canGoForward()) mContentViewCore.goForward();
             }
         });
     }
@@ -251,24 +253,33 @@ public class Shell extends LinearLayout {
     @CalledByNative
     private void initFromNativeTabContents(long nativeTabContents) {
         mContentView = ContentView.newInstance(getContext(), nativeTabContents, mWindow);
-        mContentView.setContentViewClient(mContentViewClient);
-        if (getParent() != null) mContentView.onShow();
-        if (mContentView.getUrl() != null) mUrlTextView.setText(mContentView.getUrl());
+        mContentViewCore = mContentView.getContentViewCore();
+        mContentViewCore.setContentViewClient(mContentViewClient);
+
+        if (getParent() != null) mContentViewCore.onShow();
+        if (mContentViewCore.getUrl() != null) mUrlTextView.setText(mContentViewCore.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);
+        mContentViewRenderView.setCurrentContentViewCore(mContentViewCore);
     }
 
     /**
-     * @return The {@link ContentView} currently shown by this Shell.
+     * @return The {@link ViewGroup} currently shown by this Shell.
      */
-    public ContentView getContentView() {
+    public ViewGroup getContentView() {
         return mContentView;
     }
 
+    /**
+     * @return The {@link ContentViewCore} currently managing the view shown by this Shell.
+     */
+    public ContentViewCore getContentViewCore() {
+        return mContentViewCore;
+    }
+
     private void setKeyboardVisibilityForUrl(boolean visible) {
         InputMethodManager imm = (InputMethodManager) getContext().getSystemService(
                 Context.INPUT_METHOD_SERVICE);