diff options
author | Ben Murdoch <benm@google.com> | 2010-11-17 11:03:51 +0000 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2010-11-23 12:13:06 +0000 |
commit | ca8cd243dacc9e4491fc2cce61e6d360b64e2cb8 (patch) | |
tree | eed1dc5595634a522bab3286bc5069560deded7b /WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp | |
parent | d8fcffded6ee266e903e4e191ed95a07007fac74 (diff) | |
download | external_webkit-ca8cd243dacc9e4491fc2cce61e6d360b64e2cb8.zip external_webkit-ca8cd243dacc9e4491fc2cce61e6d360b64e2cb8.tar.gz external_webkit-ca8cd243dacc9e4491fc2cce61e6d360b64e2cb8.tar.bz2 |
By default, provide native AutoFill with an empty profile.
If no profile is set then AutoFill will not inform Java that it has
found a form that could be autofilled. We want to be able to offer
the user the option Java side to set up a profile in this case, so
we set by default an empty profile that is active until the user
syncs their real profile. This ensures that the AutoFill detection
code will not early out.
Change-Id: I474b25c5b31dae59e4ddb23c7f398d013e9d3beb
Diffstat (limited to 'WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp')
-rw-r--r-- | WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp b/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp index 8fc4ac3..8199aa0 100644 --- a/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp +++ b/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp @@ -66,6 +66,8 @@ WebAutoFill::WebAutoFill() mAutoFillManager = new AutoFillManager(mTabContents.get()); mAutoFillHost = new AutoFillHostAndroid(this); mTabContents->SetAutoFillHost(mAutoFillHost.get()); + + setEmptyProfile(); } WebAutoFill::~WebAutoFill() @@ -147,6 +149,7 @@ void WebAutoFill::fillFormFields(int queryId) return; webkit_glue::FormData* form = mQueryMap[queryId]; + ASSERT(form); AutoFillQueryToUniqueIdMap::iterator iter = mUniqueIdMap.find(queryId); ASSERT(iter != mUniqueIdMap.end()); mAutoFillManager->FillAutoFillFormData(queryId, *form, iter->second); @@ -176,8 +179,10 @@ void WebAutoFill::setProfile(const string16& fullName, const string16& emailAddr const string16& addressLine1, const string16& addressLine2, const string16& city, const string16& state, const string16& zipCode, const string16& country, const string16& phoneNumber) { - mAutoFillProfile.set(new AutoFillProfile()); + if (!mAutoFillProfile) + mAutoFillProfile.set(new AutoFillProfile()); + // Update the profile. // Constants for AutoFill field types are found in external/chromium/chrome/browser/autofill/field_types.h. mAutoFillProfile->SetInfo(AutoFillType(NAME_FULL), fullName); mAutoFillProfile->SetInfo(AutoFillType(EMAIL_ADDRESS), emailAddress); @@ -212,6 +217,23 @@ void WebAutoFill::clearProfiles() // we need to remove them all here. std::string profileGuid = mAutoFillProfile->guid(); mTabContents->profile()->GetPersonalDataManager()->RemoveProfile(profileGuid); + setEmptyProfile(); +} + +void WebAutoFill::setEmptyProfile() +{ + // Set an empty profile. This will ensure that when autofill is enabled, + // we will still search the document for autofillable forms and inform + // java of their presence so we can invite the user to set up + // their own profile. + + // Chromium code will strip the values sent into the profile so we need them to be + // at least one non-whitespace character long. We need to set all fields of the + // profile to a non-empty string so that any field type can trigger the autofill + // suggestion. AutoFill will not detect form fields if the profile value for that + // field is an empty string. + static const string16 empty = string16(ASCIIToUTF16("a")); + setProfile(empty, empty, empty, empty, empty, empty, empty, empty, empty, empty); } } |