Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(352)

Side by Side Diff: content/shell/android/java/src/org/chromium/content_shell/ShellManager.java

Issue 172043002: Fix a crash of the Content Shell for Android when showing videos in a ContentVideoView. (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.content_shell; 5 package org.chromium.content_shell;
6 6
7 import android.app.Activity;
7 import android.content.Context; 8 import android.content.Context;
8 import android.util.AttributeSet; 9 import android.util.AttributeSet;
9 import android.view.LayoutInflater; 10 import android.view.LayoutInflater;
11 import android.view.View;
10 import android.widget.FrameLayout; 12 import android.widget.FrameLayout;
11 13
12 import org.chromium.base.CalledByNative; 14 import org.chromium.base.CalledByNative;
15 import org.chromium.base.CommandLine;
13 import org.chromium.base.JNINamespace; 16 import org.chromium.base.JNINamespace;
14 import org.chromium.base.ThreadUtils; 17 import org.chromium.base.ThreadUtils;
18 import org.chromium.content.browser.ActivityContentVideoViewClient;
19 import org.chromium.content.browser.ContentVideoViewClient;
15 import org.chromium.content.browser.ContentView; 20 import org.chromium.content.browser.ContentView;
21 import org.chromium.content.browser.ContentViewClient;
16 import org.chromium.content.browser.ContentViewRenderView; 22 import org.chromium.content.browser.ContentViewRenderView;
23 import org.chromium.content.common.ContentSwitches;
17 import org.chromium.ui.base.WindowAndroid; 24 import org.chromium.ui.base.WindowAndroid;
18 25
19 /** 26 /**
20 * Container and generator of ShellViews. 27 * Container and generator of ShellViews.
21 */ 28 */
22 @JNINamespace("content") 29 @JNINamespace("content")
23 public class ShellManager extends FrameLayout { 30 public class ShellManager extends FrameLayout {
24 31
25 public static final String DEFAULT_SHELL_URL = "http://www.google.com"; 32 public static final String DEFAULT_SHELL_URL = "http://www.google.com";
26 private static boolean sStartup = true; 33 private static boolean sStartup = true;
27 private WindowAndroid mWindow; 34 private WindowAndroid mWindow;
28 private Shell mActiveShell; 35 private Shell mActiveShell;
29 36
30 private String mStartupUrl = DEFAULT_SHELL_URL; 37 private String mStartupUrl = DEFAULT_SHELL_URL;
31 38
32 // The target for all content rendering. 39 // The target for all content rendering.
33 private ContentViewRenderView mContentViewRenderView; 40 private ContentViewRenderView mContentViewRenderView;
41 private ContentViewClient mContentViewClient;
34 42
35 /** 43 /**
36 * Constructor for inflating via XML. 44 * Constructor for inflating via XML.
37 */ 45 */
38 public ShellManager(Context context, AttributeSet attrs) { 46 public ShellManager(final Context context, AttributeSet attrs) {
39 super(context, attrs); 47 super(context, attrs);
40 nativeInit(this); 48 nativeInit(this);
49 mContentViewClient = new ContentViewClient() {
50 @Override
51 public ContentVideoViewClient getContentVideoViewClient() {
52 return new ActivityContentVideoViewClient((Activity) context) {
53 @Override
54 public void onShowCustomView(View view) {
55 super.onShowCustomView(view);
56 if (CommandLine.getInstance().hasSwitch(
57 ContentSwitches.ENABLE_OVERLAY_FULLSCREEN_VIDEO_ SUBTITLE)) {
58 setOverlayVideoMode(true);
59 }
60 }
61
62 @Override
63 public void onDestroyContentVideoView() {
64 super.onDestroyContentVideoView();
65 if (CommandLine.getInstance().hasSwitch(
66 ContentSwitches.ENABLE_OVERLAY_FULLSCREEN_VIDEO_ SUBTITLE)) {
67 setOverlayVideoMode(false);
68 }
69 }
70 };
71 }
72 };
41 } 73 }
42 74
43 /** 75 /**
44 * @param window The window used to generate all shells. 76 * @param window The window used to generate all shells.
45 */ 77 */
46 public void setWindow(WindowAndroid window) { 78 public void setWindow(WindowAndroid window) {
47 assert window != null; 79 assert window != null;
48 mWindow = window; 80 mWindow = window;
49 mContentViewRenderView = new ContentViewRenderView(getContext(), window) { 81 mContentViewRenderView = new ContentViewRenderView(getContext(), window) {
50 @Override 82 @Override
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 mContentViewRenderView.setOverlayVideoMode(enabled); 130 mContentViewRenderView.setOverlayVideoMode(enabled);
99 } 131 }
100 132
101 @SuppressWarnings("unused") 133 @SuppressWarnings("unused")
102 @CalledByNative 134 @CalledByNative
103 private Object createShell(long nativeShellPtr) { 135 private Object createShell(long nativeShellPtr) {
104 assert mContentViewRenderView != null; 136 assert mContentViewRenderView != null;
105 LayoutInflater inflater = 137 LayoutInflater inflater =
106 (LayoutInflater) getContext().getSystemService(Context.LAYOUT_IN FLATER_SERVICE); 138 (LayoutInflater) getContext().getSystemService(Context.LAYOUT_IN FLATER_SERVICE);
107 Shell shellView = (Shell) inflater.inflate(R.layout.shell_view, null); 139 Shell shellView = (Shell) inflater.inflate(R.layout.shell_view, null);
108 shellView.initialize(nativeShellPtr, mWindow); 140 shellView.initialize(nativeShellPtr, mWindow, mContentViewClient);
109 141
110 // TODO(tedchoc): Allow switching back to these inactive shells. 142 // TODO(tedchoc): Allow switching back to these inactive shells.
111 if (mActiveShell != null) removeShell(mActiveShell); 143 if (mActiveShell != null) removeShell(mActiveShell);
112 144
113 showShell(shellView); 145 showShell(shellView);
114 return shellView; 146 return shellView;
115 } 147 }
116 148
117 private void showShell(Shell shellView) { 149 private void showShell(Shell shellView) {
118 shellView.setContentViewRenderView(mContentViewRenderView); 150 shellView.setContentViewRenderView(mContentViewRenderView);
(...skipping 13 matching lines...) Expand all
132 if (shellView.getParent() == null) return; 164 if (shellView.getParent() == null) return;
133 ContentView contentView = shellView.getContentView(); 165 ContentView contentView = shellView.getContentView();
134 if (contentView != null) contentView.onHide(); 166 if (contentView != null) contentView.onHide();
135 shellView.setContentViewRenderView(null); 167 shellView.setContentViewRenderView(null);
136 removeView(shellView); 168 removeView(shellView);
137 } 169 }
138 170
139 private static native void nativeInit(Object shellManagerInstance); 171 private static native void nativeInit(Object shellManagerInstance);
140 private static native void nativeLaunchShell(String url); 172 private static native void nativeLaunchShell(String url);
141 } 173 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698