From 0bceb303710c5b257344a0e42a653b605696f645 Mon Sep 17 00:00:00 2001
From: "yfriedman@chromium.org"
 <yfriedman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Date: Thu, 10 Apr 2014 20:23:12 +0000
Subject: ContentView->ContentViewCore in Shell/ShellManager.

Basically just ensures you can always directly get a ContentViewCore
in ContentShell code. There's too many callers for one CL to switch everyone
over to that.

More clean-up is needed but it seems like the next strings I pull result
in a fair bit of diff. Seems like a small enough chunk that is a logical
change.

BUG=360664

Review URL: https://codereview.chromium.org/227653006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@263066 0039d316-1c4b-4281-b951-d872f2087c98
---
 .../java/src/org/chromium/content_shell/Shell.java | 31 ++++++++++++++--------
 .../org/chromium/content_shell/ShellManager.java   | 14 +++++-----
 2 files changed, 27 insertions(+), 18 deletions(-)

(limited to 'content/shell/android/java/src')

diff --git a/content/shell/android/java/src/org/chromium/content_shell/Shell.java b/content/shell/android/java/src/org/chromium/content_shell/Shell.java
index ef42b20..d9fd9f0 100644
--- a/content/shell/android/java/src/org/chromium/content_shell/Shell.java
+++ b/content/shell/android/java/src/org/chromium/content_shell/Shell.java
@@ -43,8 +43,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;
@@ -160,7 +160,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());
                 }
             }
         });
@@ -175,10 +175,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.
@@ -202,7 +202,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();
             }
         });
 
@@ -210,7 +210,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();
             }
         });
     }
@@ -252,15 +252,17 @@ 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.setCurrentContentViewCore(mContentView.getContentViewCore());
+        mContentViewRenderView.setCurrentContentViewCore(mContentViewCore);
     }
 
     /**
@@ -270,6 +272,13 @@ public class Shell extends LinearLayout {
         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);
diff --git a/content/shell/android/java/src/org/chromium/content_shell/ShellManager.java b/content/shell/android/java/src/org/chromium/content_shell/ShellManager.java
index 8004de0..1e1b9cc 100644
--- a/content/shell/android/java/src/org/chromium/content_shell/ShellManager.java
+++ b/content/shell/android/java/src/org/chromium/content_shell/ShellManager.java
@@ -17,8 +17,8 @@ import org.chromium.base.JNINamespace;
 import org.chromium.base.ThreadUtils;
 import org.chromium.content.browser.ActivityContentVideoViewClient;
 import org.chromium.content.browser.ContentVideoViewClient;
-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.common.ContentSwitches;
 import org.chromium.ui.base.WindowAndroid;
@@ -151,10 +151,10 @@ public class ShellManager extends FrameLayout {
         addView(shellView, new FrameLayout.LayoutParams(
                 FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
         mActiveShell = shellView;
-        ContentView contentView = mActiveShell.getContentView();
-        if (contentView != null) {
-            mContentViewRenderView.setCurrentContentViewCore(contentView.getContentViewCore());
-            contentView.getContentViewCore().onShow();
+        ContentViewCore contentViewCore = mActiveShell.getContentViewCore();
+        if (contentViewCore != null) {
+            mContentViewRenderView.setCurrentContentViewCore(contentViewCore);
+            contentViewCore.onShow();
         }
     }
 
@@ -162,8 +162,8 @@ public class ShellManager extends FrameLayout {
     private void removeShell(Shell shellView) {
         if (shellView == mActiveShell) mActiveShell = null;
         if (shellView.getParent() == null) return;
-        ContentView contentView = shellView.getContentView();
-        if (contentView != null) contentView.onHide();
+        ContentViewCore contentViewCore = shellView.getContentViewCore();
+        if (contentViewCore != null) contentViewCore.onHide();
         shellView.setContentViewRenderView(null);
         removeView(shellView);
     }
-- 
cgit v1.1