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

Unified Diff: shell/android/apk/src/org/chromium/mojo/shell/NativeViewportSupportApplicationDelegate.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: shell/android/apk/src/org/chromium/mojo/shell/NativeViewportSupportApplicationDelegate.java
diff --git a/shell/android/apk/src/org/chromium/mojo/shell/NativeViewportSupportApplicationDelegate.java b/shell/android/apk/src/org/chromium/mojo/shell/NativeViewportSupportApplicationDelegate.java
new file mode 100644
index 0000000000000000000000000000000000000000..e3f12745427a296bb785d6e82b3da6c03c30978e
--- /dev/null
+++ b/shell/android/apk/src/org/chromium/mojo/shell/NativeViewportSupportApplicationDelegate.java
@@ -0,0 +1,75 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.mojo.shell;
+
+import android.content.Context;
+import android.content.Intent;
+
+import org.chromium.base.ApplicationStatus;
+import org.chromium.mojo.application.ApplicationConnection;
+import org.chromium.mojo.application.ApplicationDelegate;
+import org.chromium.mojo.application.ServiceFactoryBinder;
+import org.chromium.mojo.bindings.InterfaceRequest;
+import org.chromium.mojo.system.MojoException;
+import org.chromium.mojom.mojo.Shell;
+import org.chromium.mojom.native_viewport.NativeViewportShellService;
+
+final class NativeViewportSupportApplicationDelegate implements ApplicationDelegate {
+ private class NativeViewportShellServiceFactoryBinder
+ implements ServiceFactoryBinder<NativeViewportShellService> {
+ @Override
+ public void bind(InterfaceRequest<NativeViewportShellService> request) {
+ NativeViewportShellService.MANAGER.bind(new NativeViewportShellServiceImpl(), request);
+ }
+
+ @Override
+ public String getInterfaceName() {
+ return NativeViewportShellService.MANAGER.getName();
+ }
+ }
+
+ private class NativeViewportShellServiceImpl implements NativeViewportShellService {
+ @Override
+ public void close() {}
+
+ @Override
+ public void onConnectionError(MojoException e) {}
+
+ @Override
+ public void createNewNativeWindow() {
+ Context context = ApplicationStatus.getApplicationContext();
+ 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);
+ }
+ }
+
+ /**
+ * @see ApplicationDelegate#initialize(Shell, String[], String)
+ */
+ @Override
+ public void initialize(Shell shell, String[] args, String url) {}
+
+ /**
+ * @see ApplicationDelegate#configureIncomingConnection(ApplicationConnection)
+ */
+ @Override
+ public boolean configureIncomingConnection(ApplicationConnection connection) {
+ if (!connection.getRequestorUrl().equals("mojo://native_viewport_service/")) {
+ return false;
+ }
+ connection.addService(new NativeViewportShellServiceFactoryBinder());
+ return true;
+ }
+
+ /**
+ * @see ApplicationDelegate#quit()
+ */
+ @Override
+ public void quit() {}
+}

Powered by Google App Engine
This is Rietveld 408576698