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

Unified Diff: shell/android/mojo_main.cc

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: Remove spurious print 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
Index: shell/android/mojo_main.cc
diff --git a/shell/android/mojo_main.cc b/shell/android/mojo_main.cc
index dbc01bee44e34efd1d0d64d4e8bb272031c4ede9..b485a4c678decc07df76efdcf6f848c53b707870 100644
--- a/shell/android/mojo_main.cc
+++ b/shell/android/mojo_main.cc
@@ -4,9 +4,9 @@
#include "shell/android/mojo_main.h"
-#include "base/android/command_line_android.h"
#include "base/android/java_handler_thread.h"
#include "base/android/jni_android.h"
+#include "base/android/jni_array.h"
#include "base/android/jni_string.h"
#include "base/at_exit.h"
#include "base/bind.h"
@@ -24,6 +24,7 @@
#include "services/native_viewport/native_viewport_impl.h"
#include "shell/android/android_handler_loader.h"
#include "shell/android/ui_application_loader_android.h"
+#include "shell/command_line_util.h"
#include "shell/context.h"
#include "shell/init.h"
#include "ui/gl/gl_surface_egl.h"
@@ -107,14 +108,11 @@ void ConfigureAndroidServices(Context* context) {
GURL("mojo:android_handler"));
}
-void RunShell(std::vector<GURL> app_urls) {
+void StartShellOnShellThread() {
Context* context = g_context.Pointer()->get();
ConfigureAndroidServices(context);
context->Init();
- for (std::vector<GURL>::const_iterator it = app_urls.begin();
- it != app_urls.end(); ++it) {
- context->Run(*it);
- }
+ RunCommandLineApps(context);
}
} // namespace
@@ -128,10 +126,14 @@ static void Init(JNIEnv* env,
base::android::ScopedJavaLocalRef<jobject> scoped_context(env, context);
base::android::InitApplicationContext(env, scoped_context);
- base::android::InitNativeCommandLineFromJavaArray(env, jparameters);
- base::FilePath mojo_shell_file_path(
+ std::vector<std::string> parameters;
+ parameters.push_back(
base::android::ConvertJavaStringToUTF8(env, mojo_shell_path));
- base::CommandLine::ForCurrentProcess()->SetProgram(mojo_shell_file_path);
+ base::android::AppendJavaStringArrayToStringVector(env, jparameters,
+ &parameters);
+ CommandLine::Init(0, nullptr);
+ base::CommandLine::ForCurrentProcess()->InitFromArgv(parameters);
+
InitializeLogging();
// We want ~MessageLoop to happen prior to ~Context. Initializing
@@ -140,6 +142,10 @@ static void Init(JNIEnv* env,
Context* shell_context = new Context();
shell_context->mojo_url_resolver()->SetLocalAppsPath(base::FilePath(
base::android::ConvertJavaStringToUTF8(env, j_local_apps_directory)));
+ for (auto& args : parameters) {
+ ApplyApplicationArgs(shell_context, args);
+ }
+
g_context.Get().reset(shell_context);
g_java_message_loop.Get().reset(new base::MessageLoopForUI);
@@ -151,22 +157,28 @@ static void Init(JNIEnv* env,
gfx::GLSurface::InitializeOneOff();
}
-static void Start(JNIEnv* env, jclass clazz, jstring jurl) {
- std::vector<GURL> app_urls;
+static jboolean Start(JNIEnv* env, jclass clazz) {
+ if (!base::CommandLine::ForCurrentProcess()->GetArgs().size()) {
sky 2014/12/17 16:44:04 nit: no {}
qsr 2014/12/18 14:21:35 Done.
+ return false;
+ }
+
#if defined(MOJO_SHELL_DEBUG_URL)
- app_urls.push_back(GURL(MOJO_SHELL_DEBUG_URL));
+ base::CommandLine::ForCurrentProcess()->AppendArg(MOJO_SHELL_DEBUG_URL);
// Sleep for 5 seconds to give the debugger a chance to attach.
sleep(5);
-#else
- if (jurl)
- app_urls.push_back(GURL(base::android::ConvertJavaStringToUTF8(env, jurl)));
#endif
g_shell_thread.Get().reset(
new base::android::JavaHandlerThread("shell_thread"));
g_shell_thread.Get()->Start();
g_shell_thread.Get()->message_loop()->PostTask(
- FROM_HERE, base::Bind(&RunShell, app_urls));
+ FROM_HERE, base::Bind(&StartShellOnShellThread));
+ return true;
+}
+
+static void AddApplicationURL(JNIEnv* env, jclass clazz, jstring jurl) {
+ base::CommandLine::ForCurrentProcess()->AppendArg(
+ base::android::ConvertJavaStringToUTF8(env, jurl));
}
bool RegisterMojoMain(JNIEnv* env) {

Powered by Google App Engine
This is Rietveld 408576698