diff options
Diffstat (limited to 'WebKit/android/jni')
-rw-r--r-- | WebKit/android/jni/WebCoreJni.cpp | 16 | ||||
-rw-r--r-- | WebKit/android/jni/WebCoreJni.h | 5 | ||||
-rw-r--r-- | WebKit/android/jni/WebSettings.cpp | 42 |
3 files changed, 59 insertions, 4 deletions
diff --git a/WebKit/android/jni/WebCoreJni.cpp b/WebKit/android/jni/WebCoreJni.cpp index a785f41..dd15971 100644 --- a/WebKit/android/jni/WebCoreJni.cpp +++ b/WebKit/android/jni/WebCoreJni.cpp @@ -71,4 +71,20 @@ WTF::String to_string(JNIEnv* env, jstring str) return ret; } +#if USE(CHROME_NETWORK_STACK) +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; +} +#endif + } diff --git a/WebKit/android/jni/WebCoreJni.h b/WebKit/android/jni/WebCoreJni.h index 96ee291..95bdaa0 100644 --- a/WebKit/android/jni/WebCoreJni.h +++ b/WebKit/android/jni/WebCoreJni.h @@ -26,6 +26,7 @@ #ifndef ANDROID_WEBKIT_WEBCOREJNI_H #define ANDROID_WEBKIT_WEBCOREJNI_H +#include "ChromiumIncludes.h" #include "PlatformString.h" #include <jni.h> @@ -72,6 +73,10 @@ bool checkException(JNIEnv* env); // Create a WTF::String object from a jstring object. WTF::String to_string(JNIEnv* env, jstring str); +#if USE(CHROME_NETWORK_STACK) +string16 jstringToString16(JNIEnv* env, jstring jstr); +#endif + } #endif diff --git a/WebKit/android/jni/WebSettings.cpp b/WebKit/android/jni/WebSettings.cpp index 79c4017..f75cf9a 100644 --- a/WebKit/android/jni/WebSettings.cpp +++ b/WebKit/android/jni/WebSettings.cpp @@ -31,6 +31,7 @@ #include "ApplicationCacheStorage.h" #include "BitmapAllocatorAndroid.h" #include "CachedResourceLoader.h" +#include "ChromiumIncludes.h" #include "DatabaseTracker.h" #include "Database.h" #include "Document.h" @@ -126,6 +127,10 @@ struct FieldIds { mPageCacheCapacity = env->GetFieldID(clazz, "mPageCacheCapacity", "I"); #if ENABLE(WEB_AUTOFILL) mAutoFillEnabled = env->GetFieldID(clazz, "mAutoFillEnabled", "Z"); + mAutoFillProfile = env->GetFieldID(clazz, "mAutoFillProfile", "Landroid/webkit/WebSettings$AutoFillProfile;"); + jclass autoFillProfileClass = env->FindClass("android/webkit/WebSettings$AutoFillProfile"); + mAutoFillProfileFullName = env->GetFieldID(autoFillProfileClass, "mFullName", "Ljava/lang/String;"); + mAutoFillProfileEmailAddress = env->GetFieldID(autoFillProfileClass, "mEmailAddress", "Ljava/lang/String;"); #endif LOG_ASSERT(mLayoutAlgorithm, "Could not find field mLayoutAlgorithm"); @@ -235,6 +240,9 @@ struct FieldIds { #endif #if ENABLE(WEB_AUTOFILL) jfieldID mAutoFillEnabled; + jfieldID mAutoFillProfile; + jfieldID mAutoFillProfileFullName; + jfieldID mAutoFillProfileEmailAddress; #endif }; @@ -252,6 +260,25 @@ static void recursiveCleanupForFullLayout(WebCore::RenderObject* obj) recursiveCleanupForFullLayout(n); } +#if ENABLE(WEB_AUTOFILL) +void syncAutoFillProfile(JNIEnv* env, jobject autoFillProfile, WebAutoFill* webAutoFill) +{ + jstring str; + string16 fullName; + string16 emailAddress; + + str = static_cast<jstring>(env->GetObjectField(autoFillProfile, gFieldIds->mAutoFillProfileFullName)); + if (str) + fullName = jstringToString16(env, str); + + str = static_cast<jstring>(env->GetObjectField(autoFillProfile, gFieldIds->mAutoFillProfileEmailAddress)); + if (str) + emailAddress = jstringToString16(env, str); + + webAutoFill->setProfile(fullName, emailAddress); +} +#endif + class WebSettings { public: static void Sync(JNIEnv* env, jobject obj, jint frame) @@ -454,14 +481,21 @@ public: // for forms. bool oldAutoFillSetting = s->autoFillEnabled(); s->setAutoFillEnabled(flag); - if (!oldAutoFillSetting && flag) { - EditorClientAndroid* editorC = static_cast<EditorClientAndroid*>(pFrame->page()->editorClient()); - editorC->getAutoFill()->searchDocument(pFrame->document()); - } + + EditorClientAndroid* editorC = static_cast<EditorClientAndroid*>(pFrame->page()->editorClient()); + WebAutoFill* webAutoFill = editorC->getAutoFill(); + if (!oldAutoFillSetting && flag) + webAutoFill->searchDocument(pFrame->document()); + + // Set the active AutoFillProfile data. + jobject autoFillProfile = env->GetObjectField(obj, gFieldIds->mAutoFillProfile); + if (autoFillProfile) + syncAutoFillProfile(env, autoFillProfile, webAutoFill); #endif } }; + //------------------------------------------------------------- // JNI registration //------------------------------------------------------------- |