diff options
author | Ben Murdoch <benm@google.com> | 2010-09-10 22:00:37 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2010-09-28 19:09:59 +0100 |
commit | 3978ee5f7771518f1c2650dfe39033c2fecc09fe (patch) | |
tree | fe7f375b1a3f3ae651670d289740c2e5257e0da3 /WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp | |
parent | cd0967466be49b8ea06b49a79f790e267e1adb66 (diff) | |
download | external_webkit-3978ee5f7771518f1c2650dfe39033c2fecc09fe.zip external_webkit-3978ee5f7771518f1c2650dfe39033c2fecc09fe.tar.gz external_webkit-3978ee5f7771518f1c2650dfe39033c2fecc09fe.tar.bz2 |
Turn autofill on by default at compile time and make it a browser setting.
Make autofill a runtime option configured through the browser.
Required a corresponding change in frameworks/base -
https://android-git.corp.google.com/g/65573
and packages/apps/browser -
https://android-git.corp.google.com/g/65579
Change-Id: I905b464a6338ff27b02f16d0b9a718154c3c98c1
Diffstat (limited to 'WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp')
-rw-r--r-- | WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp b/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp index 278889c..f9fc954 100644 --- a/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp +++ b/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp @@ -37,6 +37,8 @@ #include "HTMLFormControlElement.h" #include "MainThreadProxy.h" #include "Node.h" +#include "Page.h" +#include "Settings.h" #include "WebFrame.h" #include "WebRequestContext.h" #include "WebUrlLoaderClient.h" @@ -90,6 +92,10 @@ void WebAutoFill::searchDocument(WebCore::Document* document) // fields in those forms. It's currently synchronous and might be slow // if the page has many or complex forms. Might want to make this an // async method. + + if (!enabled()) + return; + if (!mFormManager) return; @@ -106,6 +112,14 @@ void WebAutoFill::searchDocument(WebCore::Document* document) void WebAutoFill::formFieldFocused(WebCore::HTMLFormControlElement* formFieldElement) { + if (!enabled()) { + // 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); + return; + } + // Get the FormField from the Node. webkit_glue::FormField formField; FormManager::HTMLFormControlElementToFormField(*formFieldElement, false, &formField); @@ -127,6 +141,9 @@ void WebAutoFill::formFieldFocused(WebCore::HTMLFormControlElement* formFieldEle void WebAutoFill::querySuccessful(int queryId, const string16& value, const string16& label, int uniqueId) { + if (!enabled()) + return; + // Store the results for the query and inform java that autofill suggestions for this form are available. // Pass java the queryId so that it can pass it back if the user decides to use autofill. AutoFillSuggestion suggestion; @@ -141,6 +158,9 @@ void WebAutoFill::querySuccessful(int queryId, const string16& value, const stri void WebAutoFill::fillFormFields(int queryId) { + if (!enabled()) + return; + webkit_glue::FormData* form = mQueryMap[queryId]; AutoFillQuerySuggestionMap::iterator iter = mSuggestionMap.find(queryId); ASSERT(iter != mSuggestionMap.end()); @@ -151,9 +171,18 @@ void WebAutoFill::fillFormFields(int queryId) void WebAutoFill::fillFormInPage(int queryId, const webkit_glue::FormData& form) { + if (!enabled()) + return; + mFormManager->FillForm(form); } +bool WebAutoFill::enabled() const +{ + Page* page = mWebViewCore->mainFrame()->page(); + return page ? page->settings()->autoFillEnabled() : false; +} + } #endif |