diff options
-rw-r--r-- | WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp | 12 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/autofill/WebAutoFill.h | 4 | ||||
-rw-r--r-- | WebKit/android/jni/WebSettings.cpp | 47 |
3 files changed, 48 insertions, 15 deletions
diff --git a/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp b/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp index ce0a455..4774778 100644 --- a/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp +++ b/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp @@ -167,13 +167,23 @@ bool WebAutoFill::enabled() const return page ? page->settings()->autoFillEnabled() : false; } -void WebAutoFill::setProfile(const string16& fullName, const string16& emailAddress) +void WebAutoFill::setProfile(const string16& fullName, const string16& emailAddress, const string16& companyName, const string16& addressLine1, + const string16& addressLine2, const string16& city, const string16& state, const string16& zipCode, + const string16& country, const string16& phoneNumber) { AutoFillProfile autoFillProfile; // Constants for AutoFill field types are found in external/chromium/chrome/browser/autofill/field_types.h. autoFillProfile.SetInfo(AutoFillType(NAME_FULL), fullName); autoFillProfile.SetInfo(AutoFillType(EMAIL_ADDRESS), emailAddress); + autoFillProfile.SetInfo(AutoFillType(COMPANY_NAME), companyName); + autoFillProfile.SetInfo(AutoFillType(ADDRESS_HOME_LINE1), addressLine1); + autoFillProfile.SetInfo(AutoFillType(ADDRESS_HOME_LINE2), addressLine2); + autoFillProfile.SetInfo(AutoFillType(ADDRESS_HOME_CITY), city); + autoFillProfile.SetInfo(AutoFillType(ADDRESS_HOME_STATE), state); + autoFillProfile.SetInfo(AutoFillType(ADDRESS_HOME_ZIP), zipCode); + autoFillProfile.SetInfo(AutoFillType(ADDRESS_HOME_COUNTRY), country); + autoFillProfile.SetInfo(AutoFillType(PHONE_HOME_WHOLE_NUMBER), phoneNumber); std::vector<AutoFillProfile> profiles; profiles.push_back(autoFillProfile); diff --git a/WebKit/android/WebCoreSupport/autofill/WebAutoFill.h b/WebKit/android/WebCoreSupport/autofill/WebAutoFill.h index fabd3bf..140fdc0 100644 --- a/WebKit/android/WebCoreSupport/autofill/WebAutoFill.h +++ b/WebKit/android/WebCoreSupport/autofill/WebAutoFill.h @@ -63,7 +63,9 @@ public: void setWebViewCore(WebViewCore* webViewCore) { mWebViewCore = webViewCore; } bool enabled() const; - void setProfile(const string16& fullName, const string16& emailAddress); + void setProfile(const string16& fullName, const string16& emailAddress, const string16& companyName, const string16& addressLine1, + const string16& addressLine2, const string16& city, const string16& state, const string16& zipCode, + const string16& country, const string16& phoneNumber); private: OwnPtr<FormManager> mFormManager; diff --git a/WebKit/android/jni/WebSettings.cpp b/WebKit/android/jni/WebSettings.cpp index f75cf9a..5b2fb57 100644 --- a/WebKit/android/jni/WebSettings.cpp +++ b/WebKit/android/jni/WebSettings.cpp @@ -131,6 +131,14 @@ struct FieldIds { jclass autoFillProfileClass = env->FindClass("android/webkit/WebSettings$AutoFillProfile"); mAutoFillProfileFullName = env->GetFieldID(autoFillProfileClass, "mFullName", "Ljava/lang/String;"); mAutoFillProfileEmailAddress = env->GetFieldID(autoFillProfileClass, "mEmailAddress", "Ljava/lang/String;"); + mAutoFillProfileCompanyName = env->GetFieldID(autoFillProfileClass, "mCompanyName", "Ljava/lang/String;"); + mAutoFillProfileAddressLine1 = env->GetFieldID(autoFillProfileClass, "mAddressLine1", "Ljava/lang/String;"); + mAutoFillProfileAddressLine2 = env->GetFieldID(autoFillProfileClass, "mAddressLine2", "Ljava/lang/String;"); + mAutoFillProfileCity = env->GetFieldID(autoFillProfileClass, "mCity", "Ljava/lang/String;"); + mAutoFillProfileState = env->GetFieldID(autoFillProfileClass, "mState", "Ljava/lang/String;"); + mAutoFillProfileZipCode = env->GetFieldID(autoFillProfileClass, "mZipCode", "Ljava/lang/String;"); + mAutoFillProfileCountry = env->GetFieldID(autoFillProfileClass, "mCountry", "Ljava/lang/String;"); + mAutoFillProfilePhoneNumber = env->GetFieldID(autoFillProfileClass, "mPhoneNumber", "Ljava/lang/String;"); #endif LOG_ASSERT(mLayoutAlgorithm, "Could not find field mLayoutAlgorithm"); @@ -243,6 +251,14 @@ struct FieldIds { jfieldID mAutoFillProfile; jfieldID mAutoFillProfileFullName; jfieldID mAutoFillProfileEmailAddress; + jfieldID mAutoFillProfileCompanyName; + jfieldID mAutoFillProfileAddressLine1; + jfieldID mAutoFillProfileAddressLine2; + jfieldID mAutoFillProfileCity; + jfieldID mAutoFillProfileState; + jfieldID mAutoFillProfileZipCode; + jfieldID mAutoFillProfileCountry; + jfieldID mAutoFillProfilePhoneNumber; #endif }; @@ -261,21 +277,26 @@ static void recursiveCleanupForFullLayout(WebCore::RenderObject* obj) } #if ENABLE(WEB_AUTOFILL) -void syncAutoFillProfile(JNIEnv* env, jobject autoFillProfile, WebAutoFill* webAutoFill) +inline string16 getStringFieldAsString16(JNIEnv* env, jobject autoFillProfile, jfieldID fieldId) { - 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); + jstring str = static_cast<jstring>(env->GetObjectField(autoFillProfile, fieldId)); + return str ? jstringToString16(env, str) : string16(); +} - webAutoFill->setProfile(fullName, emailAddress); +void syncAutoFillProfile(JNIEnv* env, jobject autoFillProfile, WebAutoFill* webAutoFill) +{ + string16 fullName = getStringFieldAsString16(env, autoFillProfile, gFieldIds->mAutoFillProfileFullName); + string16 emailAddress = getStringFieldAsString16(env, autoFillProfile, gFieldIds->mAutoFillProfileEmailAddress); + string16 companyName = getStringFieldAsString16(env, autoFillProfile, gFieldIds->mAutoFillProfileCompanyName); + string16 addressLine1 = getStringFieldAsString16(env, autoFillProfile, gFieldIds->mAutoFillProfileAddressLine1); + string16 addressLine2 = getStringFieldAsString16(env, autoFillProfile, gFieldIds->mAutoFillProfileAddressLine2); + string16 city = getStringFieldAsString16(env, autoFillProfile, gFieldIds->mAutoFillProfileCity); + string16 state = getStringFieldAsString16(env, autoFillProfile, gFieldIds->mAutoFillProfileState); + string16 zipCode = getStringFieldAsString16(env, autoFillProfile, gFieldIds->mAutoFillProfileZipCode); + string16 country = getStringFieldAsString16(env, autoFillProfile, gFieldIds->mAutoFillProfileCountry); + string16 phoneNumber = getStringFieldAsString16(env, autoFillProfile, gFieldIds->mAutoFillProfilePhoneNumber); + + webAutoFill->setProfile(fullName, emailAddress, companyName, addressLine1, addressLine2, city, state, zipCode, country, phoneNumber); } #endif |