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

Unified Diff: shell/android/apk/src/org/chromium/mojo/shell/ViewportActivity.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/ViewportActivity.java
diff --git a/shell/android/apk/src/org/chromium/mojo/shell/ViewportActivity.java b/shell/android/apk/src/org/chromium/mojo/shell/ViewportActivity.java
new file mode 100644
index 0000000000000000000000000000000000000000..f356e209a442ee52ca70a8f1ba8c76b7f22f796f
--- /dev/null
+++ b/shell/android/apk/src/org/chromium/mojo/shell/ViewportActivity.java
@@ -0,0 +1,57 @@
+// 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.app.Activity;
+import android.app.UiModeManager;
+import android.content.Intent;
+import android.content.res.Configuration;
+import android.os.Bundle;
+import android.view.WindowManager;
+
+import org.chromium.mojo.PlatformViewportAndroid;
+
+/**
+ * Activity for displaying on the screen from the NativeViewportService.
+ */
+public class ViewportActivity extends Activity {
+ private static final String TAG = "ViewportActivity";
+ private PlatformViewportAndroid mPlatformViewport;
+
+ @Override
+ protected void onCreate(final Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ if (!PlatformViewportAndroid.newActivityStarted(this)) {
+ // We have not attached to a viewport, so there's no point continuing.
+ finishAndRemoveTask();
+ }
+
+ // TODO(tonyg): Watch activities go back to the home screen within a
+ // couple of seconds of detaching from adb. So for demonstration purposes,
+ // we just keep the screen on. Eventually we'll want a solution for
+ // allowing the screen to sleep without quitting the shell.
+ // TODO(etiennej): Verify the above is still true after the switch to a Service model.
+ UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE);
+ if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_WATCH) {
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
+ }
+ }
+
+ @Override
+ public void onNewIntent(Intent intent) {
+ super.onNewIntent(intent);
+ new RuntimeException("This activity instance should only ever receive one intent.");
+ }
+
+ /**
+ * @see Activity#onActivityResult(int, int, Intent)
+ * TODO(etiennej): Fix by changing IntentReceiverService into an Activity.
+ */
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ IntentReceiverRegistry.getInstance().onActivityResult(requestCode, resultCode, data);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698