summaryrefslogtreecommitdiffstats
path: root/WebKit/android/jni/WebSettings.cpp
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2010-10-06 14:34:04 +0100
committerBen Murdoch <benm@google.com>2010-10-13 12:01:11 +0100
commit81feb0e216184fe2c8d13ef52dd678925cc4ad77 (patch)
tree412ce15f250931476a324166b1a847c47f45218a /WebKit/android/jni/WebSettings.cpp
parent0a12879c6b8ddf8b2b27629dfd999cedd9589959 (diff)
downloadexternal_webkit-81feb0e216184fe2c8d13ef52dd678925cc4ad77.zip
external_webkit-81feb0e216184fe2c8d13ef52dd678925cc4ad77.tar.gz
external_webkit-81feb0e216184fe2c8d13ef52dd678925cc4ad77.tar.bz2
Sync autofill profile data from java.
Add the JNI bindings so that we can get the AutoFill profile data that the user entered in the Browser UI and inject that data into the WebAutoFill object. This eliminates the John Smith profile! Note that additional profile data such as addresses and phone numbers will be added very shortly. Requires a corresponding change to frameworks/base, see https://android-git.corp.google.com/g/#change,72204 Change-Id: Ie32100123ef0d868e1f7efb5604c6fac48725967
Diffstat (limited to 'WebKit/android/jni/WebSettings.cpp')
-rw-r--r--WebKit/android/jni/WebSettings.cpp42
1 files changed, 38 insertions, 4 deletions
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
//-------------------------------------------------------------