diff options
author | Ben Murdoch <benm@google.com> | 2010-10-06 14:34:04 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2010-10-13 12:01:11 +0100 |
commit | 81feb0e216184fe2c8d13ef52dd678925cc4ad77 (patch) | |
tree | 412ce15f250931476a324166b1a847c47f45218a /WebKit/android/WebCoreSupport/autofill | |
parent | 0a12879c6b8ddf8b2b27629dfd999cedd9589959 (diff) | |
download | external_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/WebCoreSupport/autofill')
-rw-r--r-- | WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp | 35 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/autofill/WebAutoFill.h | 4 |
2 files changed, 19 insertions, 20 deletions
diff --git a/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp b/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp index aff1e2f..ce0a455 100644 --- a/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp +++ b/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp @@ -57,26 +57,10 @@ WebAutoFill::WebAutoFill() AndroidURLRequestContextGetter::Get()->SetURLRequestContextGetterFunction(&WebRequestContext::GetAndroidContext); AndroidURLRequestContextGetter::Get()->SetIOThread(WebUrlLoaderClient::ioThread()); - TabContents* tabContents = new TabContents(); - mAutoFillManager = new AutoFillManager(tabContents); - - // FIXME: For testing use a precanned profile. This should come from Java land! - mAutoFillProfile = new AutoFillProfile(); - mAutoFillProfile->SetInfo(AutoFillType(NAME_FULL), string16(ASCIIToUTF16("John Smith"))); - mAutoFillProfile->SetInfo(AutoFillType(EMAIL_ADDRESS), string16(ASCIIToUTF16("jsmith@gmail.com"))); - mAutoFillProfile->SetInfo(AutoFillType(ADDRESS_HOME_LINE1), string16(ASCIIToUTF16("123 Fake Street"))); - mAutoFillProfile->SetInfo(AutoFillType(ADDRESS_HOME_LINE2), string16(ASCIIToUTF16("Somewhere"))); - mAutoFillProfile->SetInfo(AutoFillType(ADDRESS_HOME_CITY), string16(ASCIIToUTF16("Faketown"))); - mAutoFillProfile->SetInfo(AutoFillType(ADDRESS_HOME_STATE), string16(ASCIIToUTF16("CA"))); - mAutoFillProfile->SetInfo(AutoFillType(ADDRESS_HOME_COUNTRY), string16(ASCIIToUTF16("Germany"))); - mAutoFillProfile->SetInfo(AutoFillType(ADDRESS_HOME_ZIP), string16(ASCIIToUTF16("AB12 3DE"))); - mAutoFillProfile->SetInfo(AutoFillType(PHONE_HOME_WHOLE_NUMBER), string16(ASCIIToUTF16("0123456789"))); - - std::vector<AutoFillProfile> profiles; - profiles.push_back(*mAutoFillProfile); - tabContents->profile()->GetPersonalDataManager()->SetProfiles(&profiles); + mTabContents = new TabContents(); + mAutoFillManager = new AutoFillManager(mTabContents.get()); mAutoFillHost = new AutoFillHostAndroid(this); - tabContents->SetAutoFillHost(mAutoFillHost.get()); + mTabContents->SetAutoFillHost(mAutoFillHost.get()); } WebAutoFill::~WebAutoFill() @@ -183,6 +167,19 @@ bool WebAutoFill::enabled() const return page ? page->settings()->autoFillEnabled() : false; } +void WebAutoFill::setProfile(const string16& fullName, const string16& emailAddress) +{ + 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); + + std::vector<AutoFillProfile> profiles; + profiles.push_back(autoFillProfile); + mTabContents->profile()->GetPersonalDataManager()->SetProfiles(&profiles); +} + } #endif diff --git a/WebKit/android/WebCoreSupport/autofill/WebAutoFill.h b/WebKit/android/WebCoreSupport/autofill/WebAutoFill.h index c1226ed..fabd3bf 100644 --- a/WebKit/android/WebCoreSupport/autofill/WebAutoFill.h +++ b/WebKit/android/WebCoreSupport/autofill/WebAutoFill.h @@ -63,11 +63,13 @@ public: void setWebViewCore(WebViewCore* webViewCore) { mWebViewCore = webViewCore; } bool enabled() const; + void setProfile(const string16& fullName, const string16& emailAddress); + private: OwnPtr<FormManager> mFormManager; OwnPtr<AutoFillManager> mAutoFillManager; - OwnPtr<AutoFillProfile> mAutoFillProfile; OwnPtr<AutoFillHost> mAutoFillHost; + OwnPtr<TabContents> mTabContents; typedef std::vector<webkit_glue::FormData, std::allocator<webkit_glue::FormData> > FormList; FormList mForms; |