diff options
author | Kristian Monsen <kristianm@google.com> | 2011-07-20 17:39:55 +0100 |
---|---|---|
committer | Kristian Monsen <kristianm@google.com> | 2011-07-28 16:04:55 +0100 |
commit | cecae02673edd6b4cee88a9b87a61055a91f70bb (patch) | |
tree | 30b7d086cc75b92cc13a678903da868b29fc2770 | |
parent | 4ec1b5c8bfb53483c6105db0656c81740f798f10 (diff) | |
download | external_chromium-cecae02673edd6b4cee88a9b87a61055a91f70bb.zip external_chromium-cecae02673edd6b4cee88a9b87a61055a91f70bb.tar.gz external_chromium-cecae02673edd6b4cee88a9b87a61055a91f70bb.tar.bz2 |
Part of fix for 5065047: build libchromium as a shared lib
Linking chromium_net as a static lib.
Needed to update the jni to be handled internally instead
of using the one from webkit it got linked with.
Change-Id: Ia717a29afa879be39835d22faacb6c4810728b53
-rw-r--r-- | Android.mk | 15 | ||||
-rw-r--r-- | android/autofill/url_fetcher_proxy.h | 2 | ||||
-rw-r--r-- | android/jni/autofill_request_url.cc | 4 | ||||
-rw-r--r-- | android/jni/jni_utils.cc | 71 | ||||
-rw-r--r-- | android/jni/jni_utils.h | 7 | ||||
-rw-r--r-- | android/jni/mime_utils.cc | 8 | ||||
-rw-r--r-- | android/jni/platform_file_jni.cc | 24 | ||||
-rw-r--r-- | android/net/android_network_library_impl.cc | 18 | ||||
-rw-r--r-- | android/ui/base/l10n/l10n_util.cc | 10 | ||||
-rw-r--r-- | webkit/glue/form_field.cc | 6 |
10 files changed, 113 insertions, 52 deletions
@@ -11,7 +11,7 @@ include $(CLEAR_VARS) LOCAL_CPP_EXTENSION := .cc LOCAL_MODULE := libchromium_net -LOCAL_MODULE_CLASS := STATIC_LIBRARIES +LOCAL_MODULE_CLASS := SHARED_LIBRARIES INTERMEDIATES := $(call local-intermediates-dir) LOCAL_SRC_FILES := \ @@ -32,6 +32,7 @@ LOCAL_SRC_FILES := \ googleurl/src/url_parse_file.cc \ googleurl/src/url_util.cc \ \ + android/content/common/url_constants.cc \ android/execinfo.cc \ android/jni/autofill_request_url.cc \ android/jni/mime_utils.cc \ @@ -47,6 +48,7 @@ LOCAL_SRC_FILES := \ \ base/at_exit.cc \ base/base64.cc \ + base/environment.cc \ base/file_descriptor_shuffle.cc \ base/file_path.cc \ base/file_util.cc \ @@ -65,6 +67,7 @@ LOCAL_SRC_FILES := \ base/pickle.cc \ base/platform_file.cc \ base/platform_file_posix.cc \ + base/process_posix.cc \ base/process_util.cc \ base/process_util_linux.cc \ base/process_util_posix.cc \ @@ -393,7 +396,8 @@ LOCAL_SRC_FILES += \ third_party/libjingle/source/talk/xmllite/xmlparser.cc \ third_party/libjingle/source/talk/xmllite/xmlprinter.cc \ \ - webkit/glue/form_data.cc + webkit/glue/form_data.cc \ + webkit/glue/form_field.cc LOCAL_C_INCLUDES := \ $(LOCAL_PATH) \ @@ -455,7 +459,7 @@ $(GEN): perl $(SCRIPT) $@ "public/WebString.h" LOCAL_GENERATED_SOURCES += $(GEN) -LOCAL_CFLAGS := -DHAVE_CONFIG_H -DANDROID -fvisibility=hidden -DEXPAT_RELATIVE_PATH -DALLOW_QUOTED_COOKIE_VALUES +LOCAL_CFLAGS := -DHAVE_CONFIG_H -DANDROID -DEXPAT_RELATIVE_PATH -DALLOW_QUOTED_COOKIE_VALUES LOCAL_CPPFLAGS := -Wno-sign-promo -Wno-missing-field-initializers # Just a few definitions not provided by bionic. @@ -467,9 +471,10 @@ LOCAL_C_INCLUDES := \ $(LOCAL_PATH)/android \ $(LOCAL_C_INCLUDES) -LOCAL_WHOLE_STATIC_LIBRARIES += libevent libprotobuf-cpp-2.3.0-lite modp_b64 dmg_fp +LOCAL_WHOLE_STATIC_LIBRARIES += libevent modp_b64 dmg_fp libcutils +LOCAL_SHARED_LIBRARIES = libstlport libexpat libcrypto libssl libz libicuuc libicui18n libsqlite libcutils libdl # Including this will modify the include path include external/stlport/libstlport.mk -include $(BUILD_STATIC_LIBRARY) +include $(BUILD_SHARED_LIBRARY) diff --git a/android/autofill/url_fetcher_proxy.h b/android/autofill/url_fetcher_proxy.h index 5649448..cbf1cad 100644 --- a/android/autofill/url_fetcher_proxy.h +++ b/android/autofill/url_fetcher_proxy.h @@ -118,7 +118,7 @@ public: cookies_ = cookies; data_ = data; pending_callbacks_[this] = true; - MainThreadProxy::CallOnMainThread(DoComplete, this); + DoComplete(this); } net::HttpResponseHeaders* response_headers() const {return real_fetcher_->response_headers();}; diff --git a/android/jni/autofill_request_url.cc b/android/jni/autofill_request_url.cc index e272798..084ac88 100644 --- a/android/jni/autofill_request_url.cc +++ b/android/jni/autofill_request_url.cc @@ -8,11 +8,11 @@ namespace android { std::string AutofillRequestUrl::GetQueryUrl() { - JNIEnv* env = android::GetJNIEnv(); + JNIEnv* env = android::jni::GetJNIEnv(); jclass bridgeClass = env->FindClass("android/webkit/JniUtil"); jmethodID method = env->GetStaticMethodID(bridgeClass, "getAutofillQueryUrl", "()Ljava/lang/String;"); jstring autofill_query_url = static_cast<jstring>(env->CallStaticObjectMethod(bridgeClass, method)); - std::string request_url = android::JstringToStdString(env, autofill_query_url); + std::string request_url = android::jni::JstringToStdString(env, autofill_query_url); env->DeleteLocalRef(autofill_query_url); env->DeleteLocalRef(bridgeClass); diff --git a/android/jni/jni_utils.cc b/android/jni/jni_utils.cc index 91e5266..7f97d47 100644 --- a/android/jni/jni_utils.cc +++ b/android/jni/jni_utils.cc @@ -3,32 +3,68 @@ // found in the LICENSE file. #include "android/jni/jni_utils.h" +#include "base/logging.h" +#include "base/utf_string_conversions.h" +#include "jni.h" -// We currently delegate our implementation to WebKit, as WebKit controls the -// JNI startup process. However, we can't #include relevant headers because they -// require many extra include paths and #defines that clash with our existing -// ones. So we forward-declare the methods instead. -// TODO: Disentangle Android JNI from WebKit. +namespace { +JavaVM* sVM; -// JNIUtility.h -namespace JSC { -namespace Bindings { -JNIEnv* getJNIEnv(); -JavaVM* getJavaVM(); +JavaVM* getJavaVM() { + return sVM; } } -// WebCoreJni.h namespace android { -std::string jstringToStdString(JNIEnv* env, jstring jstr); -string16 jstringToString16(JNIEnv* env, jstring jstr); -bool checkException(JNIEnv*); +namespace jni { + +void SetJavaVM(JavaVM* vm) { + sVM = vm; } -namespace android { +bool checkException(JNIEnv* env) +{ + if (env->ExceptionCheck() != 0) + { + LOG(ERROR) << "*** Uncaught exception returned from Java call!\n"; + env->ExceptionDescribe(); + return true; + } + return false; +} + +string16 jstringToString16(JNIEnv* env, jstring jstr) +{ + if (!jstr || !env) + return string16(); + + const char* s = env->GetStringUTFChars(jstr, 0); + if (!s) + return string16(); + string16 str = UTF8ToUTF16(s); + env->ReleaseStringUTFChars(jstr, s); + checkException(env); + return str; +} + +std::string jstringToStdString(JNIEnv* env, jstring jstr) +{ + if (!jstr || !env) + return std::string(); + + const char* s = env->GetStringUTFChars(jstr, 0); + if (!s) + return std::string(); + std::string str(s); + env->ReleaseStringUTFChars(jstr, s); + checkException(env); + return str; +} JNIEnv* GetJNIEnv() { - return JSC::Bindings::getJNIEnv(); + JNIEnv* env; + getJavaVM()->AttachCurrentThread(&env, NULL); + return env; } std::string JstringToStdString(JNIEnv* env, jstring jstr) { @@ -52,9 +88,10 @@ jstring ConvertUTF8ToJavaString(JNIEnv* env, std::string str) void DetachFromVM() { - JavaVM* vm = JSC::Bindings::getJavaVM(); + JavaVM* vm = getJavaVM(); vm->DetachCurrentThread(); } +} // namespace jni } // namespace android diff --git a/android/jni/jni_utils.h b/android/jni/jni_utils.h index 60d7cde..b4141f8 100644 --- a/android/jni/jni_utils.h +++ b/android/jni/jni_utils.h @@ -1,3 +1,4 @@ + // Copyright (c) 2010 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. @@ -9,6 +10,10 @@ namespace android { +namespace jni { // To avoid name conflict with similar functions in webkit + +void SetJavaVM(JavaVM* vm); + // Get the JNI environment for the current thread. JNIEnv* GetJNIEnv(); @@ -23,5 +28,7 @@ bool CheckException(JNIEnv*); void DetachFromVM(); +} // namespace jni + } // namespace android diff --git a/android/jni/mime_utils.cc b/android/jni/mime_utils.cc index 9181eb2..3dc71f7 100644 --- a/android/jni/mime_utils.cc +++ b/android/jni/mime_utils.cc @@ -32,13 +32,13 @@ namespace android { bool MimeUtils::GuessMimeTypeFromExtension(const std::string& extension, std::string* result) { - JNIEnv* env = GetJNIEnv(); + JNIEnv* env = jni::GetJNIEnv(); jstring jExtension = env->NewStringUTF(extension.c_str()); jobject jResult = env->CallStaticObjectMethod( get_class(env), guess_mime_type_from_extension(env), jExtension); env->DeleteLocalRef(jExtension); if (jResult) { - *result = JstringToStdString(env, static_cast<jstring>(jResult)); + *result = jni::JstringToStdString(env, static_cast<jstring>(jResult)); env->DeleteLocalRef(jResult); } return jResult; @@ -46,13 +46,13 @@ bool MimeUtils::GuessMimeTypeFromExtension(const std::string& extension, bool MimeUtils::GuessExtensionFromMimeType(const std::string& mimeType, std::string* result) { - JNIEnv* env = GetJNIEnv(); + JNIEnv* env = jni::GetJNIEnv(); jstring jMimeType = env->NewStringUTF(mimeType.c_str()); jobject jResult = env->CallStaticObjectMethod( get_class(env), guess_extension_from_mime_type(env), jMimeType); env->DeleteLocalRef(jMimeType); if (jResult) { - *result = JstringToStdString(env, static_cast<jstring>(jResult)); + *result = jni::JstringToStdString(env, static_cast<jstring>(jResult)); env->DeleteLocalRef(jResult); } return jResult; diff --git a/android/jni/platform_file_jni.cc b/android/jni/platform_file_jni.cc index d713d23..e1916e3 100644 --- a/android/jni/platform_file_jni.cc +++ b/android/jni/platform_file_jni.cc @@ -10,7 +10,7 @@ namespace android { JavaISWrapper::JavaISWrapper(const FilePath& path) { - JNIEnv* env = GetJNIEnv(); + JNIEnv* env = jni::GetJNIEnv(); jclass inputStreamClass = env->FindClass("java/io/InputStream"); m_read = env->GetMethodID(inputStreamClass, "read", "([B)I"); m_close = env->GetMethodID(inputStreamClass, "close", "()V"); @@ -23,24 +23,24 @@ JavaISWrapper::JavaISWrapper(const FilePath& path) { m_inputStream = env->NewGlobalRef(env->CallStaticObjectMethod( bridgeClass, method, - ConvertUTF8ToJavaString(env, path.value()))); + jni::ConvertUTF8ToJavaString(env, path.value()))); env->DeleteLocalRef(bridgeClass); env->DeleteLocalRef(inputStreamClass); } JavaISWrapper::~JavaISWrapper() { - JNIEnv* env = GetJNIEnv(); + JNIEnv* env = jni::GetJNIEnv(); env->CallVoidMethod(m_inputStream, m_close); - CheckException(env); + jni::CheckException(env); env->DeleteGlobalRef(m_inputStream); } int JavaISWrapper::Read(char* out, int length) { - JNIEnv* env = GetJNIEnv(); + JNIEnv* env = jni::GetJNIEnv(); jbyteArray buffer = env->NewByteArray(length); int size = (int) env->CallIntMethod(m_inputStream, m_read, buffer); - if (CheckException(env) || size < 0) { + if (jni::CheckException(env) || size < 0) { env->DeleteLocalRef(buffer); return 0; } @@ -51,10 +51,16 @@ int JavaISWrapper::Read(char* out, int length) { } uint64 contentUrlSize(const FilePath& name) { - JNIEnv* env = GetJNIEnv(); + JNIEnv* env = jni::GetJNIEnv(); jclass bridgeClass = env->FindClass("android/webkit/JniUtil"); - jmethodID method = env->GetStaticMethodID(bridgeClass, "contentUrlSize", "(Ljava/lang/String;)J"); - jlong length = env->CallStaticLongMethod(bridgeClass, method, ConvertUTF8ToJavaString(env, name.value())); + jmethodID method = env->GetStaticMethodID( + bridgeClass, + "contentUrlSize", + "(Ljava/lang/String;)J"); + jlong length = env->CallStaticLongMethod( + bridgeClass, + method, + jni::ConvertUTF8ToJavaString(env, name.value())); env->DeleteLocalRef(bridgeClass); return static_cast<uint64>(length); diff --git a/android/net/android_network_library_impl.cc b/android/net/android_network_library_impl.cc index 8f000f1..1989621 100644 --- a/android/net/android_network_library_impl.cc +++ b/android/net/android_network_library_impl.cc @@ -56,13 +56,13 @@ AndroidNetworkLibraryImpl::VerifyResult if (!cert_verifier_class_) return VERIFY_INVOCATION_ERROR; - JNIEnv* env = GetJNIEnv(); + JNIEnv* env = jni::GetJNIEnv(); DCHECK(env); static jmethodID verify_fn = env->GetStaticMethodID( cert_verifier_class_, "verifyServerCertificates", "([[BLjava/lang/String;Ljava/lang/String;)Landroid/net/http/SslError;"); - if (CheckException(env)) { + if (jni::CheckException(env)) { LOG(ERROR) << "verifyServerCertificates method not found; skipping"; return VERIFY_INVOCATION_ERROR; } @@ -72,9 +72,9 @@ AndroidNetworkLibraryImpl::VerifyResult if (!chain_byte_array) return VERIFY_INVOCATION_ERROR; - jstring host_string = ConvertUTF8ToJavaString(env, hostname); + jstring host_string = jni::ConvertUTF8ToJavaString(env, hostname); DCHECK(host_string); - jstring auth_string = ConvertUTF8ToJavaString(env, auth_type); + jstring auth_string = jni::ConvertUTF8ToJavaString(env, auth_type); DCHECK(auth_string); jobject error = env->CallStaticObjectMethod(cert_verifier_class_, verify_fn, @@ -85,7 +85,7 @@ AndroidNetworkLibraryImpl::VerifyResult env->DeleteLocalRef(auth_string); VerifyResult result = VERIFY_INVOCATION_ERROR; - if (!CheckException(env)) { + if (!jni::CheckException(env)) { if (!error) { result = VERIFY_OK; } else { @@ -95,7 +95,7 @@ AndroidNetworkLibraryImpl::VerifyResult "getPrimaryError", "()I"); if (error_fn) { int code = env->CallIntMethod(error, error_fn); - if (!CheckException(env)) { + if (!jni::CheckException(env)) { if (code == 2) { // SSL_IDMISMATCH == 2 result = VERIFY_BAD_HOSTNAME; } else if (code == 3) { // SSL_UNTRUSTED == 3 @@ -111,7 +111,7 @@ AndroidNetworkLibraryImpl::VerifyResult // may shutdown at anytime. However this assumption should not be baked in // here: another user of the function may not want to have their thread // detached at this point. - DetachFromVM(); + jni::DetachFromVM(); return result; } @@ -128,7 +128,7 @@ void AndroidNetworkLibraryImpl::InitWithApplicationContext(JNIEnv* env, AndroidNetworkLibraryImpl::AndroidNetworkLibraryImpl(JNIEnv* env) : cert_verifier_class_(NULL) { jclass cls = env->FindClass(kClassPathName); - if (CheckException(env) || !cls) { + if (jni::CheckException(env) || !cls) { NOTREACHED() << "Unable to load class " << kClassPathName; } else { cert_verifier_class_ = static_cast<jclass>(env->NewGlobalRef(cls)); @@ -138,6 +138,6 @@ AndroidNetworkLibraryImpl::AndroidNetworkLibraryImpl(JNIEnv* env) AndroidNetworkLibraryImpl::~AndroidNetworkLibraryImpl() { if (cert_verifier_class_) - GetJNIEnv()->DeleteGlobalRef(cert_verifier_class_); + jni::GetJNIEnv()->DeleteGlobalRef(cert_verifier_class_); } diff --git a/android/ui/base/l10n/l10n_util.cc b/android/ui/base/l10n/l10n_util.cc index 93217be..3a91174 100644 --- a/android/ui/base/l10n/l10n_util.cc +++ b/android/ui/base/l10n/l10n_util.cc @@ -54,7 +54,7 @@ JNIHelper::JNIHelper() JNIHelper::~JNIHelper() { - JNIEnv* currentEnv = android::GetJNIEnv(); + JNIEnv* currentEnv = android::jni::GetJNIEnv(); if (currentEnv) currentEnv->DeleteGlobalRef(mClassRef); } @@ -62,7 +62,7 @@ JNIHelper::~JNIHelper() string16 JNIHelper::getLocalisedString(int message_id) { android::Mutex::Autolock lock(mGetStringLock); - JNIEnv* env = android::GetJNIEnv(); + JNIEnv* env = android::jni::GetJNIEnv(); if (!mInited) { jclass localClass = env->FindClass("android/webkit/L10nUtils"); mClassRef = static_cast<jclass>(env->NewGlobalRef(localClass)); @@ -72,7 +72,7 @@ string16 JNIHelper::getLocalisedString(int message_id) static jmethodID getLocalisedString = env->GetStaticMethodID(mClassRef, "getLocalisedString", "(I)Ljava/lang/String;"); jstring result = static_cast<jstring>(env->CallStaticObjectMethod(mClassRef, getLocalisedString, message_id)); - string16 str = android::JstringToString16(env, result); + string16 str = android::jni::JstringToString16(env, result); env->DeleteLocalRef(result); return str; } @@ -96,13 +96,13 @@ string16 GetStringFUTF16(int message_id, const string16& a, const string16& b, c std::string GetApplicationLocale() { - JNIEnv* env = android::GetJNIEnv(); + JNIEnv* env = android::jni::GetJNIEnv(); jclass locale_class = env->FindClass("java/util/Locale"); jmethodID get_default_locale = env->GetStaticMethodID(locale_class, "getDefault", "()Ljava/util/Locale;"); jmethodID to_string = env->GetMethodID(locale_class, "toString", "()Ljava/lang/String;"); jobject locale_jobj = env->CallStaticObjectMethod(locale_class, get_default_locale); jstring locale_jstr = static_cast<jstring>(env->CallObjectMethod(locale_jobj, to_string)); - std::string locale = android::JstringToStdString(env, locale_jstr); + std::string locale = android::jni::JstringToStdString(env, locale_jstr); env->DeleteLocalRef(locale_jstr); env->DeleteLocalRef(locale_jobj); env->DeleteLocalRef(locale_class); diff --git a/webkit/glue/form_field.cc b/webkit/glue/form_field.cc index 0de8446..619d47e 100644 --- a/webkit/glue/form_field.cc +++ b/webkit/glue/form_field.cc @@ -6,16 +6,20 @@ #include "base/string_util.h" #include "base/utf_string_conversions.h" +#ifndef ANDROID #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebOptionElement.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebSelectElement.h" +#endif +#ifndef ANDROID using WebKit::WebFormControlElement; using WebKit::WebElement; using WebKit::WebInputElement; using WebKit::WebOptionElement; using WebKit::WebSelectElement; using WebKit::WebVector; +#endif namespace webkit_glue { @@ -24,6 +28,7 @@ FormField::FormField() is_autofilled(false) { } +#ifndef ANDROID // TODO(jhawkins): This constructor should probably be deprecated and the // functionality moved to FormManager. FormField::FormField(WebFormControlElement element) @@ -56,6 +61,7 @@ FormField::FormField(WebFormControlElement element) TrimWhitespace(value, TRIM_LEADING, &value); } +#endif FormField::FormField(const string16& label, const string16& name, |