diff options
Diffstat (limited to 'WebKit/android/WebCoreSupport')
-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; |