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

Unified Diff: shell/android/main.cc

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: shell/android/main.cc
diff --git a/shell/android/main.cc b/shell/android/main.cc
index 6502015c0b28692fdc5dbc9b8be0dbaf10592d93..76cd4a56e5a4bc3407e8ecbf5f6d763970e87e1a 100644
--- a/shell/android/main.cc
+++ b/shell/android/main.cc
@@ -23,6 +23,7 @@
#include "base/threading/simple_thread.h"
#include "jni/ShellService_jni.h"
#include "mojo/common/message_pump_mojo.h"
+#include "mojo/services/native_viewport/public/interfaces/native_viewport.mojom.h"
#include "mojo/services/network/public/interfaces/network_service.mojom.h"
#include "mojo/services/window_manager/public/interfaces/window_manager.mojom.h"
#include "shell/android/android_handler_loader.h"
@@ -92,6 +93,7 @@ struct InternalShellData {
// Proxy to a Window Manager, initialized on the shell thread.
mojo::WindowManagerPtr window_manager;
+ mojo::NativeViewportShellServicePtr native_viewport;
// TaskRunner used to execute tasks on the shell thread.
scoped_refptr<base::SingleThreadTaskRunner> shell_task_runner;
@@ -196,6 +198,16 @@ void ConnectToApplicationImpl(
url, GURL(), services.Pass(), exposed_services.Pass(), base::Closure());
}
+void SendSurfaceAvailable() {
+ if (!g_internal_data.Get().native_viewport.get()) {
+ Context* context = g_internal_data.Get().context.get();
+ context->application_manager()->ConnectToService(
+ GURL("mojo:native_viewport_service"),
+ &g_internal_data.Get().native_viewport);
+ }
+ g_internal_data.Get().native_viewport->NewNativeSurfaceAvailable();
+}
+
void EmbedApplicationByURL(std::string url) {
DCHECK(g_internal_data.Get().shell_task_runner->RunsTasksOnCurrentThread());
if (!g_internal_data.Get().window_manager.get()) {
@@ -335,6 +347,11 @@ static void ConnectToApplication(JNIEnv* env,
mojo::MessagePipeHandle(exposed_services_handle)))));
}
+static void SurfaceAvailable(JNIEnv* env, jclass clazz) {
+ g_internal_data.Get().shell_task_runner->PostTask(
+ FROM_HERE, base::Bind(&SendSurfaceAvailable));
+}
+
bool RegisterShellService(JNIEnv* env) {
return RegisterNativesImpl(env);
}

Powered by Google App Engine
This is Rietveld 408576698