Commit 7f817a42 authored by Clemens Arbesser's avatar Clemens Arbesser Committed by Commit Bot

[Autofill Assistant] Moved events and interactions into dedicated files.

This is a refactoring only and should have no user-facing changes.

Bug: b/145043394
Change-Id: If820f681fefd486b7f0700800c610152339293d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2120353Reviewed-by: default avatarMarian Fechete <marianfe@google.com>
Commit-Queue: Clemens Arbesser <arbesser@google.com>
Cr-Commit-Position: refs/heads/master@{#753197}
parent f0a585c5
......@@ -120,6 +120,7 @@ android_library("java") {
"java/src/org/chromium/chrome/browser/autofill_assistant/generic_ui/AssistantGenericUiModel.java",
"java/src/org/chromium/chrome/browser/autofill_assistant/generic_ui/AssistantGenericUiViewBinder.java",
"java/src/org/chromium/chrome/browser/autofill_assistant/generic_ui/AssistantValue.java",
"java/src/org/chromium/chrome/browser/autofill_assistant/generic_ui/AssistantViewEvents.java",
"java/src/org/chromium/chrome/browser/autofill_assistant/generic_ui/AssistantViewFactory.java",
"java/src/org/chromium/chrome/browser/autofill_assistant/generic_ui/AssistantViewInteractions.java",
"java/src/org/chromium/chrome/browser/autofill_assistant/header/AnimatedProgressBar.java",
......@@ -185,6 +186,7 @@ generate_jni("jni_headers") {
"java/src/org/chromium/chrome/browser/autofill_assistant/generic_ui/AssistantGenericUiDelegate.java",
"java/src/org/chromium/chrome/browser/autofill_assistant/generic_ui/AssistantGenericUiModel.java",
"java/src/org/chromium/chrome/browser/autofill_assistant/generic_ui/AssistantValue.java",
"java/src/org/chromium/chrome/browser/autofill_assistant/generic_ui/AssistantViewEvents.java",
"java/src/org/chromium/chrome/browser/autofill_assistant/generic_ui/AssistantViewFactory.java",
"java/src/org/chromium/chrome/browser/autofill_assistant/generic_ui/AssistantViewInteractions.java",
"java/src/org/chromium/chrome/browser/autofill_assistant/header/AssistantHeaderDelegate.java",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.autofill_assistant.generic_ui;
import android.view.View;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
/** JNI bridge between {@code generic_ui_events_android} and Java. */
@JNINamespace("autofill_assistant")
public class AssistantViewEvents {
@CalledByNative
private static void setOnClickListener(
View view, String identifier, AssistantGenericUiDelegate delegate) {
view.setOnClickListener(unused -> delegate.onViewClicked(identifier));
}
}
......@@ -26,15 +26,9 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/** JNI bridge between {@code interaction_handler_android} and Java. */
/** JNI bridge between {@code generic_ui_interactions_android} and Java. */
@JNINamespace("autofill_assistant")
public class AssistantViewInteractions {
@CalledByNative
private static void setOnClickListener(
View view, String identifier, AssistantGenericUiDelegate delegate) {
view.setOnClickListener(unused -> delegate.onViewClicked(identifier));
}
@CalledByNative
private static void showListPopup(Context context, String[] itemNames,
@PopupItemType int[] itemTypes, int[] selectedItems, boolean multiple,
......
......@@ -2332,6 +2332,10 @@ jumbo_static_library("browser") {
"android/autofill_assistant/client_android.h",
"android/autofill_assistant/generic_ui_controller_android.cc",
"android/autofill_assistant/generic_ui_controller_android.h",
"android/autofill_assistant/generic_ui_events_android.cc",
"android/autofill_assistant/generic_ui_events_android.h",
"android/autofill_assistant/generic_ui_interactions_android.cc",
"android/autofill_assistant/generic_ui_interactions_android.h",
"android/autofill_assistant/interaction_handler_android.cc",
"android/autofill_assistant/interaction_handler_android.h",
"android/autofill_assistant/ui_controller_android.cc",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/android/autofill_assistant/generic_ui_events_android.h"
#include "base/android/jni_string.h"
#include "chrome/android/features/autofill_assistant/jni_headers/AssistantViewEvents_jni.h"
namespace autofill_assistant {
namespace android_events {
void SetOnClickListener(JNIEnv* env,
base::android::ScopedJavaGlobalRef<jobject> jview,
base::android::ScopedJavaGlobalRef<jobject> jdelegate,
const OnViewClickedEventProto& proto) {
Java_AssistantViewEvents_setOnClickListener(
env, jview,
base::android::ConvertUTF8ToJavaString(env, proto.view_identifier()),
jdelegate);
}
} // namespace android_events
} // namespace autofill_assistant
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_ANDROID_AUTOFILL_ASSISTANT_GENERIC_UI_EVENTS_ANDROID_H_
#define CHROME_BROWSER_ANDROID_AUTOFILL_ASSISTANT_GENERIC_UI_EVENTS_ANDROID_H_
#include <string>
#include "base/android/jni_android.h"
#include "base/android/scoped_java_ref.h"
#include "components/autofill_assistant/browser/interactions.pb.h"
namespace autofill_assistant {
namespace android_events {
// Sets a click listener for |jview|.
void SetOnClickListener(JNIEnv* env,
base::android::ScopedJavaGlobalRef<jobject> jview,
base::android::ScopedJavaGlobalRef<jobject> jdelegate,
const OnViewClickedEventProto& proto);
} // namespace android_events
} // namespace autofill_assistant
#endif // CHROME_BROWSER_ANDROID_AUTOFILL_ASSISTANT_GENERIC_UI_EVENTS_ANDROID_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_ANDROID_AUTOFILL_ASSISTANT_GENERIC_UI_INTERACTIONS_ANDROID_H_
#define CHROME_BROWSER_ANDROID_AUTOFILL_ASSISTANT_GENERIC_UI_INTERACTIONS_ANDROID_H_
#include <string>
#include "base/android/jni_android.h"
#include "base/android/scoped_java_ref.h"
#include "base/memory/weak_ptr.h"
#include "components/autofill_assistant/browser/basic_interactions.h"
#include "components/autofill_assistant/browser/interactions.pb.h"
namespace autofill_assistant {
namespace android_interactions {
// Writes a value to the model.
void SetValue(base::WeakPtr<BasicInteractions> basic_interactions,
const SetModelValueProto& proto);
// Computes a value and writes it to the model.
void ComputeValue(base::WeakPtr<BasicInteractions> basic_interactions,
const ComputeValueProto& proto);
// Sets the list of available user actions (i.e., chips and direct actions).
void SetUserActions(base::WeakPtr<BasicInteractions> basic_interactions,
const SetUserActionsProto& proto);
// Ends the current ShowGenericUi action.
void EndAction(base::WeakPtr<BasicInteractions> basic_interactions,
const EndActionProto& proto);
// Enables or disables a particular user action.
void ToggleUserAction(base::WeakPtr<BasicInteractions> basic_interactions,
const ToggleUserActionProto& proto);
// Displays an info popup on the screen.
void ShowInfoPopup(const InfoPopupProto& proto,
base::android::ScopedJavaGlobalRef<jobject> jcontext);
// Displays a list popup on the screen.
void ShowListPopup(base::WeakPtr<UserModel> user_model,
const ShowListPopupProto& proto,
base::android::ScopedJavaGlobalRef<jobject> jcontext,
base::android::ScopedJavaGlobalRef<jobject> jdelegate);
// Displays a calendar popup on the screen.
void ShowCalendarPopup(base::WeakPtr<UserModel> user_model,
const ShowCalendarPopupProto& proto,
base::android::ScopedJavaGlobalRef<jobject> jcontext,
base::android::ScopedJavaGlobalRef<jobject> jdelegate);
// Sets the text of a view.
void SetViewText(
base::WeakPtr<UserModel> user_model,
const SetTextProto& proto,
std::map<std::string, base::android::ScopedJavaGlobalRef<jobject>>* views);
// Sets the visibility of a view.
void SetViewVisibility(
base::WeakPtr<UserModel> user_model,
const SetViewVisibilityProto& proto,
std::map<std::string, base::android::ScopedJavaGlobalRef<jobject>>* views);
} // namespace android_interactions
} // namespace autofill_assistant
#endif // CHROME_BROWSER_ANDROID_AUTOFILL_ASSISTANT_GENERIC_UI_INTERACTIONS_ANDROID_H_
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