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

Unified Diff: shell/android/apk/src/org/chromium/mojo_shell_apk/MojoShellActivity.java

Issue 816473002: Update mojo shell so that --args-for can be used on android (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Follow review Created 6 years 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
« no previous file with comments | « shell/android/apk/src/org/chromium/mojo_shell_apk/MojoMain.java ('k') | shell/android/mojo_main.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: shell/android/apk/src/org/chromium/mojo_shell_apk/MojoShellActivity.java
diff --git a/shell/android/apk/src/org/chromium/mojo_shell_apk/MojoShellActivity.java b/shell/android/apk/src/org/chromium/mojo_shell_apk/MojoShellActivity.java
index 66e8565855f466f05f460d60b3540b3d5aac5ea5..857805827e746df43a95cf94732efc224dd66e1c 100644
--- a/shell/android/apk/src/org/chromium/mojo_shell_apk/MojoShellActivity.java
+++ b/shell/android/apk/src/org/chromium/mojo_shell_apk/MojoShellActivity.java
@@ -22,8 +22,18 @@ public class MojoShellActivity extends Activity {
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- String appUrl = getUrlFromIntent(getIntent());
- if (appUrl == null) {
+ // TODO(ppi): Gotcha - the call below will work only once per process lifetime, but the OS
+ // has no obligation to kill the application process between destroying and restarting the
+ // activity. If the application process is kept alive, initialization parameters sent with
+ // the intent will be stale.
+ // TODO(qsr): We should be passing application context here as required by
+ // InitApplicationContext on the native side. Currently we can't, as PlatformViewportAndroid
+ // relies on this being the activity context.
+ MojoMain.ensureInitialized(this, getParametersFromIntent(getIntent()));
+
+ if (MojoMain.start()) {
+ Log.i(TAG, "Mojo started");
+ } else {
Log.i(TAG, "No URL provided via intent, prompting user...");
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("Enter a URL");
@@ -34,33 +44,19 @@ public class MojoShellActivity extends Activity {
@Override
public void onClick(DialogInterface dialog, int button) {
String url = input.getText().toString();
- startWithURL(url);
+ MojoMain.addApplicationURL(url);
+ MojoMain.start();
+ Log.i(TAG, "Mojo started");
}
});
alert.show();
- } else {
- startWithURL(appUrl);
}
}
- private static String getUrlFromIntent(Intent intent) {
- return intent != null ? intent.getDataString() : null;
- }
-
private static String[] getParametersFromIntent(Intent intent) {
return intent != null ? intent.getStringArrayExtra("parameters") : null;
}
private void startWithURL(String url) {
- // TODO(ppi): Gotcha - the call below will work only once per process lifetime, but the OS
- // has no obligation to kill the application process between destroying and restarting the
- // activity. If the application process is kept alive, initialization parameters sent with
- // the intent will be stale.
- // TODO(qsr): We should be passing application context here as required by
- // InitApplicationContext on the native side. Currently we can't, as PlatformViewportAndroid
- // relies on this being the activity context.
- MojoMain.ensureInitialized(this, getParametersFromIntent(getIntent()));
- MojoMain.start(url);
- Log.i(TAG, "Mojo started: " + url);
}
}
« no previous file with comments | « shell/android/apk/src/org/chromium/mojo_shell_apk/MojoMain.java ('k') | shell/android/mojo_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698