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

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

Issue 10823051: ContentShell rendering support on Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address Ted's comments Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: content/shell/android/java/src/org/chromium/content_shell/ShellManager.java
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 feb6c84963a566cd0877d4562fe11c1357ea8423..e97ba20978a0f1e4b40a235b79e27a0d339badbf 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
@@ -7,6 +7,9 @@ package org.chromium.content_shell;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
+import android.view.Surface;
+import android.view.SurfaceView;
+import android.view.SurfaceHolder;
import android.widget.FrameLayout;
import org.chromium.base.CalledByNative;
@@ -20,12 +23,43 @@ public class ShellManager extends FrameLayout {
private Shell mActiveShell;
+ private String mStartupUrl = ContentShellActivity.DEFAULT_SHELL_URL;
+
+ // The target for all content rendering.
+ private SurfaceView mSurfaceView;
+
/**
* Constructor for inflating via XML.
*/
public ShellManager(Context context, AttributeSet attrs) {
super(context, attrs);
nativeInit(this);
+
+ mSurfaceView = new SurfaceView(context);
+ mSurfaceView.getHolder().addCallback(new SurfaceHolder.Callback() {
+ @Override
+ public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
+ nativeSurfaceSetSize(width, height);
+ }
+
+ @Override
+ public void surfaceCreated(SurfaceHolder holder) {
+ nativeSurfaceCreated(holder.getSurface());
+ mActiveShell.loadUrl(mStartupUrl);
+ }
+
+ @Override
+ public void surfaceDestroyed(SurfaceHolder holder) {
+ nativeSurfaceDestroyed();
+ }
+ });
+ }
+
+ /**
+ * Sets the startup URL for new shell windows.
+ */
+ public void setStartupUrl(String url) {
+ mStartupUrl = url;
}
/**
@@ -49,6 +83,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.setSurfaceView(mSurfaceView);
removeAllViews();
addView(shellView, new FrameLayout.LayoutParams(
@@ -60,4 +95,7 @@ public class ShellManager extends FrameLayout {
private static native void nativeInit(Object shellManagerInstance);
private static native void nativeLaunchShell(String url);
+ private static native void nativeSurfaceCreated(Surface surface);
+ private static native void nativeSurfaceDestroyed();
+ private static native void nativeSurfaceSetSize(int width, int height);
}

Powered by Google App Engine
This is Rietveld 408576698