Commit c7dca4cc authored by Tao Bai's avatar Tao Bai Committed by Commit Bot

Hookup the datalist related function to provider

No feature change.

Bug: 949555
Change-Id: I73ccacc91694bfac3b1016de6310f628403805cf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2234016
Commit-Queue: Tao Bai <michaelbai@chromium.org>
Reviewed-by: default avatarDominic Battré <battre@chromium.org>
Cr-Commit-Position: refs/heads/master@{#776354}
parent 60549c9c
......@@ -19,6 +19,7 @@
#include "ui/gfx/geometry/rect_f.h"
using base::android::AttachCurrentThread;
using base::android::ConvertJavaStringToUTF16;
using base::android::ConvertUTF16ToJavaString;
using base::android::ConvertUTF8ToJavaString;
using base::android::JavaRef;
......@@ -141,6 +142,16 @@ void AutofillProviderAndroid::OnAutofillAvailable(JNIEnv* env,
}
}
void AutofillProviderAndroid::OnAcceptDataListSuggestion(JNIEnv* env,
jobject jcaller,
jstring value) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (auto* handler = handler_.get()) {
RendererShouldAcceptDataListSuggestion(
handler, ConvertJavaStringToUTF16(env, value));
}
}
void AutofillProviderAndroid::OnTextFieldDidChange(
AutofillHandlerProxy* handler,
const FormData& form,
......@@ -314,6 +325,18 @@ void AutofillProviderAndroid::OnFormsSeen(AutofillHandlerProxy* handler,
FireSuccessfulSubmission(pending_submission_source_);
}
void AutofillProviderAndroid::OnHidePopup(AutofillHandlerProxy* handler) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (handler == handler_.get()) {
JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
if (obj.is_null())
return;
Java_AutofillProvider_hidePopup(env, obj);
}
}
void AutofillProviderAndroid::Reset(AutofillHandlerProxy* handler) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (handler == handler_.get()) {
......
......@@ -67,11 +67,13 @@ class AutofillProviderAndroid : public AutofillProvider {
void OnFormsSeen(AutofillHandlerProxy* handler,
const std::vector<FormData>& forms,
const base::TimeTicks timestamp) override;
void OnHidePopup(AutofillHandlerProxy* handler) override;
void Reset(AutofillHandlerProxy* handler) override;
// Methods called by Java.
void OnAutofillAvailable(JNIEnv* env, jobject jcaller, jobject form_data);
void OnAcceptDataListSuggestion(JNIEnv* env, jobject jcaller, jstring value);
private:
void FireSuccessfulSubmission(mojom::SubmissionSource source);
......
......@@ -137,6 +137,11 @@ public abstract class AutofillProvider {
nativeAutofillProvider, AutofillProvider.this, formData);
}
protected void acceptDataListSuggestion(long nativeAutofillProvider, String value) {
AutofillProviderJni.get().onAcceptDataListSuggestion(
nativeAutofillProvider, AutofillProvider.this, value);
}
/**
* Invoked when current query need to be reset.
*/
......@@ -149,9 +154,15 @@ public abstract class AutofillProvider {
@CalledByNative
protected abstract void onDidFillAutofillFormData();
@CalledByNative
protected abstract void hidePopup();
@NativeMethods
interface Natives {
void onAutofillAvailable(
long nativeAutofillProviderAndroid, AutofillProvider caller, FormData formData);
void onAcceptDataListSuggestion(
long nativeAutofillProviderAndroid, AutofillProvider caller, String value);
}
}
......@@ -419,6 +419,9 @@ public class AutofillProviderImpl extends AutofillProvider {
focusOnForm, focusField, x, y, width, height, false /*causedByValueChange*/);
}
@Override
protected void hidePopup() {}
private void notifyViewExitBeforeDestoryRequest() {
if (mRequest == null) return;
FocusField focusField = mRequest.getFocusField();
......
......@@ -88,7 +88,9 @@ void AutofillHandlerProxy::OnDidPreviewAutofillFormData() {}
void AutofillHandlerProxy::OnDidEndTextFieldEditing() {}
void AutofillHandlerProxy::OnHidePopup() {}
void AutofillHandlerProxy::OnHidePopup() {
provider_->OnHidePopup(this);
}
void AutofillHandlerProxy::SelectFieldOptionsDidChange(const FormData& form) {}
......
......@@ -19,4 +19,10 @@ void AutofillProvider::SendFormDataToRenderer(AutofillHandlerProxy* handler,
requestId, AutofillDriver::FORM_DATA_ACTION_FILL, formData);
}
} // namespace autofil
void AutofillProvider::RendererShouldAcceptDataListSuggestion(
AutofillHandlerProxy* handler,
const base::string16& value) {
handler->driver()->RendererShouldAcceptDataListSuggestion(value);
}
} // namespace autofill
......@@ -67,11 +67,18 @@ class AutofillProvider {
const std::vector<FormData>& forms,
const base::TimeTicks timestamp) = 0;
virtual void OnHidePopup(AutofillHandlerProxy* handler) = 0;
virtual void Reset(AutofillHandlerProxy* handler) = 0;
void SendFormDataToRenderer(AutofillHandlerProxy* handler,
int requestId,
const FormData& formData);
// Notifies the renderer should accept the datalist suggestion given by
// |value| and fill the associated input field.
void RendererShouldAcceptDataListSuggestion(AutofillHandlerProxy* handler,
const base::string16& value);
};
} // namespace autofill
......
......@@ -50,6 +50,8 @@ void TestAutofillProvider::OnFormsSeen(AutofillHandlerProxy* handler,
const std::vector<FormData>& forms,
const base::TimeTicks timestamp) {}
void TestAutofillProvider::OnHidePopup(AutofillHandlerProxy* handler) {}
void TestAutofillProvider::Reset(AutofillHandlerProxy* handler) {}
} // namespace autofill
......@@ -48,6 +48,7 @@ class TestAutofillProvider : public AutofillProvider {
void OnFormsSeen(AutofillHandlerProxy* handler,
const std::vector<FormData>& forms,
const base::TimeTicks timestamp) override;
void OnHidePopup(AutofillHandlerProxy* handler) override;
void Reset(AutofillHandlerProxy* handler) override;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment