summaryrefslogtreecommitdiffstats
path: root/content/shell
diff options
context:
space:
mode:
authorjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-10 01:50:47 +0000
committerjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-10 01:50:47 +0000
commite08255671738c597992f5067bc52eccf75f1afa1 (patch)
tree53e9a332ca7a1b619dfce059a131361746339414 /content/shell
parent6465bc3aea8a62f0598d5ea16e5efe8272f24dbf (diff)
downloadchromium_src-e08255671738c597992f5067bc52eccf75f1afa1.zip
chromium_src-e08255671738c597992f5067bc52eccf75f1afa1.tar.gz
chromium_src-e08255671738c597992f5067bc52eccf75f1afa1.tar.bz2
Android content shell bringup.
Build media java files (we weren't). Fix adb_install_content_shell for cases where the app was stuck. Add upstream staging gyp var / #define. Be more consistent about jar output files (all in lib.java). Upstream a bunch of random files (e.g. ppapi). Upstream a bunch of java and native code hit as part of shlib init. Properly package jar files in content shell. BUG= TEST= Review URL: https://chromiumcodereview.appspot.com/10377059 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136219 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/shell')
-rw-r--r--content/shell/android/content_shell_apk.xml7
-rw-r--r--content/shell/android/java/org/chromium/content_shell/ContentShellActivity.java32
-rw-r--r--content/shell/android/java/org/chromium/content_shell/ContentShellApplication.java8
-rw-r--r--content/shell/android/shell_library_loader.cc38
4 files changed, 59 insertions, 26 deletions
diff --git a/content/shell/android/content_shell_apk.xml b/content/shell/android/content_shell_apk.xml
index 3e89773b..003380b 100644
--- a/content/shell/android/content_shell_apk.xml
+++ b/content/shell/android/content_shell_apk.xml
@@ -23,6 +23,13 @@
<fileset file="${toolchain.dir}/../../gdbserver"/>
</path>
<property name="native.libs.absolute.dir" location="${out.dir}/libs" />
+ <!-- If your app crashes when referencing java from a different .jar
+ (e.g. java.lang.NoClassDefFoundError:
+ org.chromium.content.browser.CommandLine), And if
+ chromium_content.jar is in fact in your java/libs directory (as
+ placed by a gyp 'cp'), the following line will make sure it
+ gets added to the classes.dex file. -->
+ <property name="out.classes.absolute.dir" location="${jar.libs.dir}" />
<!-- We expect PRODUCT_DIR to be set like the gyp var
(e.g. $ROOT/out/Debug) -->
diff --git a/content/shell/android/java/org/chromium/content_shell/ContentShellActivity.java b/content/shell/android/java/org/chromium/content_shell/ContentShellActivity.java
index a3a1028..ce6ca88 100644
--- a/content/shell/android/java/org/chromium/content_shell/ContentShellActivity.java
+++ b/content/shell/android/java/org/chromium/content_shell/ContentShellActivity.java
@@ -7,11 +7,14 @@ package org.chromium.content_shell;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
+import android.os.Debug;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
+import org.chromium.content.browser.CommandLine;
import org.chromium.content.browser.ContentView;
+import org.chromium.content.browser.LibraryLoader;
/**
* Activity for managing the Content Shell.
@@ -20,6 +23,7 @@ public class ContentShellActivity extends Activity {
private static final String COMMAND_LINE_FILE = "/data/local/content-shell-command-line";
private static final String TAG = "ContentShellActivity";
+ private static final String NATIVE_LIBRARY = "content_shell_content_view";
private ShellManager mShellManager;
@@ -28,17 +32,17 @@ public class ContentShellActivity extends Activity {
super.onCreate(savedInstanceState);
// Initializing the command line must occur before loading the library.
- // TODO(tedchoc): Initialize command line from file.
+ CommandLine.initFromFile(COMMAND_LINE_FILE);
String startupUrl = getUrlFromIntent(getIntent());
if (!TextUtils.isEmpty(startupUrl)) {
- // TODO(tedchoc): Append URL to command line.
+ CommandLine.getInstance().appendSwitchesAndArguments(
+ new String[] {ShellView.sanitizeUrl(startupUrl)});
}
- // TODO(jrg,tedchoc): upstream the async library loader, then
- // make this call look like this:
- // LibraryLoader.loadAndInitSync();
- loadNativeLibrary();
-
+ // TODO(jrg): once command line support is addef (for
+ // --wait-for-debugger), remove this.
+ // Debug.waitForDebugger();
+ LibraryLoader.loadAndInitSync();
initializeContentViewResources();
setContentView(R.layout.content_shell_activity);
@@ -93,18 +97,4 @@ public class ContentShellActivity extends Activity {
ContentView.registerPopupOverlayCornerRadius(0);
ContentView.registerPopupOverlayResourceId(R.drawable.popup_zoomer_overlay);
}
-
-
- private static final String NATIVE_LIBRARY = "content_shell_content_view";
-
- private void loadNativeLibrary() throws UnsatisfiedLinkError {
- Log.i(TAG, "loading: " + NATIVE_LIBRARY);
- try {
- System.loadLibrary(NATIVE_LIBRARY);
- } catch (UnsatisfiedLinkError e) {
- Log.e(TAG, "Unable to load lib" + NATIVE_LIBRARY + ".so: " + e);
- throw e;
- }
- Log.i(TAG, "loaded: " + NATIVE_LIBRARY);
- }
}
diff --git a/content/shell/android/java/org/chromium/content_shell/ContentShellApplication.java b/content/shell/android/java/org/chromium/content_shell/ContentShellApplication.java
index 9f2a0de..56b4cf5 100644
--- a/content/shell/android/java/org/chromium/content_shell/ContentShellApplication.java
+++ b/content/shell/android/java/org/chromium/content_shell/ContentShellApplication.java
@@ -5,16 +5,22 @@
package org.chromium.content_shell;
import android.app.Application;
+import org.chromium.content.browser.LibraryLoader;
/**
* Entry point for the content shell application. Handles initialization of information that needs
* to be shared across the main activity and the sandbox services created.
*/
public class ContentShellApplication extends Application {
+
+ // TODO(jrg): do not downstream this filename!
+ private static final String NATIVE_LIBRARY = "content_shell_content_view";
+
@Override
public void onCreate() {
super.onCreate();
- // TODO(tedchoc): Initialize the .pak files to load and the native library name.
+ // TODO(tedchoc): Initialize the .pak files to load
+ LibraryLoader.setLibraryToLoad(NATIVE_LIBRARY);
}
}
diff --git a/content/shell/android/shell_library_loader.cc b/content/shell/android/shell_library_loader.cc
index e447d7e7..3b6757e 100644
--- a/content/shell/android/shell_library_loader.cc
+++ b/content/shell/android/shell_library_loader.cc
@@ -3,8 +3,11 @@
// found in the LICENSE file.
#include "base/basictypes.h"
+#include "base/debug/debugger.h"
+#include "base/logging.h"
#include "base/android/jni_android.h"
#include "base/android/jni_registrar.h"
+#include "content/public/app/content_main_runner.h"
#include "content/public/browser/android_library_loader_hooks.h"
#include "content/shell/shell_main_delegate.h"
#include "content/shell/android/shell_manager.h"
@@ -15,8 +18,32 @@ static base::android::RegistrationMethod kRegistrationMethods[] = {
{ "ShellView", content::ShellView::Register },
};
+namespace {
+ content::ContentMainRunner* g_content_main_runner = NULL;
+}
+
// This is called by the VM when the shared library is first loaded.
JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
+
+ // Don't call anything in base without initializing it.
+ // ContentMainRunner will do what we need.
+ g_content_main_runner = content::ContentMainRunner::Create();
+
+ // TODO(tedchoc): Set this to the main delegate once the Android specific
+ // browser process initialization gets checked in.
+ ShellMainDelegate* delegate = new ShellMainDelegate();
+
+ // We use a ShellContentClient, created as a member of
+ // ShellMainDelegate and set with a call to
+ // content::SetContentClient() in PreSandboxStartup().
+ // That must be done before ContentMainRunner::Initialize().
+ // TODO(jrg): resolve the upstream/downstream discrepancy; we
+ // shouldn't need to do this.
+ delegate->PreSandboxStartup();
+
+ // TODO(jrg): find command line info from java; pass down in here.
+ g_content_main_runner->Initialize(0, NULL, NULL);
+
base::android::InitVM(vm);
JNIEnv* env = base::android::AttachCurrentThread();
if (!RegisterLibraryLoaderEntryHook(env)) {
@@ -29,9 +56,12 @@ JNI_EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
arraysize(kRegistrationMethods)))
return -1;
- // TODO(tedchoc): Set this to the main delegate once the Android specific
- // browser process initialization gets checked in.
- new ShellMainDelegate();
-
return JNI_VERSION_1_4;
}
+
+
+JNI_EXPORT void JNI_OnUnload(JavaVM* vm, void* reserved) {
+ delete g_content_main_runner;
+ g_content_main_runner = NULL;
+}
+