Commit 0602efcc authored by gogerald's avatar gogerald Committed by Commit Bot

[Autofill Assistant] Initial impl of OnClickOverlay

Bug: 806868
Change-Id: I22b21ccbb386e89d5ac2b0cd8d80e53cc14b447a
Reviewed-on: https://chromium-review.googlesource.com/c/1282362
Commit-Queue: Ganggui Tang <gogerald@chromium.org>
Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#599980}
parent 530a1ad5
......@@ -144,7 +144,7 @@ public class AutofillAssistantUiController implements AutofillAssistantUiDelegat
@Override
public void onClickOverlay() {
// TODO(crbug.com/806868): Notify native side.
nativeOnClickOverlay(mUiControllerAndroid);
}
@CalledByNative
......@@ -241,6 +241,7 @@ public class AutofillAssistantUiController implements AutofillAssistantUiDelegat
private native long nativeInit(
WebContents webContents, String[] parameterNames, String[] parameterValues);
private native void nativeDestroy(long nativeUiControllerAndroid);
private native void nativeOnClickOverlay(long nativeUiControllerAndroid);
private native void nativeOnScriptSelected(long nativeUiControllerAndroid, String scriptPath);
private native void nativeOnAddressSelected(long nativeUiControllerAndroid, String guid);
private native void nativeOnCardSelected(long nativeUiControllerAndroid, String guid);
......
......@@ -273,6 +273,12 @@ void UiControllerAndroid::Destroy(JNIEnv* env,
ui_delegate_->OnDestroy();
}
void UiControllerAndroid::OnClickOverlay(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& jcaller) {
ui_delegate_->OnClickOverlay();
}
static jlong JNI_AutofillAssistantUiController_Init(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& jcaller,
......
......@@ -51,6 +51,8 @@ class UiControllerAndroid : public UiController, public Client {
// Called by Java.
void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj);
void OnClickOverlay(JNIEnv* env,
const base::android::JavaParamRef<jobject>& jcaller);
void OnScriptSelected(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& jcaller,
......
......@@ -218,7 +218,7 @@ void Controller::OnScriptExecuted(const std::string& script_path,
void Controller::OnClickOverlay() {
GetUiController()->HideOverlay();
// TODO(crbug.com/806868): Stop executing scripts.
script_tracker_->StopExecuteScript();
}
void Controller::OnScriptSelected(const std::string& script_path) {
......
......@@ -42,6 +42,14 @@ void ScriptExecutor::Run(RunScriptCallback callback) {
weak_ptr_factory_.GetWeakPtr()));
}
void ScriptExecutor::Stop() {
// TODO(crbug.com/806868): Consider distinguish between stop by clicking
// overlay and manual fallback when choosing addresses and/or cards.
// Note that the script won't stop running immediately, but after finishing
// the running action.
should_stop_script_ = true;
}
std::unique_ptr<BatchElementChecker>
ScriptExecutor::CreateBatchElementChecker() {
return std::make_unique<BatchElementChecker>(delegate_->GetWebController());
......
......@@ -47,6 +47,11 @@ class ScriptExecutor : public ActionDelegate {
using RunScriptCallback = base::OnceCallback<void(Result)>;
void Run(RunScriptCallback callback);
// Stop the execution of the current script and notify caller with 'at_end =
// |CONTINUE|' as the result, so it can continue. It's different from the
// interfaces 'ShutDown' and 'Restart' below, which notify caller with 'at_end
// = SHUTDOWN' and 'at_end = RESTART' respectively.
void Stop();
// Override ActionDelegate:
std::unique_ptr<BatchElementChecker> CreateBatchElementChecker() override;
......
......@@ -98,6 +98,12 @@ void ScriptTracker::ExecuteScript(const std::string& script_path,
}
}
void ScriptTracker::StopExecuteScript() {
DCHECK(running());
executor_->Stop();
}
void ScriptTracker::ClearRunnableScripts() {
runnable_scripts_.clear();
listener_->OnRunnableScriptsChanged(runnable_scripts_);
......
......@@ -66,6 +66,11 @@ class ScriptTracker {
void ExecuteScript(const std::string& path,
ScriptExecutor::RunScriptCallback callback);
// Stops the current running script and other scripts can continue with the
// current status. Not like ShutDown and Restart by action, which will
// shutdown the whole module and clear current status respectively.
void StopExecuteScript();
// Clears the set of scripts that could be run.
//
// Calling this function will clean the bottom bar.
......
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