diff options
author | sungmann.cho@navercorp.com <sungmann.cho@navercorp.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-21 10:02:19 +0000 |
---|---|---|
committer | sungmann.cho@navercorp.com <sungmann.cho@navercorp.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-21 10:02:19 +0000 |
commit | 81b2a0566177262ef54e704911f35c20463b5cac (patch) | |
tree | c4c071ac3086593b07558c3429cb6172ba4a0aee /content/shell/android/java/src | |
parent | 48209017b42f9f862d7e56607a475b96274dca3c (diff) | |
download | chromium_src-81b2a0566177262ef54e704911f35c20463b5cac.zip chromium_src-81b2a0566177262ef54e704911f35c20463b5cac.tar.gz chromium_src-81b2a0566177262ef54e704911f35c20463b5cac.tar.bz2 |
Fix a crash of the Content Shell for Android when showing videos in a ContentVideoView.
The Content Shell for Android crashes when it attempts to show a ContentVideoView(see below logs for details).
It only happens in the child Shell that newly opened, not in the initial Shell.
Because a ContentViewClient is set only for the initial Shell, but not the others.
Steps to reproduces:
1. Go to http://www.google.com and search YouTube.
2. Click the link of YouTube in the result pages. Then YouTube page is opened in a new Shell.
3. Click a play button on a video clip.
java.lang.NullPointerException
at org.chromium.content.browser.ContentVideoView.showContentVideoView(ContentVideoView.java:176)
at org.chromium.content.browser.ContentVideoViewLegacy.showContentVideoView(ContentVideoViewLegacy.java:128)
at org.chromium.content.browser.ContentVideoView.<init>(ContentVideoView.java:150)
at org.chromium.content.browser.ContentVideoViewLegacy.<init>(ContentVideoViewLegacy.java:57)
at org.chromium.content.browser.ContentVideoView.createContentVideoView(ContentVideoView.java:378)
at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:24)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Review URL: https://codereview.chromium.org/172043002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@252530 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/shell/android/java/src')
-rw-r--r-- | content/shell/android/java/src/org/chromium/content_shell/Shell.java | 8 | ||||
-rw-r--r-- | content/shell/android/java/src/org/chromium/content_shell/ShellManager.java | 36 |
2 files changed, 41 insertions, 3 deletions
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 3a442a0..5e21dc0 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 @@ -22,6 +22,7 @@ import android.widget.TextView.OnEditorActionListener; 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.ContentViewRenderView; import org.chromium.content.browser.LoadUrlParams; import org.chromium.ui.base.WindowAndroid; @@ -43,6 +44,7 @@ public class Shell extends LinearLayout { // TODO(jrg): a mContentView.destroy() call is needed, both upstream and downstream. private ContentView mContentView; + private ContentViewClient mContentViewClient; private EditText mUrlTextView; private ImageButton mPrevButton; private ImageButton mNextButton; @@ -85,10 +87,13 @@ public class Shell extends LinearLayout { * * @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) { + public void initialize(long nativeShell, WindowAndroid window, ContentViewClient client) { mNativeShell = nativeShell; mWindow = window; + mContentViewClient = client; } /** @@ -246,6 +251,7 @@ public class Shell extends LinearLayout { @CalledByNative private void initFromNativeTabContents(long nativeTabContents) { mContentView = ContentView.newInstance(getContext(), nativeTabContents, mWindow); + mContentView.setContentViewClient(mContentViewClient); if (mContentView.getUrl() != null) mUrlTextView.setText(mContentView.getUrl()); ((FrameLayout) findViewById(R.id.contentview_holder)).addView(mContentView, new FrameLayout.LayoutParams( 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 9303be8..96b4112 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 @@ -4,16 +4,23 @@ package org.chromium.content_shell; +import android.app.Activity; import android.content.Context; import android.util.AttributeSet; import android.view.LayoutInflater; +import android.view.View; import android.widget.FrameLayout; import org.chromium.base.CalledByNative; +import org.chromium.base.CommandLine; 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.ContentViewRenderView; +import org.chromium.content.common.ContentSwitches; import org.chromium.ui.base.WindowAndroid; /** @@ -31,13 +38,38 @@ public class ShellManager extends FrameLayout { // The target for all content rendering. private ContentViewRenderView mContentViewRenderView; + private ContentViewClient mContentViewClient; /** * Constructor for inflating via XML. */ - public ShellManager(Context context, AttributeSet attrs) { + public ShellManager(final Context context, AttributeSet attrs) { super(context, attrs); nativeInit(this); + mContentViewClient = new ContentViewClient() { + @Override + public ContentVideoViewClient getContentVideoViewClient() { + return new ActivityContentVideoViewClient((Activity) context) { + @Override + public void onShowCustomView(View view) { + super.onShowCustomView(view); + if (CommandLine.getInstance().hasSwitch( + ContentSwitches.ENABLE_OVERLAY_FULLSCREEN_VIDEO_SUBTITLE)) { + setOverlayVideoMode(true); + } + } + + @Override + public void onDestroyContentVideoView() { + super.onDestroyContentVideoView(); + if (CommandLine.getInstance().hasSwitch( + ContentSwitches.ENABLE_OVERLAY_FULLSCREEN_VIDEO_SUBTITLE)) { + setOverlayVideoMode(false); + } + } + }; + } + }; } /** @@ -105,7 +137,7 @@ public class ShellManager extends FrameLayout { LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); Shell shellView = (Shell) inflater.inflate(R.layout.shell_view, null); - shellView.initialize(nativeShellPtr, mWindow); + shellView.initialize(nativeShellPtr, mWindow, mContentViewClient); // TODO(tedchoc): Allow switching back to these inactive shells. if (mActiveShell != null) removeShell(mActiveShell); |