| Index: content/shell/android/java/src/org/chromium/content_shell/Shell.java
|
| 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 da99918f4d7cfb73652e8854a5f105b2808dc805..631c5ad6076d1a744f0d93a3793b5b46b5699854 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
|
| @@ -4,62 +4,25 @@
|
|
|
| package org.chromium.content_shell;
|
|
|
| -import android.content.Context;
|
| -import android.graphics.drawable.ClipDrawable;
|
| -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;
|
| -import android.widget.FrameLayout;
|
| -import android.widget.ImageButton;
|
| -import android.widget.LinearLayout;
|
| -import android.widget.TextView;
|
| -import android.widget.TextView.OnEditorActionListener;
|
| -
|
| import org.chromium.base.annotations.CalledByNative;
|
| import org.chromium.base.annotations.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_public.browser.LoadUrlParams;
|
| -import org.chromium.content_public.browser.NavigationController;
|
| -import org.chromium.content_public.browser.WebContents;
|
| -import org.chromium.ui.base.WindowAndroid;
|
| +//import org.chromium.content_public.browser.LoadUrlParams;
|
| +//import org.chromium.content_public.browser.NavigationController;
|
| +//import org.chromium.content_public.browser.WebContents;
|
| +//import org.chromium.ui.base.WindowAndroid;
|
| +
|
| +//import org.chromium.ui.PlatformWindowAndroid;
|
|
|
| /**
|
| * Container for the various UI components that make up a shell window.
|
| */
|
| @JNINamespace("content")
|
| -public class Shell extends LinearLayout {
|
| -
|
| - private static final long COMPLETED_PROGRESS_TIMEOUT_MS = 200;
|
| -
|
| - private final Runnable mClearProgressRunnable = new Runnable() {
|
| - @Override
|
| - public void run() {
|
| - mProgressDrawable.setLevel(0);
|
| - }
|
| - };
|
| +public class Shell {
|
|
|
| - private ContentViewCore mContentViewCore;
|
| - private WebContents mWebContents;
|
| - private NavigationController mNavigationController;
|
| - private ContentViewClient mContentViewClient;
|
| - private EditText mUrlTextView;
|
| - private ImageButton mPrevButton;
|
| - private ImageButton mNextButton;
|
| - private ImageButton mStopReloadButton;
|
| -
|
| - private ClipDrawable mProgressDrawable;
|
| +// private WebContents mWebContents;
|
| +// private NavigationController mNavigationController;
|
|
|
| private long mNativeShell;
|
| - private ContentViewRenderView mContentViewRenderView;
|
| - private WindowAndroid mWindow;
|
|
|
| private boolean mLoading = false;
|
| private boolean mIsFullscreen = false;
|
| @@ -67,40 +30,34 @@ public class Shell extends LinearLayout {
|
| /**
|
| * Constructor for inflating via XML.
|
| */
|
| - public Shell(Context context, AttributeSet attrs) {
|
| - super(context, attrs);
|
| + public Shell() {
|
| }
|
|
|
| /**
|
| * Set the SurfaceView being renderered to as soon as it is available.
|
| */
|
| - public void setContentViewRenderView(ContentViewRenderView contentViewRenderView) {
|
| - FrameLayout contentViewHolder = (FrameLayout) findViewById(R.id.contentview_holder);
|
| - if (contentViewRenderView == null) {
|
| - if (mContentViewRenderView != null) {
|
| - contentViewHolder.removeView(mContentViewRenderView);
|
| - }
|
| - } else {
|
| - contentViewHolder.addView(contentViewRenderView,
|
| - new FrameLayout.LayoutParams(
|
| - FrameLayout.LayoutParams.MATCH_PARENT,
|
| - FrameLayout.LayoutParams.MATCH_PARENT));
|
| - }
|
| - mContentViewRenderView = contentViewRenderView;
|
| - }
|
| +// public void setPlatformWindowAndroid(PlatformWindowAndroid platformWindowAndroid) {
|
| +// FrameLayout contentViewHolder = (FrameLayout) findViewById(R.id.contentview_holder);
|
| +// if (contentViewRenderView == null) {
|
| +// if (mPlatformWindowAndroid != null) {
|
| +// contentViewHolder.removeView(mPlatformWindowAndroid);
|
| +// }
|
| +// } else {
|
| +// contentViewHolder.addView(platformWindowAndroid,
|
| +// new FrameLayout.LayoutParams(
|
| +// FrameLayout.LayoutParams.MATCH_PARENT,
|
| +// FrameLayout.LayoutParams.MATCH_PARENT));
|
| +// }
|
| +// mPlatformWindowAndroid = platformWindowAndroid;
|
| +// }
|
|
|
| /**
|
| * Initializes the Shell for use.
|
| *
|
| * @param nativeShell The pointer to the native Shell object.
|
| - * @param window The owning window for this shell.
|
| - * @param client The {@link ContentViewClient} to be bound to any current or new
|
| - * {@link ContentViewCore}s associated with this shell.
|
| */
|
| - public void initialize(long nativeShell, WindowAndroid window, ContentViewClient client) {
|
| + public void initialize(long nativeShell) {
|
| mNativeShell = nativeShell;
|
| - mWindow = window;
|
| - mContentViewClient = client;
|
| }
|
|
|
| /**
|
| @@ -114,9 +71,7 @@ public class Shell extends LinearLayout {
|
|
|
| @CalledByNative
|
| private void onNativeDestroyed() {
|
| - mWindow = null;
|
| mNativeShell = 0;
|
| - mContentViewCore.destroy();
|
| }
|
|
|
| /**
|
| @@ -134,55 +89,6 @@ public class Shell extends LinearLayout {
|
| return mLoading;
|
| }
|
|
|
| - @Override
|
| - protected void onFinishInflate() {
|
| - super.onFinishInflate();
|
| -
|
| - mProgressDrawable = (ClipDrawable) findViewById(R.id.toolbar).getBackground();
|
| - initializeUrlField();
|
| - initializeNavigationButtons();
|
| - }
|
| -
|
| - private void initializeUrlField() {
|
| - mUrlTextView = (EditText) findViewById(R.id.url);
|
| - mUrlTextView.setOnEditorActionListener(new OnEditorActionListener() {
|
| - @Override
|
| - public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
| - if ((actionId != EditorInfo.IME_ACTION_GO) && (event == null
|
| - || event.getKeyCode() != KeyEvent.KEYCODE_ENTER
|
| - || event.getAction() != KeyEvent.ACTION_DOWN)) {
|
| - return false;
|
| - }
|
| - loadUrl(mUrlTextView.getText().toString());
|
| - setKeyboardVisibilityForUrl(false);
|
| - mContentViewCore.getContainerView().requestFocus();
|
| - return true;
|
| - }
|
| - });
|
| - mUrlTextView.setOnFocusChangeListener(new OnFocusChangeListener() {
|
| - @Override
|
| - public void onFocusChange(View v, boolean hasFocus) {
|
| - setKeyboardVisibilityForUrl(hasFocus);
|
| - mNextButton.setVisibility(hasFocus ? GONE : VISIBLE);
|
| - mPrevButton.setVisibility(hasFocus ? GONE : VISIBLE);
|
| - mStopReloadButton.setVisibility(hasFocus ? GONE : VISIBLE);
|
| - if (!hasFocus) {
|
| - mUrlTextView.setText(mWebContents.getUrl());
|
| - }
|
| - }
|
| - });
|
| - mUrlTextView.setOnKeyListener(new OnKeyListener() {
|
| - @Override
|
| - public boolean onKey(View v, int keyCode, KeyEvent event) {
|
| - if (keyCode == KeyEvent.KEYCODE_BACK) {
|
| - mContentViewCore.getContainerView().requestFocus();
|
| - return true;
|
| - }
|
| - return false;
|
| - }
|
| - });
|
| - }
|
| -
|
| /**
|
| * Loads an URL. This will perform minimal amounts of sanitizing of the URL to attempt to
|
| * make it valid.
|
| @@ -191,16 +97,12 @@ public class Shell extends LinearLayout {
|
| */
|
| public void loadUrl(String url) {
|
| if (url == null) return;
|
| -
|
| - if (TextUtils.equals(url, mWebContents.getUrl())) {
|
| - mNavigationController.reload(true);
|
| - } else {
|
| - mNavigationController.loadUrl(new LoadUrlParams(sanitizeUrl(url)));
|
| - }
|
| - mUrlTextView.clearFocus();
|
| - // TODO(aurimas): Remove this when crbug.com/174541 is fixed.
|
| - mContentViewCore.getContainerView().clearFocus();
|
| - mContentViewCore.getContainerView().requestFocus();
|
| + // TODO(mfomitchev): need mNavigationController for this
|
| +// if (TextUtils.equals(url, mWebContents.getUrl())) {
|
| +// mNavigationController.reload(true);
|
| +// } else {
|
| +// mNavigationController.loadUrl(new LoadUrlParams(sanitizeUrl(url)));
|
| +// }
|
| }
|
|
|
| /**
|
| @@ -214,141 +116,87 @@ public class Shell extends LinearLayout {
|
| return url;
|
| }
|
|
|
| - private void initializeNavigationButtons() {
|
| - mPrevButton = (ImageButton) findViewById(R.id.prev);
|
| - mPrevButton.setOnClickListener(new OnClickListener() {
|
| - @Override
|
| - public void onClick(View v) {
|
| - if (mNavigationController.canGoBack()) mNavigationController.goBack();
|
| - }
|
| - });
|
| -
|
| - mNextButton = (ImageButton) findViewById(R.id.next);
|
| - mNextButton.setOnClickListener(new OnClickListener() {
|
| - @Override
|
| - public void onClick(View v) {
|
| - if (mNavigationController.canGoForward()) mNavigationController.goForward();
|
| - }
|
| - });
|
| - mStopReloadButton = (ImageButton) findViewById(R.id.stop_reload_button);
|
| - mStopReloadButton.setOnClickListener(new OnClickListener() {
|
| - @Override
|
| - public void onClick(View v) {
|
| - if (mLoading) mWebContents.stop();
|
| - else mNavigationController.reload(true);
|
| - }
|
| - });
|
| - }
|
| -
|
| - @SuppressWarnings("unused")
|
| - @CalledByNative
|
| - private void onUpdateUrl(String url) {
|
| - mUrlTextView.setText(url);
|
| - }
|
| -
|
| - @SuppressWarnings("unused")
|
| - @CalledByNative
|
| - private void onLoadProgressChanged(double progress) {
|
| - removeCallbacks(mClearProgressRunnable);
|
| - mProgressDrawable.setLevel((int) (10000.0 * progress));
|
| - if (progress == 1.0) postDelayed(mClearProgressRunnable, COMPLETED_PROGRESS_TIMEOUT_MS);
|
| - }
|
| -
|
| - @CalledByNative
|
| - private void toggleFullscreenModeForTab(boolean enterFullscreen) {
|
| - mIsFullscreen = enterFullscreen;
|
| - LinearLayout toolBar = (LinearLayout) findViewById(R.id.toolbar);
|
| - toolBar.setVisibility(enterFullscreen ? GONE : VISIBLE);
|
| - }
|
| -
|
| - @CalledByNative
|
| - private boolean isFullscreenForTabOrPending() {
|
| - return mIsFullscreen;
|
| - }
|
| -
|
| - @SuppressWarnings("unused")
|
| - @CalledByNative
|
| - private void setIsLoading(boolean loading) {
|
| - mLoading = loading;
|
| - if (mLoading) {
|
| - mStopReloadButton
|
| - .setImageResource(android.R.drawable.ic_menu_close_clear_cancel);
|
| - } else {
|
| - mStopReloadButton.setImageResource(R.drawable.ic_refresh);
|
| - }
|
| - }
|
| -
|
| - /**
|
| - * Initializes the ContentView based on the native tab contents pointer passed in.
|
| - * @param webContents A {@link WebContents} object.
|
| - */
|
| - @SuppressWarnings("unused")
|
| - @CalledByNative
|
| - private void initFromNativeTabContents(WebContents webContents) {
|
| - Context context = getContext();
|
| - mContentViewCore = new ContentViewCore(context);
|
| - ContentView cv = new ContentView(context, mContentViewCore);
|
| - mContentViewCore.initialize(cv, cv, webContents, mWindow);
|
| - mContentViewCore.setContentViewClient(mContentViewClient);
|
| - mWebContents = mContentViewCore.getWebContents();
|
| - mNavigationController = mWebContents.getNavigationController();
|
| - if (getParent() != null) mContentViewCore.onShow();
|
| - if (mWebContents.getUrl() != null) {
|
| - mUrlTextView.setText(mWebContents.getUrl());
|
| - }
|
| - ((FrameLayout) findViewById(R.id.contentview_holder)).addView(cv,
|
| - new FrameLayout.LayoutParams(
|
| - FrameLayout.LayoutParams.MATCH_PARENT,
|
| - FrameLayout.LayoutParams.MATCH_PARENT));
|
| - cv.requestFocus();
|
| - mContentViewRenderView.setCurrentContentViewCore(mContentViewCore);
|
| - }
|
| -
|
| - /**
|
| - * Enable/Disable navigation(Prev/Next) button if navigation is allowed/disallowed
|
| - * in respective direction.
|
| - * @param controlId Id of button to update
|
| - * @param enabled enable/disable value
|
| - */
|
| - @CalledByNative
|
| - private void enableUiControl(int controlId, boolean enabled) {
|
| - if (controlId == 0) {
|
| - mPrevButton.setEnabled(enabled);
|
| - } else if (controlId == 1) {
|
| - mNextButton.setEnabled(enabled);
|
| - }
|
| - }
|
| -
|
| - /**
|
| - * @return The {@link ViewGroup} currently shown by this Shell.
|
| - */
|
| - public ViewGroup getContentView() {
|
| - return mContentViewCore.getContainerView();
|
| - }
|
| -
|
| - /**
|
| - * @return The {@link ContentViewCore} currently managing the view shown by this Shell.
|
| - */
|
| - public ContentViewCore getContentViewCore() {
|
| - return mContentViewCore;
|
| - }
|
| -
|
| - /**
|
| - * @return The {@link WebContents} currently managing the content shown by this Shell.
|
| - */
|
| - public WebContents getWebContents() {
|
| - return mWebContents;
|
| - }
|
| -
|
| - private void setKeyboardVisibilityForUrl(boolean visible) {
|
| - InputMethodManager imm = (InputMethodManager) getContext().getSystemService(
|
| - Context.INPUT_METHOD_SERVICE);
|
| - if (visible) {
|
| - imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT);
|
| - } else {
|
| - imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0);
|
| - }
|
| - }
|
| +// @CalledByNative
|
| +// private void toggleFullscreenModeForTab(boolean enterFullscreen) {
|
| +// mIsFullscreen = enterFullscreen;
|
| +// LinearLayout toolBar = (LinearLayout) findViewById(R.id.toolbar);
|
| +// toolBar.setVisibility(enterFullscreen ? GONE : VISIBLE);
|
| +// }
|
| +
|
| +// @CalledByNative
|
| +// private boolean isFullscreenForTabOrPending() {
|
| +// return mIsFullscreen;
|
| +// }
|
| +
|
| +// @SuppressWarnings("unused")
|
| +// @CalledByNative
|
| +// private void setIsLoading(boolean loading) {
|
| +// mLoading = loading;
|
| +// if (mLoading) {
|
| +// mStopReloadButton
|
| +// .setImageResource(android.R.drawable.ic_menu_close_clear_cancel);
|
| +// } else {
|
| +// mStopReloadButton.setImageResource(R.drawable.ic_refresh);
|
| +// }
|
| +// }
|
| +
|
| +// /**
|
| +// * Initializes the ContentView based on the native tab contents pointer passed in.
|
| +// * @param webContents A {@link WebContents} object.
|
| +// */
|
| +// @SuppressWarnings("unused")
|
| +// @CalledByNative
|
| +// private void initFromNativeTabContents(WebContents webContents) {
|
| +// Context context = getContext();
|
| +// mContentViewCore = new ContentViewCore(context);
|
| +// ContentView cv = new ContentView(context, mContentViewCore);
|
| +// mContentViewCore.initialize(cv, cv, webContents, mWindow);
|
| +// mContentViewCore.setContentViewClient(mContentViewClient);
|
| +// mWebContents = mContentViewCore.getWebContents();
|
| +// mNavigationController = mWebContents.getNavigationController();
|
| +// if (getParent() != null) mContentViewCore.onShow();
|
| +// if (mWebContents.getUrl() != null) {
|
| +// mUrlTextView.setText(mWebContents.getUrl());
|
| +// }
|
| +// ((FrameLayout) findViewById(R.id.contentview_holder)).addView(cv,
|
| +// new FrameLayout.LayoutParams(
|
| +// FrameLayout.LayoutParams.MATCH_PARENT,
|
| +// FrameLayout.LayoutParams.MATCH_PARENT));
|
| +// cv.requestFocus();
|
| +// mContentViewRenderView.setCurrentContentViewCore(mContentViewCore);
|
| +// }
|
| +
|
| +// /**
|
| +// * Enable/Disable navigation(Prev/Next) button if navigation is allowed/disallowed
|
| +// * in respective direction.
|
| +// * @param controlId Id of button to update
|
| +// * @param enabled enable/disable value
|
| +// */
|
| +// @CalledByNative
|
| +// private void enableUiControl(int controlId, boolean enabled) {
|
| +// if (controlId == 0) {
|
| +// mPrevButton.setEnabled(enabled);
|
| +// } else if (controlId == 1) {
|
| +// mNextButton.setEnabled(enabled);
|
| +// }
|
| +// }
|
| +
|
| +// /**
|
| +// * @return The {@link WebContents} currently managing the content shown by this Shell.
|
| +// */
|
| +// public WebContents getWebContents() {
|
| +// return mWebContents;
|
| +// }
|
| +
|
| +// private void setKeyboardVisibilityForUrl(boolean visible) {
|
| +// InputMethodManager imm = (InputMethodManager) getContext().getSystemService(
|
| +// Context.INPUT_METHOD_SERVICE);
|
| +// if (visible) {
|
| +// imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT);
|
| +// } else {
|
| +// imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0);
|
| +// }
|
| +// }
|
|
|
| private static native void nativeCloseShell(long shellPtr);
|
| }
|
|
|