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 | |
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
-rw-r--r-- | Android.mk | 8 | ||||
-rw-r--r-- | WebCore/page/Settings.cpp | 3 | ||||
-rw-r--r-- | WebCore/page/Settings.h | 9 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp | 29 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/autofill/WebAutoFill.h | 1 | ||||
-rw-r--r-- | WebKit/android/jni/WebSettings.cpp | 27 |
6 files changed, 72 insertions, 5 deletions
@@ -96,11 +96,11 @@ ifeq ($(JAVASCRIPT_ENGINE),jsc) HTTP_STACK = android endif -# Read the environment variable to determine if Autofill is enabled. -# The default is off. Chrome HTTP stack must be used when Autofill +# Read the environment variable to determine if Autofill is compiled. +# The default is on. Chrome HTTP stack must be used when Autofill # is turned on. -ifneq ($(ENABLE_AUTOFILL),true) - ENABLE_AUTOFILL=false +ifneq ($(ENABLE_AUTOFILL),false) + ENABLE_AUTOFILL = true endif ifneq ($(HTTP_STACK),chrome) ENABLE_AUTOFILL = false diff --git a/WebCore/page/Settings.cpp b/WebCore/page/Settings.cpp index 8b3a74c..210c97e 100644 --- a/WebCore/page/Settings.cpp +++ b/WebCore/page/Settings.cpp @@ -158,6 +158,9 @@ Settings::Settings(Page* page) #endif , m_memoryInfoEnabled(false) , m_interactiveFormValidation(false) +#if ENABLE(WEB_AUTOFILL) + , m_autoFillEnabled(false) +#endif #ifdef ANDROID_PLUGINS , m_pluginsOnDemand(false) #endif diff --git a/WebCore/page/Settings.h b/WebCore/page/Settings.h index 654f317..6f18616 100644 --- a/WebCore/page/Settings.h +++ b/WebCore/page/Settings.h @@ -397,6 +397,11 @@ namespace WebCore { void setInteractiveFormValidationEnabled(bool flag) { m_interactiveFormValidation = flag; } bool interactiveFormValidationEnabled() const { return m_interactiveFormValidation; } +#if ENABLE(WEB_AUTOFILL) + void setAutoFillEnabled(bool flag) { m_autoFillEnabled = flag; } + bool autoFillEnabled() { return m_autoFillEnabled; } +#endif + private: Page* m_page; @@ -522,10 +527,12 @@ namespace WebCore { #endif bool m_memoryInfoEnabled: 1; bool m_interactiveFormValidation: 1; - #ifdef ANDROID_PLUGINS bool m_pluginsOnDemand : 1; #endif +#if ENABLE(WEB_AUTOFILL) + bool m_autoFillEnabled: 1; +#endif #if USE(SAFARI_THEME) static bool gShouldPaintNativeControls; 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 diff --git a/WebKit/android/WebCoreSupport/autofill/WebAutoFill.h b/WebKit/android/WebCoreSupport/autofill/WebAutoFill.h index 986e1a2..c1226ed 100644 --- a/WebKit/android/WebCoreSupport/autofill/WebAutoFill.h +++ b/WebKit/android/WebCoreSupport/autofill/WebAutoFill.h @@ -61,6 +61,7 @@ public: void querySuccessful(int queryId, const string16& value, const string16& label, int uniqueId); void fillFormInPage(int queryId, const webkit_glue::FormData& form); void setWebViewCore(WebViewCore* webViewCore) { mWebViewCore = webViewCore; } + bool enabled() const; private: OwnPtr<FormManager> mFormManager; diff --git a/WebKit/android/jni/WebSettings.cpp b/WebKit/android/jni/WebSettings.cpp index 29d72e4..ff6a482 100644 --- a/WebKit/android/jni/WebSettings.cpp +++ b/WebKit/android/jni/WebSettings.cpp @@ -34,6 +34,7 @@ #include "DatabaseTracker.h" #include "Database.h" #include "Document.h" +#include "EditorClientAndroid.h" #include "Frame.h" #include "FrameLoader.h" #include "FrameView.h" @@ -122,6 +123,9 @@ struct FieldIds { mSyntheticLinksEnabled = env->GetFieldID(clazz, "mSyntheticLinksEnabled", "Z"); mUseDoubleTree = env->GetFieldID(clazz, "mUseDoubleTree", "Z"); mPageCacheCapacity = env->GetFieldID(clazz, "mPageCacheCapacity", "I"); +#if ENABLE(WEB_AUTOFILL) + mAutoFillEnabled = env->GetFieldID(clazz, "mAutoFillEnabled", "Z"); +#endif LOG_ASSERT(mLayoutAlgorithm, "Could not find field mLayoutAlgorithm"); LOG_ASSERT(mTextSize, "Could not find field mTextSize"); @@ -226,6 +230,9 @@ struct FieldIds { jfieldID mDatabasePath; jfieldID mDatabasePathHasBeenSet; #endif +#if ENABLE(WEB_AUTOFILL) + jfieldID mAutoFillEnabled; +#endif }; static struct FieldIds* gFieldIds; @@ -426,6 +433,26 @@ public: WebCore::pageCache()->setCapacity(size); } else s->setUsesPageCache(false); + +#if ENABLE(WEB_AUTOFILL) + flag = env->GetBooleanField(obj, gFieldIds->mAutoFillEnabled); + // TODO: This updates the Settings WebCore side with the user's + // preference for autofill and will stop WebCore making requests + // into the chromium autofill code. That code in Chromium also has + // a notion of being enabled/disabled that gets read from the users + // preferences. At the moment, it's hardcoded to true on Android + // (see chrome/browser/autofill/autofill_manager.cc:405). This + // setting should probably be synced into Chromium also. + + // If we toggle from disabled to enabled, then re search the document + // for forms. + bool oldAutoFillSetting = s->autoFillEnabled(); + s->setAutoFillEnabled(flag); + if (!oldAutoFillSetting && flag) { + EditorClientAndroid* editorC = static_cast<EditorClientAndroid*>(pFrame->page()->editorClient()); + editorC->getAutoFill()->searchDocument(pFrame->document()); + } +#endif } }; |