diff options
author | sgurun@chromium.org <sgurun@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-08 16:16:37 +0000 |
---|---|---|
committer | sgurun@chromium.org <sgurun@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-08 16:16:37 +0000 |
commit | 1140180828d318fe4d096484dd1a110b714ec285 (patch) | |
tree | b45a687a3fa16b41c3847b1ad0c8d57f13a6bb84 /android_webview/native | |
parent | 5558ebad44509c3574cf5dce1ad2929b1b0bdeb2 (diff) | |
download | chromium_src-1140180828d318fe4d096484dd1a110b714ec285.zip chromium_src-1140180828d318fe4d096484dd1a110b714ec285.tar.gz chromium_src-1140180828d318fe4d096484dd1a110b714ec285.tar.bz2 |
Implement WebViewDatabase's hasFormData API for chromium based webview.
BUG=b/6234236
Review URL: https://chromiumcodereview.appspot.com/14503010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198919 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'android_webview/native')
-rw-r--r-- | android_webview/native/android_webview_jni_registrar.cc | 2 | ||||
-rw-r--r-- | android_webview/native/aw_form_database.cc | 48 | ||||
-rw-r--r-- | android_webview/native/aw_form_database.h | 2 | ||||
-rw-r--r-- | android_webview/native/webview_native.gyp | 1 |
4 files changed, 37 insertions, 16 deletions
diff --git a/android_webview/native/android_webview_jni_registrar.cc b/android_webview/native/android_webview_jni_registrar.cc index 993ca7d..05f4388 100644 --- a/android_webview/native/android_webview_jni_registrar.cc +++ b/android_webview/native/android_webview_jni_registrar.cc @@ -8,6 +8,7 @@ #include "android_webview/native/aw_contents.h" #include "android_webview/native/aw_contents_client_bridge.h" #include "android_webview/native/aw_contents_io_thread_client_impl.h" +#include "android_webview/native/aw_form_database.h" #include "android_webview/native/aw_http_auth_handler.h" #include "android_webview/native/aw_quota_manager_bridge_impl.h" #include "android_webview/native/aw_resource.h" @@ -29,6 +30,7 @@ static base::android::RegistrationMethod kWebViewRegisteredMethods[] = { { "AwContents", RegisterAwContents }, { "AwContentsClientBridge", RegisterAwContentsClientBridge }, { "AwContentsIoThreadClientImpl", RegisterAwContentsIoThreadClientImpl}, + { "AwFormDatabase", RegisterAwFormDatabase}, { "AwSettings", RegisterAwSettings }, { "AwHttpAuthHandler", RegisterAwHttpAuthHandler }, { "AwQuotaManagerBridge", RegisterAwQuotaManagerBridge }, diff --git a/android_webview/native/aw_form_database.cc b/android_webview/native/aw_form_database.cc index f0d42fd..5ebdf12 100644 --- a/android_webview/native/aw_form_database.cc +++ b/android_webview/native/aw_form_database.cc @@ -6,33 +6,51 @@ #include "android_webview/browser/aw_browser_context.h" #include "android_webview/browser/aw_content_browser_client.h" +#include "android_webview/browser/aw_form_database_service.h" #include "base/android/jni_android.h" #include "base/logging.h" #include "base/time.h" #include "components/autofill/browser/webdata/autofill_webdata_service.h" #include "jni/AwFormDatabase_jni.h" +// static +scoped_refptr<autofill::AutofillWebDataService> +autofill::AutofillWebDataService::FromBrowserContext( + content::BrowserContext* context) { + + DCHECK(context); + android_webview::AwFormDatabaseService* service = + static_cast<android_webview::AwBrowserContext*>( + context)->GetFormDatabaseService(); + DCHECK(service); + return service->get_autofill_webdata_service(); +} + namespace android_webview { -// static -void ClearFormData(JNIEnv*, jclass) { +namespace { + +AwFormDatabaseService* GetFormDatabaseService() { + AwBrowserContext* context = AwContentBrowserClient::GetAwBrowserContext(); - DCHECK(context); + AwFormDatabaseService* service = context->GetFormDatabaseService(); + return service; +} + +} // anonymous namespace - autofill::AutofillWebDataService* service = - autofill::AutofillWebDataService::FromBrowserContext(context).get(); - if (service == NULL) { - LOG(WARNING) << "No webdata service found, ignoring ClearFormData"; - return; - } - - base::Time begin; - base::Time end = base::Time::Max(); - service->RemoveFormElementsAddedBetween(begin, end); - service->RemoveAutofillDataModifiedBetween(begin, end); + +// static +jboolean HasFormData(JNIEnv*, jclass) { + return GetFormDatabaseService()->HasFormData(); +} + +// static +void ClearFormData(JNIEnv*, jclass) { + GetFormDatabaseService()->ClearFormData(); } -bool RegisterFormDatabase(JNIEnv* env) { +bool RegisterAwFormDatabase(JNIEnv* env) { return RegisterNativesImpl(env) >= 0; } diff --git a/android_webview/native/aw_form_database.h b/android_webview/native/aw_form_database.h index 9f6ebae..ae1ceb0 100644 --- a/android_webview/native/aw_form_database.h +++ b/android_webview/native/aw_form_database.h @@ -9,7 +9,7 @@ namespace android_webview { -bool RegisterFormDatabase(JNIEnv* env); +bool RegisterAwFormDatabase(JNIEnv* env); } // namespace android_webview diff --git a/android_webview/native/webview_native.gyp b/android_webview/native/webview_native.gyp index cdd2f71..2ac370d 100644 --- a/android_webview/native/webview_native.gyp +++ b/android_webview/native/webview_native.gyp @@ -12,6 +12,7 @@ 'dependencies': [ '../../base/base.gyp:base_static', '../../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations', + '../../components/components.gyp:autofill_browser', '../../components/components.gyp:web_contents_delegate_android', '../../cc/cc.gyp:cc', '../../net/net.gyp:net', |