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

Unified Diff: services/native_viewport/android/src/org/chromium/mojo/PlatformViewportAndroid.java

Issue 1280613003: Allow native_viewport to create new native windows on demand on Android. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 4 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: services/native_viewport/android/src/org/chromium/mojo/PlatformViewportAndroid.java
diff --git a/services/native_viewport/android/src/org/chromium/mojo/PlatformViewportAndroid.java b/services/native_viewport/android/src/org/chromium/mojo/PlatformViewportAndroid.java
index fabcb081c574382ffe5c7e927eaa4b3ae52e4914..1b1ef9bf5cf688f9bd710921777d20bc530a0713 100644
--- a/services/native_viewport/android/src/org/chromium/mojo/PlatformViewportAndroid.java
+++ b/services/native_viewport/android/src/org/chromium/mojo/PlatformViewportAndroid.java
@@ -6,6 +6,7 @@ package org.chromium.mojo;
import android.app.Activity;
import android.content.Context;
+import android.content.Intent;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.SurfaceHolder;
@@ -18,6 +19,7 @@ import org.chromium.base.ApplicationStatus;
import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
import org.chromium.mojo.keyboard.KeyboardServiceImpl;
+import org.chromium.mojo.shell.ViewportActivity;
/**
* Exposes SurfaceView to native code.
@@ -30,13 +32,23 @@ public class PlatformViewportAndroid extends SurfaceView {
@CalledByNative
public static PlatformViewportAndroid create(long nativeViewport) {
- Activity activity = ApplicationStatus.getLastTrackedFocusedActivity();
+ Activity activity = ViewportActivity.getNextUnattachedActivity();
PlatformViewportAndroid rv = new PlatformViewportAndroid(activity, nativeViewport);
KeyboardServiceImpl.setActiveView(rv);
activity.setContentView(rv);
return rv;
}
+ @CalledByNative
+ public static void createNativeWindow() {
+ final Context context = ApplicationStatus.getApplicationContext();
+ final Intent newDocumentIntent = new Intent(context, ViewportActivity.class);
+ newDocumentIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
+ newDocumentIntent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
+ newDocumentIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ context.startActivity(newDocumentIntent);
+ }
+
public PlatformViewportAndroid(Context context, long nativeViewport) {
super(context);

Powered by Google App Engine
This is Rietveld 408576698