diff options
author | Ben Murdoch <benm@google.com> | 2010-10-19 19:41:08 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2010-11-05 11:33:18 +0000 |
commit | f27fc812b6f9c8e44806849bdf68f6e5399f3081 (patch) | |
tree | 60e43791c7cbbdcbfc40e14be9bc66aa126499e1 | |
parent | 78fba6ce7c5f203a64307ceb5a1dc4d2286c2e4b (diff) | |
download | external_webkit-f27fc812b6f9c8e44806849bdf68f6e5399f3081.zip external_webkit-f27fc812b6f9c8e44806849bdf68f6e5399f3081.tar.gz external_webkit-f27fc812b6f9c8e44806849bdf68f6e5399f3081.tar.bz2 |
Send the AutoFill Preview string java side.
When we have determined that the form can be autofilled, send
a preview string over to Java so that we can display it in the
drop down box.
Requires a change in frameworks/base:
https://android-git.corp.google.com/g/#change,77127
Change-Id: Ia0dd899d659c6e5710155f33749255058d7c3faf
-rw-r--r-- | WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp | 42 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/autofill/WebAutoFill.h | 4 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 8 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.h | 2 |
4 files changed, 27 insertions, 29 deletions
diff --git a/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp b/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp index 1aecef1..f80168d 100644 --- a/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp +++ b/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp @@ -57,7 +57,6 @@ static URLRequestContext* webAutoFillContextGetter() WebAutoFill::WebAutoFill() : mWebViewCore(0) - , mUniqueProfileId(NO_PROFILE_SET) { mFormManager = new FormManager(); mQueryId = 1; @@ -107,7 +106,7 @@ void WebAutoFill::formFieldFocused(WebCore::HTMLFormControlElement* formFieldEle // In case that we've just been disabled and the last time we got autofill // suggestions and told Java about them, clear that bit Java side now // we're disabled. - mWebViewCore->setWebTextViewAutoFillable(FORM_NOT_AUTOFILLABLE); + mWebViewCore->setWebTextViewAutoFillable(FORM_NOT_AUTOFILLABLE, string16()); return; } @@ -125,7 +124,7 @@ void WebAutoFill::formFieldFocused(WebCore::HTMLFormControlElement* formFieldEle if (!suggestions) { ASSERT(mWebViewCore); // Tell Java no autofill suggestions for this form. - mWebViewCore->setWebTextViewAutoFillable(FORM_NOT_AUTOFILLABLE); + mWebViewCore->setWebTextViewAutoFillable(FORM_NOT_AUTOFILLABLE, string16()); return; } } @@ -140,7 +139,7 @@ void WebAutoFill::querySuccessful(int queryId, const string16& value, const stri mUniqueIdMap[queryId] = uniqueId; ASSERT(mWebViewCore); - mWebViewCore->setWebTextViewAutoFillable(queryId); + mWebViewCore->setWebTextViewAutoFillable(queryId, mAutoFillProfile->PreviewSummary()); } void WebAutoFill::fillFormFields(int queryId) @@ -173,24 +172,23 @@ void WebAutoFill::setProfile(int id, const string16& fullName, const string16& e const string16& addressLine1, const string16& addressLine2, const string16& city, const string16& state, const string16& zipCode, const string16& country, const string16& phoneNumber) { - AutoFillProfile autoFillProfile; - mUniqueProfileId = id; - autoFillProfile.set_unique_id(id); + mAutoFillProfile.set(new AutoFillProfile()); + mAutoFillProfile->set_unique_id(id); // 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); + mAutoFillProfile->SetInfo(AutoFillType(NAME_FULL), fullName); + mAutoFillProfile->SetInfo(AutoFillType(EMAIL_ADDRESS), emailAddress); + mAutoFillProfile->SetInfo(AutoFillType(COMPANY_NAME), companyName); + mAutoFillProfile->SetInfo(AutoFillType(ADDRESS_HOME_LINE1), addressLine1); + mAutoFillProfile->SetInfo(AutoFillType(ADDRESS_HOME_LINE2), addressLine2); + mAutoFillProfile->SetInfo(AutoFillType(ADDRESS_HOME_CITY), city); + mAutoFillProfile->SetInfo(AutoFillType(ADDRESS_HOME_STATE), state); + mAutoFillProfile->SetInfo(AutoFillType(ADDRESS_HOME_ZIP), zipCode); + mAutoFillProfile->SetInfo(AutoFillType(ADDRESS_HOME_COUNTRY), country); + mAutoFillProfile->SetInfo(AutoFillType(PHONE_HOME_WHOLE_NUMBER), phoneNumber); std::vector<AutoFillProfile> profiles; - profiles.push_back(autoFillProfile); + profiles.push_back(*mAutoFillProfile); mTabContents->profile()->GetPersonalDataManager()->SetProfiles(&profiles); } @@ -199,10 +197,10 @@ void WebAutoFill::clearProfiles() // For now Chromium only ever knows about one profile, so we can just // remove it by unique id. If we support multiple profiles in the future // we need to remove them all here. - if (mUniqueProfileId != NO_PROFILE_SET) { - mTabContents->profile()->GetPersonalDataManager()->RemoveProfile(mUniqueProfileId); - mUniqueProfileId = NO_PROFILE_SET; - } + int uniqueProfileId = mAutoFillProfile->unique_id(); + if (uniqueProfileId != NO_PROFILE_SET) + mTabContents->profile()->GetPersonalDataManager()->RemoveProfile(uniqueProfileId); + mAutoFillProfile.set(0); } } diff --git a/WebKit/android/WebCoreSupport/autofill/WebAutoFill.h b/WebKit/android/WebCoreSupport/autofill/WebAutoFill.h index d74c838..c4b63b0 100644 --- a/WebKit/android/WebCoreSupport/autofill/WebAutoFill.h +++ b/WebKit/android/WebCoreSupport/autofill/WebAutoFill.h @@ -73,6 +73,7 @@ private: OwnPtr<AutoFillManager> mAutoFillManager; OwnPtr<AutoFillHost> mAutoFillHost; OwnPtr<TabContents> mTabContents; + OwnPtr<AutoFillProfile> mAutoFillProfile; typedef std::vector<webkit_glue::FormData, std::allocator<webkit_glue::FormData> > FormList; FormList mForms; @@ -84,9 +85,6 @@ private: AutoFillQueryToUniqueIdMap mUniqueIdMap; int mQueryId; - // This is set by Java when a profile is synced. - int mUniqueProfileId; - WebViewCore* mWebViewCore; }; diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index c301421..deae37f 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -381,7 +381,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m m_javaGlue->m_centerFitRect = GetJMethod(env, clazz, "centerFitRect", "(IIII)V"); m_javaGlue->m_setScrollbarModes = GetJMethod(env, clazz, "setScrollbarModes", "(II)V"); m_javaGlue->m_setInstallableWebApp = GetJMethod(env, clazz, "setInstallableWebApp", "()V"); - m_javaGlue->m_setWebTextViewAutoFillable = GetJMethod(env, clazz, "setWebTextViewAutoFillable", "(I)V"); + m_javaGlue->m_setWebTextViewAutoFillable = GetJMethod(env, clazz, "setWebTextViewAutoFillable", "(ILjava/lang/String;)V"); env->DeleteLocalRef(clazz); env->SetIntField(javaWebViewCore, gWebViewCoreFields.m_nativeClass, (jint)this); @@ -3304,10 +3304,12 @@ void WebViewCore::notifyWebAppCanBeInstalled() checkException(env); } -void WebViewCore::setWebTextViewAutoFillable(int queryId) +void WebViewCore::setWebTextViewAutoFillable(int queryId, const string16& previewSummary) { JNIEnv* env = JSC::Bindings::getJNIEnv(); - env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_setWebTextViewAutoFillable, queryId); + jstring preview = env->NewString(previewSummary.data(), previewSummary.length()); + env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_setWebTextViewAutoFillable, queryId, preview); + env->DeleteLocalRef(preview); } bool WebViewCore::drawIsPaused() const diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h index 853c17b..1e2f130 100644 --- a/WebKit/android/jni/WebViewCore.h +++ b/WebKit/android/jni/WebViewCore.h @@ -508,7 +508,7 @@ namespace android { void splitContent(PictureSet*); void notifyWebAppCanBeInstalled(); - void setWebTextViewAutoFillable(int queryId); + void setWebTextViewAutoFillable(int queryId, const string16& previewSummary); DeviceMotionAndOrientationManager* deviceMotionAndOrientationManager() { return &m_deviceMotionAndOrientationManager; } |