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
parent cb5db8e2
...@@ -26,7 +26,7 @@ public class TabUtils { ...@@ -26,7 +26,7 @@ public class TabUtils {
if (client instanceof TestContentViewClient) return (TestContentViewClient) client; if (client instanceof TestContentViewClient) return (TestContentViewClient) client;
TestContentViewClient testClient = new TestContentViewClientWrapper(client); TestContentViewClient testClient = new TestContentViewClientWrapper(client);
tab.getContentView().setContentViewClient(testClient); tab.getContentViewCore().setContentViewClient(testClient);
return testClient; return testClient;
} }
......
...@@ -120,10 +120,6 @@ public class ContentView extends FrameLayout ...@@ -120,10 +120,6 @@ public class ContentView extends FrameLayout
return mContentViewCore.isAlive(); return mContentViewCore.isAlive();
} }
public void setContentViewClient(ContentViewClient client) {
mContentViewCore.setContentViewClient(client);
}
@VisibleForTesting @VisibleForTesting
public ContentViewClient getContentViewClient() { public ContentViewClient getContentViewClient() {
return mContentViewCore.getContentViewClient(); return mContentViewCore.getContentViewClient();
......
...@@ -43,8 +43,8 @@ public class Shell extends LinearLayout { ...@@ -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 ContentView mContentView;
private ContentViewCore mContentViewCore;
private ContentViewClient mContentViewClient; private ContentViewClient mContentViewClient;
private EditText mUrlTextView; private EditText mUrlTextView;
private ImageButton mPrevButton; private ImageButton mPrevButton;
...@@ -160,7 +160,7 @@ public class Shell extends LinearLayout { ...@@ -160,7 +160,7 @@ public class Shell extends LinearLayout {
mNextButton.setVisibility(hasFocus ? GONE : VISIBLE); mNextButton.setVisibility(hasFocus ? GONE : VISIBLE);
mPrevButton.setVisibility(hasFocus ? GONE : VISIBLE); mPrevButton.setVisibility(hasFocus ? GONE : VISIBLE);
if (!hasFocus) { if (!hasFocus) {
mUrlTextView.setText(mContentView.getUrl()); mUrlTextView.setText(mContentViewCore.getUrl());
} }
} }
}); });
...@@ -175,10 +175,10 @@ public class Shell extends LinearLayout { ...@@ -175,10 +175,10 @@ public class Shell extends LinearLayout {
public void loadUrl(String url) { public void loadUrl(String url) {
if (url == null) return; if (url == null) return;
if (TextUtils.equals(url, mContentView.getUrl())) { if (TextUtils.equals(url, mContentViewCore.getUrl())) {
mContentView.getContentViewCore().reload(true); mContentViewCore.reload(true);
} else { } else {
mContentView.loadUrl(new LoadUrlParams(sanitizeUrl(url))); mContentViewCore.loadUrl(new LoadUrlParams(sanitizeUrl(url)));
} }
mUrlTextView.clearFocus(); mUrlTextView.clearFocus();
// TODO(aurimas): Remove this when crbug.com/174541 is fixed. // TODO(aurimas): Remove this when crbug.com/174541 is fixed.
...@@ -202,7 +202,7 @@ public class Shell extends LinearLayout { ...@@ -202,7 +202,7 @@ public class Shell extends LinearLayout {
mPrevButton.setOnClickListener(new OnClickListener() { mPrevButton.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (mContentView.canGoBack()) mContentView.goBack(); if (mContentViewCore.canGoBack()) mContentViewCore.goBack();
} }
}); });
...@@ -210,7 +210,7 @@ public class Shell extends LinearLayout { ...@@ -210,7 +210,7 @@ public class Shell extends LinearLayout {
mNextButton.setOnClickListener(new OnClickListener() { mNextButton.setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (mContentView.canGoForward()) mContentView.goForward(); if (mContentViewCore.canGoForward()) mContentViewCore.goForward();
} }
}); });
} }
...@@ -252,15 +252,17 @@ public class Shell extends LinearLayout { ...@@ -252,15 +252,17 @@ public class Shell extends LinearLayout {
@CalledByNative @CalledByNative
private void initFromNativeTabContents(long nativeTabContents) { private void initFromNativeTabContents(long nativeTabContents) {
mContentView = ContentView.newInstance(getContext(), nativeTabContents, mWindow); mContentView = ContentView.newInstance(getContext(), nativeTabContents, mWindow);
mContentView.setContentViewClient(mContentViewClient); mContentViewCore = mContentView.getContentViewCore();
if (getParent() != null) mContentView.onShow(); mContentViewCore.setContentViewClient(mContentViewClient);
if (mContentView.getUrl() != null) mUrlTextView.setText(mContentView.getUrl());
if (getParent() != null) mContentViewCore.onShow();
if (mContentViewCore.getUrl() != null) mUrlTextView.setText(mContentViewCore.getUrl());
((FrameLayout) findViewById(R.id.contentview_holder)).addView(mContentView, ((FrameLayout) findViewById(R.id.contentview_holder)).addView(mContentView,
new FrameLayout.LayoutParams( new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT)); FrameLayout.LayoutParams.MATCH_PARENT));
mContentView.requestFocus(); mContentView.requestFocus();
mContentViewRenderView.setCurrentContentViewCore(mContentView.getContentViewCore()); mContentViewRenderView.setCurrentContentViewCore(mContentViewCore);
} }
/** /**
...@@ -270,6 +272,13 @@ public class Shell extends LinearLayout { ...@@ -270,6 +272,13 @@ public class Shell extends LinearLayout {
return mContentView; return mContentView;
} }
/**
* @return The {@link ContentViewCore} currently managing the view shown by this Shell.
*/
public ContentViewCore getContentViewCore() {
return mContentViewCore;
}
private void setKeyboardVisibilityForUrl(boolean visible) { private void setKeyboardVisibilityForUrl(boolean visible) {
InputMethodManager imm = (InputMethodManager) getContext().getSystemService( InputMethodManager imm = (InputMethodManager) getContext().getSystemService(
Context.INPUT_METHOD_SERVICE); Context.INPUT_METHOD_SERVICE);
......
...@@ -17,8 +17,8 @@ import org.chromium.base.JNINamespace; ...@@ -17,8 +17,8 @@ import org.chromium.base.JNINamespace;
import org.chromium.base.ThreadUtils; import org.chromium.base.ThreadUtils;
import org.chromium.content.browser.ActivityContentVideoViewClient; import org.chromium.content.browser.ActivityContentVideoViewClient;
import org.chromium.content.browser.ContentVideoViewClient; import org.chromium.content.browser.ContentVideoViewClient;
import org.chromium.content.browser.ContentView;
import org.chromium.content.browser.ContentViewClient; import org.chromium.content.browser.ContentViewClient;
import org.chromium.content.browser.ContentViewCore;
import org.chromium.content.browser.ContentViewRenderView; import org.chromium.content.browser.ContentViewRenderView;
import org.chromium.content.common.ContentSwitches; import org.chromium.content.common.ContentSwitches;
import org.chromium.ui.base.WindowAndroid; import org.chromium.ui.base.WindowAndroid;
...@@ -151,10 +151,10 @@ public class ShellManager extends FrameLayout { ...@@ -151,10 +151,10 @@ public class ShellManager extends FrameLayout {
addView(shellView, new FrameLayout.LayoutParams( addView(shellView, new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT)); FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
mActiveShell = shellView; mActiveShell = shellView;
ContentView contentView = mActiveShell.getContentView(); ContentViewCore contentViewCore = mActiveShell.getContentViewCore();
if (contentView != null) { if (contentViewCore != null) {
mContentViewRenderView.setCurrentContentViewCore(contentView.getContentViewCore()); mContentViewRenderView.setCurrentContentViewCore(contentViewCore);
contentView.getContentViewCore().onShow(); contentViewCore.onShow();
} }
} }
...@@ -162,8 +162,8 @@ public class ShellManager extends FrameLayout { ...@@ -162,8 +162,8 @@ public class ShellManager extends FrameLayout {
private void removeShell(Shell shellView) { private void removeShell(Shell shellView) {
if (shellView == mActiveShell) mActiveShell = null; if (shellView == mActiveShell) mActiveShell = null;
if (shellView.getParent() == null) return; if (shellView.getParent() == null) return;
ContentView contentView = shellView.getContentView(); ContentViewCore contentViewCore = shellView.getContentViewCore();
if (contentView != null) contentView.onHide(); if (contentViewCore != null) contentViewCore.onHide();
shellView.setContentViewRenderView(null); shellView.setContentViewRenderView(null);
removeView(shellView); removeView(shellView);
} }
......
...@@ -18,8 +18,8 @@ import org.chromium.base.library_loader.LibraryLoader; ...@@ -18,8 +18,8 @@ import org.chromium.base.library_loader.LibraryLoader;
import org.chromium.base.library_loader.Linker; import org.chromium.base.library_loader.Linker;
import org.chromium.base.library_loader.ProcessInitException; import org.chromium.base.library_loader.ProcessInitException;
import org.chromium.content.browser.BrowserStartupController; import org.chromium.content.browser.BrowserStartupController;
import org.chromium.content.browser.ContentView;
import org.chromium.content.browser.ContentViewClient; import org.chromium.content.browser.ContentViewClient;
import org.chromium.content.browser.ContentViewCore;
import org.chromium.content_shell.Shell; import org.chromium.content_shell.Shell;
import org.chromium.content_shell.ShellManager; import org.chromium.content_shell.ShellManager;
import org.chromium.ui.base.ActivityWindowAndroid; import org.chromium.ui.base.ActivityWindowAndroid;
...@@ -129,7 +129,7 @@ public class ChromiumLinkerTestActivity extends Activity { ...@@ -129,7 +129,7 @@ public class ChromiumLinkerTestActivity extends Activity {
private void finishInitialization(Bundle savedInstanceState) { private void finishInitialization(Bundle savedInstanceState) {
String shellUrl = ShellManager.DEFAULT_SHELL_URL; String shellUrl = ShellManager.DEFAULT_SHELL_URL;
mShellManager.launchShell(shellUrl); mShellManager.launchShell(shellUrl);
getActiveContentView().setContentViewClient(new ContentViewClient()); getActiveContentViewCore().setContentViewClient(new ContentViewClient());
} }
private void initializationFailed() { private void initializationFailed() {
...@@ -155,16 +155,16 @@ public class ChromiumLinkerTestActivity extends Activity { ...@@ -155,16 +155,16 @@ public class ChromiumLinkerTestActivity extends Activity {
protected void onStop() { protected void onStop() {
super.onStop(); super.onStop();
ContentView view = getActiveContentView(); ContentViewCore contentViewCore = getActiveContentViewCore();
if (view != null) view.onHide(); if (contentViewCore != null) contentViewCore.onHide();
} }
@Override @Override
protected void onStart() { protected void onStart() {
super.onStart(); super.onStart();
ContentView view = getActiveContentView(); ContentViewCore contentViewCore = getActiveContentViewCore();
if (view != null) view.onShow(); if (contentViewCore != null) contentViewCore.onShow();
} }
@Override @Override
...@@ -178,10 +178,10 @@ public class ChromiumLinkerTestActivity extends Activity { ...@@ -178,10 +178,10 @@ public class ChromiumLinkerTestActivity extends Activity {
} }
/** /**
* @return The {@link ContentView} owned by the currently visible {@link Shell} or null if one * @return The {@link ContentViewCore} owned by the currently visible {@link Shell} or null if
* is not showing. * one is not showing.
*/ */
public ContentView getActiveContentView() { public ContentViewCore getActiveContentViewCore() {
if (mShellManager == null) if (mShellManager == null)
return null; return null;
...@@ -189,6 +189,6 @@ public class ChromiumLinkerTestActivity extends Activity { ...@@ -189,6 +189,6 @@ public class ChromiumLinkerTestActivity extends Activity {
if (shell == null) if (shell == null)
return null; return null;
return shell.getContentView(); return shell.getContentViewCore();
} }
} }
...@@ -19,6 +19,7 @@ import org.chromium.base.library_loader.LibraryLoader; ...@@ -19,6 +19,7 @@ import org.chromium.base.library_loader.LibraryLoader;
import org.chromium.base.library_loader.ProcessInitException; import org.chromium.base.library_loader.ProcessInitException;
import org.chromium.content.browser.BrowserStartupController; import org.chromium.content.browser.BrowserStartupController;
import org.chromium.content.browser.ContentView; import org.chromium.content.browser.ContentView;
import org.chromium.content.browser.ContentViewCore;
import org.chromium.content.browser.DeviceUtils; import org.chromium.content.browser.DeviceUtils;
import org.chromium.content.common.ContentSwitches; import org.chromium.content.common.ContentSwitches;
import org.chromium.content_shell.Shell; import org.chromium.content_shell.Shell;
...@@ -125,9 +126,9 @@ public class ContentShellActivity extends Activity { ...@@ -125,9 +126,9 @@ public class ContentShellActivity extends Activity {
@Override @Override
protected void onSaveInstanceState(Bundle outState) { protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState); super.onSaveInstanceState(outState);
Shell activeShell = getActiveShell(); ContentViewCore contentViewCore = getActiveContentViewCore();
if (activeShell != null) { if (contentViewCore != null) {
outState.putString(ACTIVE_SHELL_URL_KEY, activeShell.getContentView().getUrl()); outState.putString(ACTIVE_SHELL_URL_KEY, contentViewCore.getUrl());
} }
mWindowAndroid.saveInstanceState(outState); mWindowAndroid.saveInstanceState(outState);
...@@ -144,9 +145,9 @@ public class ContentShellActivity extends Activity { ...@@ -144,9 +145,9 @@ public class ContentShellActivity extends Activity {
@Override @Override
public boolean onKeyUp(int keyCode, KeyEvent event) { public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) { if (keyCode == KeyEvent.KEYCODE_BACK) {
ContentView contentView = getActiveContentView(); ContentViewCore contentViewCore = getActiveContentViewCore();
if (contentView != null && contentView.canGoBack()) { if (contentViewCore != null && contentViewCore.canGoBack()) {
contentView.goBack(); contentViewCore.goBack();
return true; return true;
} }
} }
...@@ -175,16 +176,16 @@ public class ContentShellActivity extends Activity { ...@@ -175,16 +176,16 @@ public class ContentShellActivity extends Activity {
protected void onStop() { protected void onStop() {
super.onStop(); super.onStop();
ContentView view = getActiveContentView(); ContentViewCore contentViewCore = getActiveContentViewCore();
if (view != null) view.onHide(); if (contentViewCore != null) contentViewCore.onHide();
} }
@Override @Override
protected void onStart() { protected void onStart() {
super.onStart(); super.onStart();
ContentView view = getActiveContentView(); ContentViewCore contentViewCore = getActiveContentViewCore();
if (view != null) view.onShow(); if (contentViewCore != null) contentViewCore.onShow();
} }
@Override @Override
...@@ -224,4 +225,13 @@ public class ContentShellActivity extends Activity { ...@@ -224,4 +225,13 @@ public class ContentShellActivity extends Activity {
Shell shell = getActiveShell(); Shell shell = getActiveShell();
return shell != null ? shell.getContentView() : null; return shell != null ? shell.getContentView() : null;
} }
/**
* @return The {@link ContentViewCore} owned by the currently visible {@link Shell} or null if
* one is not showing.
*/
public ContentViewCore getActiveContentViewCore() {
Shell shell = getActiveShell();
return shell != null ? shell.getContentViewCore() : null;
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment