summaryrefslogtreecommitdiffstats
path: root/android_webview/native/aw_form_database.cc
diff options
context:
space:
mode:
authorsgurun@chromium.org <sgurun@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-08 16:16:37 +0000
committersgurun@chromium.org <sgurun@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-08 16:16:37 +0000
commit1140180828d318fe4d096484dd1a110b714ec285 (patch)
treeb45a687a3fa16b41c3847b1ad0c8d57f13a6bb84 /android_webview/native/aw_form_database.cc
parent5558ebad44509c3574cf5dce1ad2929b1b0bdeb2 (diff)
downloadchromium_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/aw_form_database.cc')
-rw-r--r--android_webview/native/aw_form_database.cc48
1 files changed, 33 insertions, 15 deletions
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;
}