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

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.content.Context; 7 import android.content.Context;
8 import android.util.AttributeSet; 8 import android.util.AttributeSet;
9 import android.view.LayoutInflater; 9 import android.view.LayoutInflater;
10 import android.widget.FrameLayout; 10 import android.widget.FrameLayout;
11 11
12 import org.chromium.base.CalledByNative; 12 import org.chromium.base.CalledByNative;
13 import org.chromium.base.JNINamespace; 13 import org.chromium.base.JNINamespace;
14 import org.chromium.base.ThreadUtils; 14 import org.chromium.base.ThreadUtils;
15 import org.chromium.content.browser.ContentView; 15 import org.chromium.content.browser.ContentView;
16 import org.chromium.content.browser.ContentViewClient;
16 import org.chromium.content.browser.ContentViewRenderView; 17 import org.chromium.content.browser.ContentViewRenderView;
17 import org.chromium.ui.base.WindowAndroid; 18 import org.chromium.ui.base.WindowAndroid;
18 19
19 /** 20 /**
20 * Container and generator of ShellViews. 21 * Container and generator of ShellViews.
21 */ 22 */
22 @JNINamespace("content") 23 @JNINamespace("content")
23 public class ShellManager extends FrameLayout { 24 public class ShellManager extends FrameLayout {
24 25
25 public static final String DEFAULT_SHELL_URL = "http://www.google.com"; 26 public static final String DEFAULT_SHELL_URL = "http://www.google.com";
26 private static boolean sStartup = true; 27 private static boolean sStartup = true;
27 private WindowAndroid mWindow; 28 private WindowAndroid mWindow;
28 private Shell mActiveShell; 29 private Shell mActiveShell;
29 30
30 private String mStartupUrl = DEFAULT_SHELL_URL; 31 private String mStartupUrl = DEFAULT_SHELL_URL;
31 32
32 // The target for all content rendering. 33 // The target for all content rendering.
33 private ContentViewRenderView mContentViewRenderView; 34 private ContentViewRenderView mContentViewRenderView;
35 private ContentViewClient mContentViewClient;
34 36
35 /** 37 /**
36 * Constructor for inflating via XML. 38 * Constructor for inflating via XML.
37 */ 39 */
38 public ShellManager(Context context, AttributeSet attrs) { 40 public ShellManager(Context context, AttributeSet attrs) {
39 super(context, attrs); 41 super(context, attrs);
40 nativeInit(this); 42 nativeInit(this);
41 } 43 }
42 44
43 /** 45 /**
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 93
92 /** 94 /**
93 * Enter or leave overlay video mode. 95 * Enter or leave overlay video mode.
94 * @param enabled Whether overlay mode is enabled. 96 * @param enabled Whether overlay mode is enabled.
95 */ 97 */
96 public void setOverlayVideoMode(boolean enabled) { 98 public void setOverlayVideoMode(boolean enabled) {
97 if (mContentViewRenderView == null) return; 99 if (mContentViewRenderView == null) return;
98 mContentViewRenderView.setOverlayVideoMode(enabled); 100 mContentViewRenderView.setOverlayVideoMode(enabled);
99 } 101 }
100 102
103 public void setContentViewClient(ContentViewClient client) {
Ted C 2014/02/20 00:54:08 I would just have ShellManager build the ContentVi
104 mContentViewClient = client;
105 }
106
101 @SuppressWarnings("unused") 107 @SuppressWarnings("unused")
102 @CalledByNative 108 @CalledByNative
103 private Object createShell(long nativeShellPtr) { 109 private Object createShell(long nativeShellPtr) {
104 assert mContentViewRenderView != null; 110 assert mContentViewRenderView != null;
105 LayoutInflater inflater = 111 LayoutInflater inflater =
106 (LayoutInflater) getContext().getSystemService(Context.LAYOUT_IN FLATER_SERVICE); 112 (LayoutInflater) getContext().getSystemService(Context.LAYOUT_IN FLATER_SERVICE);
107 Shell shellView = (Shell) inflater.inflate(R.layout.shell_view, null); 113 Shell shellView = (Shell) inflater.inflate(R.layout.shell_view, null);
108 shellView.initialize(nativeShellPtr, mWindow); 114 shellView.initialize(nativeShellPtr, mWindow);
115 shellView.setContentViewClient(mContentViewClient);
Ted C 2014/02/20 00:54:08 just pass this param with initialize above.
109 116
110 // TODO(tedchoc): Allow switching back to these inactive shells. 117 // TODO(tedchoc): Allow switching back to these inactive shells.
111 if (mActiveShell != null) removeShell(mActiveShell); 118 if (mActiveShell != null) removeShell(mActiveShell);
112 119
113 showShell(shellView); 120 showShell(shellView);
114 return shellView; 121 return shellView;
115 } 122 }
116 123
117 private void showShell(Shell shellView) { 124 private void showShell(Shell shellView) {
118 shellView.setContentViewRenderView(mContentViewRenderView); 125 shellView.setContentViewRenderView(mContentViewRenderView);
(...skipping 13 matching lines...) Expand all
132 if (shellView.getParent() == null) return; 139 if (shellView.getParent() == null) return;
133 ContentView contentView = shellView.getContentView(); 140 ContentView contentView = shellView.getContentView();
134 if (contentView != null) contentView.onHide(); 141 if (contentView != null) contentView.onHide();
135 shellView.setContentViewRenderView(null); 142 shellView.setContentViewRenderView(null);
136 removeView(shellView); 143 removeView(shellView);
137 } 144 }
138 145
139 private static native void nativeInit(Object shellManagerInstance); 146 private static native void nativeInit(Object shellManagerInstance);
140 private static native void nativeLaunchShell(String url); 147 private static native void nativeLaunchShell(String url);
141 } 148 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698