diff options
-rw-r--r-- | WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp | 14 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/autofill/WebAutoFill.h | 4 | ||||
-rw-r--r-- | WebKit/android/jni/WebSettings.cpp | 6 |
3 files changed, 24 insertions, 0 deletions
diff --git a/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp b/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp index ef9d598..1aecef1 100644 --- a/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp +++ b/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp @@ -44,6 +44,7 @@ #include "WebUrlLoaderClient.h" #include "WebViewCore.h" +#define NO_PROFILE_SET 0 #define FORM_NOT_AUTOFILLABLE -1 namespace android @@ -56,6 +57,7 @@ static URLRequestContext* webAutoFillContextGetter() WebAutoFill::WebAutoFill() : mWebViewCore(0) + , mUniqueProfileId(NO_PROFILE_SET) { mFormManager = new FormManager(); mQueryId = 1; @@ -172,6 +174,7 @@ void WebAutoFill::setProfile(int id, const string16& fullName, const string16& e const string16& state, const string16& zipCode, const string16& country, const string16& phoneNumber) { AutoFillProfile autoFillProfile; + mUniqueProfileId = id; autoFillProfile.set_unique_id(id); // Constants for AutoFill field types are found in external/chromium/chrome/browser/autofill/field_types.h. @@ -191,6 +194,17 @@ void WebAutoFill::setProfile(int id, const string16& fullName, const string16& e mTabContents->profile()->GetPersonalDataManager()->SetProfiles(&profiles); } +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; + } +} + } #endif diff --git a/WebKit/android/WebCoreSupport/autofill/WebAutoFill.h b/WebKit/android/WebCoreSupport/autofill/WebAutoFill.h index 46850e6..d74c838 100644 --- a/WebKit/android/WebCoreSupport/autofill/WebAutoFill.h +++ b/WebKit/android/WebCoreSupport/autofill/WebAutoFill.h @@ -66,6 +66,7 @@ public: void setProfile(int id, 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); + void clearProfiles(); private: OwnPtr<FormManager> mFormManager; @@ -83,6 +84,9 @@ 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/WebSettings.cpp b/WebKit/android/jni/WebSettings.cpp index 62594ff..fc9d628 100644 --- a/WebKit/android/jni/WebSettings.cpp +++ b/WebKit/android/jni/WebSettings.cpp @@ -519,6 +519,12 @@ public: jobject autoFillProfile = env->GetObjectField(obj, gFieldIds->mAutoFillProfile); if (autoFillProfile) syncAutoFillProfile(env, autoFillProfile, webAutoFill); + else { + // The autofill profile is null. We need to tell Chromium about this because + // this may be because the user just deleted their profile but left the + // autofill feature setting enabled. + webAutoFill->clearProfiles(); + } #endif } }; |