Revert "[Autofill Assistant] Displays the difference in Details if there is any."
This reverts commit 04f43afbf0a81bb0d74b7e01d08bc4d35dc3e3f1.
Reason for revert: Looks like causing compile failure on Android CFI
https://ci.chromium.org/p/chromium/builders/luci.chromium.ci/Android%20CFI/3645
Original change's description:
> [Autofill Assistant] Displays the difference in Details if there is any.
>
> If there is a difference between current and new details it's
> highlighted and two chips are displayed; to allow move forward or
> go back (which closes CCT).
>
> Screenshot: https://screenshot.googleplex.com/kOoC3B1frUp
>
> Bug: 806868
> Change-Id: I95ff09c379398d5a5858aa3947d4c578f39b14c9
> Reviewed-on: https://chromium-review.googlesource.com/c/1335941
> Commit-Queue: Lukasz Suder <lsuder@chromium.org>
> Reviewed-by: Stephane Zermatten <szermatt@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#608759}
TBR=mcarlen@chromium.org,szermatt@chromium.org,lsuder@chromium.org
Change-Id: I1a08ce61aedff0b51c7f71c27cd238e8359c0640
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 806868
Reviewed-on: https://chromium-review.googlesource.com/c/1340368
Reviewed-by: Ella Ge <eirage@chromium.org>
Commit-Queue: Ella Ge <eirage@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608790}
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantFacade.java b/chrome/android/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantFacade.java
index 1b02e48..114c14f 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantFacade.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantFacade.java
@@ -13,15 +13,26 @@
import org.chromium.chrome.browser.tabmodel.TabModel;
import org.chromium.chrome.browser.tabmodel.TabModel.TabSelectionType;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
import java.util.HashMap;
+import java.util.Locale;
import java.util.Map;
/** Facade for starting Autofill Assistant on a custom tab. */
public class AutofillAssistantFacade {
+ private static final String RFC_3339_FORMAT_WITHOUT_TIMEZONE = "yyyy'-'MM'-'dd'T'HH':'mm':'ss";
+
/** Prefix for Intent extras relevant to this feature. */
private static final String INTENT_EXTRA_PREFIX =
"org.chromium.chrome.browser.autofill_assistant.";
+ /** Autofill Assistant Study name. */
+ private static final String STUDY_NAME = "AutofillAssistant";
+
+ /** Variation url parameter name. */
+ private static final String URL_PARAMETER_NAME = "url";
/** Special parameter that enables the feature. */
private static final String PARAMETER_ENABLED = "ENABLED";
@@ -46,7 +57,8 @@
controller.setUiDelegateHolder(delegateHolder);
initTabObservers(activity, delegateHolder);
- controller.maybeUpdateDetails(Details.makeFromParameters(parameters));
+ AutofillAssistantUiDelegate.Details initialDetails = makeDetailsFromParameters(parameters);
+ controller.maybeUpdateDetails(initialDetails);
uiDelegate.startOrSkipInitScreen();
}
@@ -91,4 +103,38 @@
}
return result;
}
+
+ // TODO(crbug.com/806868): Create a fallback when there are no parameters for details.
+ // TODO(crbug.com/806868): Create a fallback when there are no parameters for details.
+ private static AutofillAssistantUiDelegate.Details makeDetailsFromParameters(
+ Map<String, String> parameters) {
+ String title = "";
+ String description = "";
+ Date date = null;
+ for (String key : parameters.keySet()) {
+ if (key.contains("E_NAME")) {
+ title = parameters.get(key);
+ continue;
+ }
+
+ if (key.contains("R_NAME")) {
+ description = parameters.get(key);
+ continue;
+ }
+
+ if (key.contains("DATETIME")) {
+ try {
+ // The parameter contains the timezone shift from the current location, that we
+ // don't care about.
+ date = new SimpleDateFormat(RFC_3339_FORMAT_WITHOUT_TIMEZONE, Locale.ROOT)
+ .parse(parameters.get(key));
+ } catch (ParseException e) {
+ // Ignore.
+ }
+ }
+ }
+
+ return new AutofillAssistantUiDelegate.Details(
+ title, /* url= */ "", date, description, /* isFinal= */ false);
+ }
}
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantUiController.java b/chrome/android/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantUiController.java
index 6da07a3..919183c 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantUiController.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantUiController.java
@@ -24,7 +24,6 @@
import java.util.ArrayList;
import java.util.Calendar;
-import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -35,6 +34,13 @@
*/
@JNINamespace("autofill_assistant")
public class AutofillAssistantUiController implements AutofillAssistantUiDelegate.Client {
+ /** Prefix for Intent extras relevant to this feature. */
+ private static final String INTENT_EXTRA_PREFIX =
+ "org.chromium.chrome.browser.autofill_assistant.";
+
+ /** Special parameter that enables the feature. */
+ private static final String PARAMETER_ENABLED = "ENABLED";
+
/** OAuth2 scope that RPCs require. */
private static final String AUTH_TOKEN_TYPE =
"oauth2:https://www.googleapis.com/auth/userinfo.profile";
@@ -43,7 +49,8 @@
private final String mInitialUrl;
// TODO(crbug.com/806868): Move mCurrentDetails and mStatusMessage to a Model (refactor to MVC).
- private Details mCurrentDetails = Details.EMPTY_DETAILS;
+ private AutofillAssistantUiDelegate.Details mCurrentDetails =
+ AutofillAssistantUiDelegate.Details.getEmptyDetails();
private String mStatusMessage;
/** Native pointer to the UIController. */
@@ -76,7 +83,6 @@
CustomTabActivity activity, Map<String, String> parameters) {
mWebContents = activity.getActivityTab().getWebContents();
mInitialUrl = activity.getInitialIntent().getDataString();
-
mUiControllerAndroid =
nativeInit(mWebContents, parameters.keySet().toArray(new String[parameters.size()]),
parameters.values().toArray(new String[parameters.size()]),
@@ -106,7 +112,7 @@
}
@Override
- public Details getDetails() {
+ public AutofillAssistantUiDelegate.Details getDetails() {
return mCurrentDetails;
}
@@ -146,12 +152,6 @@
}
@Override
- public void onDetailsAcknowledged(Details displayedDetails, boolean canContinue) {
- mCurrentDetails = displayedDetails;
- nativeOnShowDetails(mUiControllerAndroid, canContinue);
- }
-
- @Override
public String getDebugContext() {
return nativeOnRequestDebugContext(mUiControllerAndroid);
}
@@ -198,11 +198,6 @@
}
@CalledByNative
- private void onCloseCustomTab() {
- mUiDelegateHolder.closeCustomTab();
- }
-
- @CalledByNative
private void onShutdownGracefully() {
mUiDelegateHolder.enterGracefulShutdownMode();
}
@@ -277,16 +272,21 @@
/**
* Updates the currently shown details.
*
- * @param newDetails details to display.
+ * @return false if details were rejected.
*/
- void maybeUpdateDetails(Details newDetails) {
- if (mCurrentDetails.isEmpty() && newDetails.isEmpty()) {
- // No update on UI needed.
- nativeOnShowDetails(mUiControllerAndroid, /* canContinue= */ true);
+ boolean maybeUpdateDetails(AutofillAssistantUiDelegate.Details newDetails) {
+ if (!mCurrentDetails.isSimilarTo(newDetails)) {
+ return false;
}
- Details mergedDetails = Details.merge(mCurrentDetails, newDetails);
- mUiDelegateHolder.performUiOperation(uiDelegate -> uiDelegate.showDetails(mergedDetails));
+ if (mCurrentDetails.isEmpty() && newDetails.isEmpty()) {
+ // No update on UI needed.
+ return true;
+ }
+
+ mCurrentDetails = AutofillAssistantUiDelegate.Details.merge(mCurrentDetails, newDetails);
+ mUiDelegateHolder.performUiOperation(uiDelegate -> uiDelegate.showDetails(mCurrentDetails));
+ return true;
}
@CalledByNative
@@ -295,7 +295,7 @@
}
@CalledByNative
- private void onShowDetails(String title, String url, String description, int year, int month,
+ private boolean onShowDetails(String title, String url, String description, int year, int month,
int day, int hour, int minute, int second) {
Date date;
if (year > 0 && month > 0 && day > 0 && hour >= 0 && minute >= 0 && second >= 0) {
@@ -308,8 +308,8 @@
date = null;
}
- maybeUpdateDetails(new Details(
- title, url, date, description, /* isFinal= */ true, Collections.emptySet()));
+ return maybeUpdateDetails(new AutofillAssistantUiDelegate.Details(
+ title, url, date, description, /* isFinal= */ true));
}
@CalledByNative
@@ -449,7 +449,6 @@
private native void nativeOnScriptSelected(long nativeUiControllerAndroid, String scriptPath);
private native void nativeOnAddressSelected(long nativeUiControllerAndroid, String guid);
private native void nativeOnCardSelected(long nativeUiControllerAndroid, String guid);
- private native void nativeOnShowDetails(long nativeUiControllerAndroid, boolean canContinue);
private native void nativeOnGetPaymentInformation(long nativeUiControllerAndroid,
boolean succeed, @Nullable PersonalDataManager.CreditCard card,
@Nullable PersonalDataManager.AutofillProfile address, @Nullable String payerName,
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantUiDelegate.java b/chrome/android/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantUiDelegate.java
index caf98ea..b311007 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantUiDelegate.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantUiDelegate.java
@@ -12,7 +12,6 @@
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.RectF;
-import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.media.ThumbnailUtils;
@@ -35,16 +34,18 @@
import android.widget.LinearLayout;
import android.widget.TextView;
+import org.json.JSONObject;
+
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.Callback;
import org.chromium.chrome.autofill_assistant.R;
+import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.autofill.PersonalDataManager.AutofillProfile;
import org.chromium.chrome.browser.autofill.PersonalDataManager.CreditCard;
import org.chromium.chrome.browser.autofill_assistant.ui.BottomBarAnimations;
import org.chromium.chrome.browser.autofill_assistant.ui.TouchEventFilter;
import org.chromium.chrome.browser.cached_image_fetcher.CachedImageFetcher;
import org.chromium.chrome.browser.compositor.layouts.ChromeAnimation;
-import org.chromium.chrome.browser.customtabs.CustomTabActivity;
import org.chromium.chrome.browser.help.HelpAndFeedback;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.snackbar.Snackbar;
@@ -52,13 +53,14 @@
import org.chromium.content_public.browser.WebContents;
import org.chromium.payments.mojom.PaymentOptions;
-import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
+import java.util.HashMap;
import java.util.List;
import java.util.Locale;
+import java.util.Map;
/** Delegate to interact with the assistant UI. */
class AutofillAssistantUiDelegate {
@@ -70,20 +72,15 @@
/** How long the snackbars created by {@link #showAutofillAssistantStoppedSnackbar} stay up. */
static final int SNACKBAR_DELAY_MS = 5_000;
+ // TODO(crbug.com/806868): Use correct user locale and remove suppressions.
@SuppressLint("ConstantLocale")
- private static final SimpleDateFormat sDetailsTimeFormat;
- static {
- DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT, Locale.getDefault());
- String timeFormatPattern =
- (df instanceof SimpleDateFormat) ? ((SimpleDateFormat) df).toPattern() : "H:mm";
- sDetailsTimeFormat = new SimpleDateFormat(timeFormatPattern, Locale.getDefault());
- }
-
+ private static final SimpleDateFormat sDetailsTimeFormat =
+ new SimpleDateFormat("H:mma", Locale.getDefault());
@SuppressLint("ConstantLocale")
private static final SimpleDateFormat sDetailsDateFormat =
new SimpleDateFormat("EEE, MMM d", Locale.getDefault());
- private final CustomTabActivity mActivity;
+ private final ChromeActivity mActivity;
private final Client mClient;
private final ViewGroup mCoordinatorView;
private final View mFullContainer;
@@ -144,14 +141,6 @@
void onCardSelected(String guid);
/**
- * Called when button for acknowledging Details differ was clicked.
- *
- * @param displayedDetails Details that were shown.
- * @param canContinue Whether the permission to continue was granted.
- */
- void onDetailsAcknowledged(Details displayedDetails, boolean canContinue);
-
- /**
* Returns current details.
*/
Details getDetails();
@@ -208,6 +197,107 @@
}
}
+ /**
+ * Java side equivalent of autofill_assistant::DetailsProto.
+ */
+ static class Details {
+ private final String mTitle;
+ private final String mUrl;
+ @Nullable
+ private final Date mDate;
+ private final String mDescription;
+ private final boolean mIsFinal;
+
+ private static final Details EMPTY_DETAILS = new Details("", "", null, "", false);
+
+ public Details(String title, String url, @Nullable Date date, String description,
+ boolean isFinal) {
+ this.mTitle = title;
+ this.mUrl = url;
+ this.mDate = date;
+ this.mDescription = description;
+ this.mIsFinal = isFinal;
+ }
+
+ String getTitle() {
+ return mTitle;
+ }
+
+ String getUrl() {
+ return mUrl;
+ }
+
+ @Nullable
+ Date getDate() {
+ return mDate;
+ }
+
+ String getDescription() {
+ return mDescription;
+ }
+
+ JSONObject toJSONObject() {
+ // Details are part of the feedback form, hence they need a JSON representation.
+ Map<String, String> movieDetails = new HashMap<>();
+ movieDetails.put("title", mTitle);
+ movieDetails.put("url", mUrl);
+ if (mDate != null) movieDetails.put("date", mDate.toString());
+ movieDetails.put("description", mDescription);
+ return new JSONObject(movieDetails);
+ }
+
+ /**
+ * Whether the details are not subject to change anymore. If set to false the animated
+ * placeholders will be displayed in place of missing data.
+ */
+ boolean isFinal() {
+ return mIsFinal;
+ }
+
+ boolean isEmpty() {
+ return mTitle.isEmpty() && mUrl.isEmpty() && mDescription.isEmpty() && mDate == null;
+ }
+
+ /**
+ * Returns true {@code details} are similar to {@code this}. In order for details to be
+ * similar the conditions apply:
+ *
+ * <p>
+ * <ul>
+ * <li> Same date.
+ * <li> TODO(crbug.com/806868): 60% of characters match within title.
+ * </ul>
+ */
+ boolean isSimilarTo(AutofillAssistantUiDelegate.Details details) {
+ if (this.isEmpty() || details.isEmpty()) {
+ return true;
+ }
+
+ return this.getDate().equals(details.getDate());
+ }
+
+ static Details getEmptyDetails() {
+ return EMPTY_DETAILS;
+ }
+
+ /**
+ * Merges {@code oldDetails} with the {@code newDetails} filling the missing fields. The
+ * distinction is important, as the fields from old version take precedence, with the
+ * exception of isFinal field.
+ */
+ static Details merge(Details oldDetails, Details newDetails) {
+ String title =
+ oldDetails.getTitle().isEmpty() ? newDetails.getTitle() : oldDetails.getTitle();
+ String url = oldDetails.getUrl().isEmpty() ? newDetails.getUrl() : oldDetails.getUrl();
+ Date date = oldDetails.getDate() == null ? newDetails.getDate() : oldDetails.getDate();
+ String description = oldDetails.getDescription().isEmpty()
+ ? newDetails.getDescription()
+ : oldDetails.getDescription();
+ boolean isFinal = newDetails.isFinal();
+ return new Details(title, url, date, description, isFinal);
+ }
+ }
+
// Names borrowed from :
// - https://guidelines.googleplex.com/googlematerial/components/chips.html
// - https://guidelines.googleplex.com/googlematerial/components/buttons.html
@@ -219,7 +309,7 @@
* @param activity The ChromeActivity
* @param client The client to forward events to
*/
- public AutofillAssistantUiDelegate(CustomTabActivity activity, Client client) {
+ public AutofillAssistantUiDelegate(ChromeActivity activity, Client client) {
mActivity = activity;
mClient = client;
@@ -437,13 +527,6 @@
mBottomBarAnimations.hideCarousel();
}
- /**
- * Closes the Chrome Custom Tab.
- */
- public void closeCustomTab() {
- mActivity.finishAndClose(false);
- }
-
/** Called to show overlay. */
public void showOverlay() {
mTouchEventFilter.setEnableFiltering(true);
@@ -463,11 +546,7 @@
showStatusMessage(mActivity.getString(R.string.autofill_assistant_give_up));
}
- /**
- * Shows the details.
- *
- * <p>If some fields changed compared to the old details, the diff mode is entered.
- * */
+ /** Called to show contextual information. */
public void showDetails(Details details) {
Drawable defaultImage = AppCompatResources.getDrawable(
mActivity, R.drawable.autofill_assistant_default_details);
@@ -475,12 +554,13 @@
updateDetailsAnimation(details, (GradientDrawable) defaultImage);
mDetailsTitle.setText(details.getTitle());
- mDetailsText.setText(makeDetailsText(details));
+ String detailsText = getDetailsText(details);
+ mDetailsText.setText(detailsText);
String url = details.getUrl();
if (!url.isEmpty()) {
- // The URL is safe because it comes from the knowledge graph and is hosted on Google
- // servers.
+ // The URL is safe given because it comes from the knowledge graph and is hosted on
+ // Google servers.
CachedImageFetcher.getInstance().fetchImage(url, image -> {
if (image != null) {
mDetailsImage.setImageDrawable(getRoundedImage(image));
@@ -500,61 +580,6 @@
// Make sure the Autofill Assistant is visible.
show();
mBottomBarAnimations.showDetails();
-
- boolean shouldShowDiffMode = details.getFieldsChanged().size() > 0;
- if (shouldShowDiffMode) {
- enableDiffModeForDetails(details);
- } else {
- mClient.onDetailsAcknowledged(details, /* canContinue= */ true);
- }
- }
-
- /**
- * Shows additional UI elements asking to confirm details change.
- *
- * TODO(crbug.com/806868): Create own Controller for managing details state.
- */
- private void enableDiffModeForDetails(Details details) {
- enableProgressBarPulsing();
- // For detailsText we compare only Date.
- if (details.getFieldsChanged().contains(Details.DetailsField.DATE)) {
- mDetailsText.setTypeface(mDetailsText.getTypeface(), Typeface.BOLD_ITALIC);
- } else {
- mDetailsText.setTextColor(ApiCompatibilityUtils.getColor(
- mActivity.getResources(), R.color.modern_grey_300));
- }
-
- if (!details.getFieldsChanged().contains(Details.DetailsField.TITLE)) {
- mDetailsTitle.setTextColor(ApiCompatibilityUtils.getColor(
- mActivity.getResources(), R.color.modern_grey_300));
- }
-
- // Show new UI parts.
- String oldMessage = mClient.getStatusMessage();
- showStatusMessage(mActivity.getString(R.string.autofill_assistant_details_differ));
-
- ArrayList<View> childViews = new ArrayList<>();
- TextView continueChip = createChipView(
- mActivity.getString(R.string.continue_button), ChipStyle.BUTTON_FILLED);
- continueChip.setOnClickListener(unusedView -> {
- // Reset UI changes.
- ApiCompatibilityUtils.setTextAppearance(mDetailsTitle, R.style.BlackCaptionDefault);
- mDetailsTitle.setTypeface(mDetailsTitle.getTypeface(), Typeface.BOLD);
- ApiCompatibilityUtils.setTextAppearance(mDetailsText, R.style.BlackCaption);
- clearCarousel();
- showStatusMessage(oldMessage);
- disableProgressBarPulsing();
-
- mClient.onDetailsAcknowledged(details, /* canContinue= */ true);
- });
- childViews.add(continueChip);
- TextView cancelChip = createChipView(
- mActivity.getString(R.string.autofill_assistant_details_differ_go_back),
- ChipStyle.BUTTON_HAIRLINE);
- cancelChip.setOnClickListener(
- unusedView -> mClient.onDetailsAcknowledged(details, /* canContinue= */ false));
- childViews.add(cancelChip);
- setCarouselChildViews(childViews, /* alignRight= */ true);
}
private void updateDetailsAnimation(Details details, GradientDrawable defaultImage) {
@@ -588,7 +613,7 @@
if (details.getTitle().isEmpty()) {
mDetailsTitle.setBackgroundColor((int) animation.getAnimatedValue());
}
- if (makeDetailsText(details).isEmpty()) {
+ if (getDetailsText(details).isEmpty()) {
mDetailsText.setBackgroundColor((int) animation.getAnimatedValue());
}
defaultImage.setColor((int) animation.getAnimatedValue());
@@ -597,18 +622,17 @@
}
}
- /** Creates text for display based on date and description.*/
- private String makeDetailsText(Details details) {
+ private String getDetailsText(Details details) {
List<String> parts = new ArrayList<>();
-
Date date = details.getDate();
if (date != null) {
parts.add(sDetailsTimeFormat.format(date).toLowerCase(Locale.getDefault()));
parts.add(sDetailsDateFormat.format(date));
}
- if (details.getDescription() != null && !details.getDescription().isEmpty()) {
- parts.add(details.getDescription());
+ String description = details.getDescription();
+ if (description != null && !description.isEmpty()) {
+ parts.add(description);
}
// TODO(crbug.com/806868): Use a view instead of this dot text.
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/autofill_assistant/Details.java b/chrome/android/java/src/org/chromium/chrome/browser/autofill_assistant/Details.java
deleted file mode 100644
index ef7ffde9..0000000
--- a/chrome/android/java/src/org/chromium/chrome/browser/autofill_assistant/Details.java
+++ /dev/null
@@ -1,162 +0,0 @@
-// Copyright 2018 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;
-
-import android.support.annotation.Nullable;
-
-import org.json.JSONObject;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Java side equivalent of autofill_assistant::DetailsProto.
- */
-class Details {
- enum DetailsField { TITLE, URL, DATE, DESCRIPTION, IS_FINAL }
-
- private final String mTitle;
- private final String mUrl;
- @Nullable
- private final Date mDate;
- private final String mDescription;
- private final boolean mIsFinal;
- /** Contains the fields that have changed when merging with other Details object. */
- private final Set<DetailsField> mFieldsChanged;
- // NOTE: When adding a new field, update the isEmpty method.
-
- static final Details EMPTY_DETAILS =
- new Details("", "", null, "", false, Collections.emptySet());
-
- private static final String RFC_3339_FORMAT_WITHOUT_TIMEZONE = "yyyy'-'MM'-'dd'T'HH':'mm':'ss";
-
- Details(String title, String url, @Nullable Date date, String description, boolean isFinal,
- Set<DetailsField> fieldsChanged) {
- this.mTitle = title;
- this.mUrl = url;
- this.mDate = date;
- this.mDescription = description;
- this.mIsFinal = isFinal;
- this.mFieldsChanged = fieldsChanged;
- }
-
- String getTitle() {
- return mTitle;
- }
-
- String getUrl() {
- return mUrl;
- }
-
- @Nullable
- Date getDate() {
- return mDate;
- }
-
- String getDescription() {
- return mDescription;
- }
-
- JSONObject toJSONObject() {
- // Details are part of the feedback form, hence they need a JSON representation.
- Map<String, String> movieDetails = new HashMap<>();
- movieDetails.put("title", mTitle);
- movieDetails.put("url", mUrl);
- if (mDate != null) movieDetails.put("date", mDate.toString());
- movieDetails.put("description", mDescription);
- return new JSONObject(movieDetails);
- }
-
- /**
- * Whether the details are not subject to change anymore. If set to false the animated
- * placeholders will be displayed in place of missing data.
- */
- boolean isFinal() {
- return mIsFinal;
- }
-
- Set<DetailsField> getFieldsChanged() {
- return mFieldsChanged;
- }
-
- boolean isEmpty() {
- return mTitle.isEmpty() && mUrl.isEmpty() && mDescription.isEmpty() && mDate == null;
- }
-
- // TODO(crbug.com/806868): Create a fallback when there are no parameters for details.
- static Details makeFromParameters(Map<String, String> parameters) {
- String title = "";
- String description = "";
- Date date = null;
- for (String key : parameters.keySet()) {
- if (key.contains("E_NAME")) {
- title = parameters.get(key);
- continue;
- }
-
- if (key.contains("R_NAME")) {
- description = parameters.get(key);
- continue;
- }
-
- if (key.contains("DATETIME")) {
- try {
- // The parameter contains the timezone shift from the current location, that we
- // don't care about.
- date = new SimpleDateFormat(RFC_3339_FORMAT_WITHOUT_TIMEZONE, Locale.ROOT)
- .parse(parameters.get(key));
- } catch (ParseException e) {
- // Ignore.
- }
- }
- }
-
- return new Details(title, /* url= */ "", date, description, /* isFinal= */ false,
- /* fieldsChanged= */ Collections.emptySet());
- }
-
- /**
- * Merges {@param oldDetails} with the {@param newDetails} filling the missing fields.
- *
- * <p>The distinction is important, as the fields from old version take precedence, with the
- * exception of date and isFinal fields.
- *
- * <p>If {@param oldDetails} are empty copy of {@param newDetails} with empty
- * {@code changedFields} is returned
- */
- static Details merge(Details oldDetails, Details newDetails) {
- if (oldDetails.isEmpty()) {
- return new Details(newDetails.getTitle(), newDetails.getUrl(), newDetails.getDate(),
- newDetails.getDescription(), newDetails.isFinal(), Collections.emptySet());
- }
-
- Set<DetailsField> changedFields = new HashSet<>();
-
- // TODO(crbug.com/806868): Change title if mid doesn't match.
- String title =
- oldDetails.getTitle().isEmpty() ? newDetails.getTitle() : oldDetails.getTitle();
- String url = oldDetails.getUrl().isEmpty() ? newDetails.getUrl() : oldDetails.getUrl();
-
- Date date = oldDetails.getDate();
- if (newDetails.getDate() != null && oldDetails.getDate() != null
- && !newDetails.getDate().equals(oldDetails.getDate())) {
- changedFields.add(DetailsField.DATE);
- date = newDetails.getDate();
- }
-
- String description = oldDetails.getDescription().isEmpty() ? newDetails.getDescription()
- : oldDetails.getDescription();
-
- boolean isFinal = newDetails.isFinal();
- return new Details(title, url, date, description, isFinal, changedFields);
- }
-}
\ No newline at end of file
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/autofill_assistant/FeedbackContext.java b/chrome/android/java/src/org/chromium/chrome/browser/autofill_assistant/FeedbackContext.java
index da5d34f..37655452 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/autofill_assistant/FeedbackContext.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/autofill_assistant/FeedbackContext.java
@@ -14,8 +14,8 @@
* Automatically extracts context information and serializes it in JSON form.
*/
class FeedbackContext extends JSONObject {
- static String buildContextString(ChromeActivity activity, Client client, Details details,
- String statusMessage, int indentSpaces) {
+ static String buildContextString(ChromeActivity activity, Client client,
+ AutofillAssistantUiDelegate.Details details, String statusMessage, int indentSpaces) {
try {
return new FeedbackContext(activity, client, details, statusMessage)
.toString(indentSpaces);
@@ -24,8 +24,9 @@
}
}
- private FeedbackContext(ChromeActivity activity, Client client, Details details,
- String statusMessage) throws JSONException {
+ private FeedbackContext(ChromeActivity activity, Client client,
+ AutofillAssistantUiDelegate.Details details, String statusMessage)
+ throws JSONException {
addActivityInformation(activity);
addClientContext(client);
put("movie", details.toJSONObject());
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/autofill_assistant/UiDelegateHolder.java b/chrome/android/java/src/org/chromium/chrome/browser/autofill_assistant/UiDelegateHolder.java
index 34217fb..be4d1ef 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/autofill_assistant/UiDelegateHolder.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/autofill_assistant/UiDelegateHolder.java
@@ -130,14 +130,6 @@
}
/**
- * Closes the Chrome Custom Tab.
- */
- void closeCustomTab() {
- shutdown();
- mUiDelegate.closeCustomTab();
- }
-
- /**
* Pause all UI operations such that they can potentially be ran later using {@link
* #unpauseUiOperations()}.
*/
diff --git a/chrome/android/java_sources.gni b/chrome/android/java_sources.gni
index 9ee529c3..f76e32a7 100644
--- a/chrome/android/java_sources.gni
+++ b/chrome/android/java_sources.gni
@@ -130,7 +130,6 @@
"java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantStudy.java",
"java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantUiController.java",
"java/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantUiDelegate.java",
- "java/src/org/chromium/chrome/browser/autofill_assistant/Details.java",
"java/src/org/chromium/chrome/browser/autofill_assistant/FeedbackContext.java",
"java/src/org/chromium/chrome/browser/autofill_assistant/UiDelegateHolder.java",
"java/src/org/chromium/chrome/browser/autofill_assistant/ui/BottomBarAnimations.java",
diff --git a/chrome/browser/android/autofill_assistant/ui_controller_android.cc b/chrome/browser/android/autofill_assistant/ui_controller_android.cc
index 89716ac..c00d3b0 100644
--- a/chrome/browser/android/autofill_assistant/ui_controller_android.cc
+++ b/chrome/browser/android/autofill_assistant/ui_controller_android.cc
@@ -131,11 +131,6 @@
AttachCurrentThread(), java_autofill_assistant_ui_controller_);
}
-void UiControllerAndroid::CloseCustomTab() {
- Java_AutofillAssistantUiController_onCloseCustomTab(
- AttachCurrentThread(), java_autofill_assistant_ui_controller_);
-}
-
void UiControllerAndroid::UpdateScripts(
const std::vector<ScriptHandle>& scripts) {
std::vector<std::string> script_paths;
@@ -259,14 +254,6 @@
}
}
-void UiControllerAndroid::OnShowDetails(JNIEnv* env,
- const JavaParamRef<jobject>& jcaller,
- jboolean jcan_continue) {
- if (show_details_callback_) {
- std::move(show_details_callback_).Run(jcan_continue);
- }
-}
-
base::android::ScopedJavaLocalRef<jstring>
UiControllerAndroid::GetPrimaryAccountName(
JNIEnv* env,
@@ -325,9 +312,7 @@
AttachCurrentThread(), java_autofill_assistant_ui_controller_);
}
-void UiControllerAndroid::ShowDetails(const DetailsProto& details,
- base::OnceCallback<void(bool)> callback) {
- show_details_callback_ = std::move(callback);
+bool UiControllerAndroid::ShowDetails(const DetailsProto& details) {
int year = details.datetime().date().year();
int month = details.datetime().date().month();
int day = details.datetime().date().day();
diff --git a/chrome/browser/android/autofill_assistant/ui_controller_android.h b/chrome/browser/android/autofill_assistant/ui_controller_android.h
index 4259ff8..b6fc32a 100644
--- a/chrome/browser/android/autofill_assistant/ui_controller_android.h
+++ b/chrome/browser/android/autofill_assistant/ui_controller_android.h
@@ -42,7 +42,6 @@
void HideOverlay() override;
void Shutdown() override;
void ShutdownGracefully() override;
- void CloseCustomTab() override;
void UpdateScripts(const std::vector<ScriptHandle>& scripts) override;
void ChooseAddress(
base::OnceCallback<void(const std::string&)> callback) override;
@@ -54,8 +53,7 @@
const std::string& title,
const std::vector<std::string>& supported_basic_card_networks) override;
void HideDetails() override;
- void ShowDetails(const DetailsProto& details,
- base::OnceCallback<void(bool)> callback) override;
+ bool ShowDetails(const DetailsProto& details) override;
void ShowProgressBar(int progress, const std::string& message) override;
void HideProgressBar() override;
void UpdateTouchableArea(bool enabled,
@@ -110,9 +108,6 @@
const base::android::JavaParamRef<jobject>& jcaller,
jboolean success,
const base::android::JavaParamRef<jstring>& access_token);
- void OnShowDetails(JNIEnv* env,
- const base::android::JavaParamRef<jobject>& jcaller,
- jboolean success);
base::android::ScopedJavaLocalRef<jstring> GetPrimaryAccountName(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& jcaller);
@@ -134,7 +129,6 @@
std::unique_ptr<AccessTokenFetcher> access_token_fetcher_;
base::OnceCallback<void(bool, const std::string&)>
fetch_access_token_callback_;
- base::OnceCallback<void(bool)> show_details_callback_;
DISALLOW_COPY_AND_ASSIGN(UiControllerAndroid);
};
diff --git a/components/autofill_assistant/browser/actions/action_delegate.h b/components/autofill_assistant/browser/actions/action_delegate.h
index cd2f549..91e066a 100644
--- a/components/autofill_assistant/browser/actions/action_delegate.h
+++ b/components/autofill_assistant/browser/actions/action_delegate.h
@@ -138,9 +138,6 @@
// Shut down Autofill Assistant at the end of the current script.
virtual void Shutdown() = 0;
- // Shut down Autofill Assistant and close the CCT.
- virtual void CloseCustomTab() = 0;
-
// Restart Autofill Assistant at the end of the current script with a cleared
// state.
virtual void Restart() = 0;
@@ -162,8 +159,7 @@
virtual void HideDetails() = 0;
// Show contextual information.
- virtual void ShowDetails(const DetailsProto& details,
- base::OnceCallback<void(bool)> callback) = 0;
+ virtual bool ShowDetails(const DetailsProto& details) = 0;
// Show the progress bar with |message| and set it at |progress|%.
virtual void ShowProgressBar(int progress, const std::string& message) = 0;
diff --git a/components/autofill_assistant/browser/actions/mock_action_delegate.h b/components/autofill_assistant/browser/actions/mock_action_delegate.h
index 2040c78..8d22fe5 100644
--- a/components/autofill_assistant/browser/actions/mock_action_delegate.h
+++ b/components/autofill_assistant/browser/actions/mock_action_delegate.h
@@ -122,16 +122,13 @@
base::OnceCallback<void(bool, const std::string&)> callback));
MOCK_METHOD1(LoadURL, void(const GURL& url));
MOCK_METHOD0(Shutdown, void());
- MOCK_METHOD0(CloseCustomTab, void());
MOCK_METHOD0(Restart, void());
MOCK_METHOD0(GetClientMemory, ClientMemory*());
MOCK_METHOD0(GetPersonalDataManager, autofill::PersonalDataManager*());
MOCK_METHOD0(GetWebContents, content::WebContents*());
MOCK_METHOD1(StopCurrentScriptAndShutdown, void(const std::string& message));
MOCK_METHOD0(HideDetails, void());
- MOCK_METHOD2(ShowDetails,
- void(const DetailsProto& details,
- base::OnceCallback<void(bool)> callback));
+ MOCK_METHOD1(ShowDetails, bool(const DetailsProto& details));
MOCK_METHOD2(ShowProgressBar, void(int progress, const std::string& message));
MOCK_METHOD0(HideProgressBar, void());
MOCK_METHOD0(ShowOverlay, void());
diff --git a/components/autofill_assistant/browser/actions/show_details_action.cc b/components/autofill_assistant/browser/actions/show_details_action.cc
index be597dc9..c6cb880 100644
--- a/components/autofill_assistant/browser/actions/show_details_action.cc
+++ b/components/autofill_assistant/browser/actions/show_details_action.cc
@@ -11,8 +11,7 @@
namespace autofill_assistant {
-ShowDetailsAction::ShowDetailsAction(const ActionProto& proto)
- : Action(proto), weak_ptr_factory_(this) {
+ShowDetailsAction::ShowDetailsAction(const ActionProto& proto) : Action(proto) {
DCHECK(proto_.has_show_details());
}
@@ -25,20 +24,9 @@
UpdateProcessedAction(ACTION_APPLIED);
std::move(callback).Run(std::move(processed_action_proto_));
} else {
- delegate->ShowDetails(proto_.show_details().details(),
- base::BindOnce(&ShowDetailsAction::OnShowDetails,
- weak_ptr_factory_.GetWeakPtr(),
- std::move(callback), delegate));
+ bool result = delegate->ShowDetails(proto_.show_details().details());
+ UpdateProcessedAction(result ? ACTION_APPLIED : OTHER_ACTION_STATUS);
+ std::move(callback).Run(std::move(processed_action_proto_));
}
}
-
-void ShowDetailsAction::OnShowDetails(ProcessActionCallback callback,
- ActionDelegate* delegate,
- bool can_continue) {
- if (!can_continue) {
- delegate->CloseCustomTab();
- }
- UpdateProcessedAction(ACTION_APPLIED);
- std::move(callback).Run(std::move(processed_action_proto_));
-}
} // namespace autofill_assistant
diff --git a/components/autofill_assistant/browser/actions/show_details_action.h b/components/autofill_assistant/browser/actions/show_details_action.h
index 510fa03..1b66148b 100644
--- a/components/autofill_assistant/browser/actions/show_details_action.h
+++ b/components/autofill_assistant/browser/actions/show_details_action.h
@@ -6,7 +6,6 @@
#define COMPONENTS_AUTOFILL_ASSISTANT_BROWSER_ACTIONS_SHOW_DETAILS_ACTION_H_
#include "base/macros.h"
-#include "base/memory/weak_ptr.h"
#include "components/autofill_assistant/browser/actions/action.h"
namespace autofill_assistant {
@@ -20,11 +19,6 @@
// Overrides Action:
void InternalProcessAction(ActionDelegate* delegate,
ProcessActionCallback callback) override;
- void OnShowDetails(ProcessActionCallback callback,
- ActionDelegate* delegate,
- bool can_continue);
-
- base::WeakPtrFactory<ShowDetailsAction> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(ShowDetailsAction);
};
diff --git a/components/autofill_assistant/browser/controller.cc b/components/autofill_assistant/browser/controller.cc
index 3630ccd..c2a2b00 100644
--- a/components/autofill_assistant/browser/controller.cc
+++ b/components/autofill_assistant/browser/controller.cc
@@ -257,10 +257,6 @@
GetUiController()->ShutdownGracefully();
return;
- case ScriptExecutor::CLOSE_CUSTOM_TAB:
- GetUiController()->CloseCustomTab();
- return;
-
case ScriptExecutor::RESTART:
script_tracker_ = std::make_unique<ScriptTracker>(/* delegate= */ this,
/* listener= */ this);
diff --git a/components/autofill_assistant/browser/mock_ui_controller.h b/components/autofill_assistant/browser/mock_ui_controller.h
index b4b4293..9e782c0 100644
--- a/components/autofill_assistant/browser/mock_ui_controller.h
+++ b/components/autofill_assistant/browser/mock_ui_controller.h
@@ -27,7 +27,6 @@
MOCK_METHOD0(HideOverlay, void());
MOCK_METHOD0(Shutdown, void());
MOCK_METHOD0(ShutdownGracefully, void());
- MOCK_METHOD0(CloseCustomTab, void());
MOCK_METHOD1(UpdateScripts, void(const std::vector<ScriptHandle>& scripts));
void ChooseAddress(
@@ -51,9 +50,7 @@
const std::string& title,
const std::vector<std::string>& supported_basic_card_networks));
MOCK_METHOD0(HideDetails, void());
- MOCK_METHOD2(ShowDetails,
- void(const DetailsProto& details,
- base::OnceCallback<void(bool)> callback));
+ MOCK_METHOD1(ShowDetails, bool(const DetailsProto& details));
MOCK_METHOD2(ShowProgressBar, void(int progress, const std::string& message));
MOCK_METHOD0(HideProgressBar, void());
MOCK_METHOD2(UpdateTouchableArea,
diff --git a/components/autofill_assistant/browser/script_executor.cc b/components/autofill_assistant/browser/script_executor.cc
index 45d3f8e..bb3260f 100644
--- a/components/autofill_assistant/browser/script_executor.cc
+++ b/components/autofill_assistant/browser/script_executor.cc
@@ -205,11 +205,6 @@
}
}
-void ScriptExecutor::CloseCustomTab() {
- at_end_ = CLOSE_CUSTOM_TAB;
- should_stop_script_ = true;
-}
-
void ScriptExecutor::Restart() {
at_end_ = RESTART;
}
@@ -239,10 +234,8 @@
delegate_->GetUiController()->HideDetails();
}
-void ScriptExecutor::ShowDetails(const DetailsProto& details,
- base::OnceCallback<void(bool)> callback) {
- return delegate_->GetUiController()->ShowDetails(details,
- std::move(callback));
+bool ScriptExecutor::ShowDetails(const DetailsProto& details) {
+ return delegate_->GetUiController()->ShowDetails(details);
}
void ScriptExecutor::OnGetActions(bool result, const std::string& response) {
diff --git a/components/autofill_assistant/browser/script_executor.h b/components/autofill_assistant/browser/script_executor.h
index a57f4acc..08b57113 100644
--- a/components/autofill_assistant/browser/script_executor.h
+++ b/components/autofill_assistant/browser/script_executor.h
@@ -52,9 +52,6 @@
// Shut down Autofill Assistant after a delay.
SHUTDOWN_GRACEFULLY,
- // Shut down Autofill Assistant and CCT.
- CLOSE_CUSTOM_TAB,
-
// Reset all state and restart.
RESTART
};
@@ -118,15 +115,13 @@
base::OnceCallback<void(bool, const std::string&)> callback) override;
void LoadURL(const GURL& url) override;
void Shutdown() override;
- void CloseCustomTab() override;
void Restart() override;
ClientMemory* GetClientMemory() override;
autofill::PersonalDataManager* GetPersonalDataManager() override;
content::WebContents* GetWebContents() override;
void StopCurrentScriptAndShutdown(const std::string& message) override;
void HideDetails() override;
- void ShowDetails(const DetailsProto& details,
- base::OnceCallback<void(bool)> callback) override;
+ bool ShowDetails(const DetailsProto& details) override;
void ShowProgressBar(int progress, const std::string& message) override;
void HideProgressBar() override;
void ShowOverlay() override;
diff --git a/components/autofill_assistant/browser/ui_controller.h b/components/autofill_assistant/browser/ui_controller.h
index c53cf03..2826891 100644
--- a/components/autofill_assistant/browser/ui_controller.h
+++ b/components/autofill_assistant/browser/ui_controller.h
@@ -46,9 +46,6 @@
// Warning: this indirectly deletes the caller.
virtual void ShutdownGracefully() = 0;
- // Shuts down Autofill Assistant and closes CCT.
- virtual void CloseCustomTab();
-
// Update the list of scripts in the UI.
virtual void UpdateScripts(const std::vector<ScriptHandle>& scripts) = 0;
@@ -83,8 +80,7 @@
// not similar to the current one.
// TODO(806868): Pass details to the native side instead of comparing on the
// Java side.
- virtual void ShowDetails(const DetailsProto& details,
- base::OnceCallback<void(bool)> callback) = 0;
+ virtual bool ShowDetails(const DetailsProto& details) = 0;
// Show the progress bar with |message| and set it at |progress|%.
virtual void ShowProgressBar(int progress, const std::string& message) = 0;
diff --git a/components/autofill_assistant_strings.grdp b/components/autofill_assistant_strings.grdp
index 2bb6a97..1a0e36e 100644
--- a/components/autofill_assistant_strings.grdp
+++ b/components/autofill_assistant_strings.grdp
@@ -19,11 +19,5 @@
<message name="IDS_AUTOFILL_ASSISTANT_TERMS" desc="The text for the terms and service acceptance checkbox. Sentence-cased." formatter_data="android_java">
I know the terms and conditions, privacy policy and right of withdrawal of <ph name="BEGIN_BOLD"><b></ph><ph name="ORIGIN">%1$s<ex>google.com</ex></ph><ph name="END_BOLD"></b></ph> (leave unchecked to read).
</message>
- <message name="IDS_AUTOFILL_ASSISTANT_DETAILS_DIFFER" desc="Shown as Status Message when details differ." formatter_data="android_java">
- The movie screening is different, do you want to continue?
- </message>
- <message name="IDS_AUTOFILL_ASSISTANT_DETAILS_DIFFER_GO_BACK" desc="Shown on a button allowing going back when details differ." formatter_data="android_java">
- Go back
- </message>
</if>
</grit-part>