Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Unified Diff: android_webview/native/aw_form_database.cc

Issue 14503010: Implement WebViewDatabase's hasFormData API for chromium based webview. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address ben's code review Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: android_webview/native/aw_form_database.cc
diff --git a/android_webview/native/aw_form_database.cc b/android_webview/native/aw_form_database.cc
index f0d42fdc7cafb8cccb1118cd9082e66643c38415..b8bde16c4f0e96785ef9e2537feb9576ae2c8dca 100644
--- a/android_webview/native/aw_form_database.cc
+++ b/android_webview/native/aw_form_database.cc
@@ -6,33 +6,53 @@
#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) {
+ AwFormDatabaseService* service = GetFormDatabaseService();
+ return service->HasFormData();
+}
+
+// static
+void ClearFormData(JNIEnv*, jclass) {
+ AwFormDatabaseService* service = GetFormDatabaseService();
+ return service->ClearFormData();
benm (inactive) 2013/05/07 19:06:55 no need to return here
sgurun-gerrit only 2013/05/07 19:56:09 Done.
}
-bool RegisterFormDatabase(JNIEnv* env) {
+bool RegisterAwFormDatabase(JNIEnv* env) {
return RegisterNativesImpl(env) >= 0;
}

Powered by Google App Engine
This is Rietveld 408576698