Commit 03fad82c authored by Lakshmi Kumar Dabbiru's avatar Lakshmi Kumar Dabbiru Committed by Commit Bot

Fix Name UI with recent changes

Latest UI - https://screenshot.googleplex.com/qqSuM2bvctM.png

UI + tool tip - https://screenshot.googleplex.com/RPZkrxgBdnN.png

Changes
1) Remove legal message from second screen as it is not needed
2) Add tool tip icon and adjust spacing for name.

UX is still working on final spaces to make it clean post Legal removal
message world. Would like to get this CL before M72 branch date,so dont need
to ask TPMs for merge. Small UI spacing fixes, can request TPMs.

Bug: 848955
Change-Id: Ia8a5cd4fe2c6751c1e169a58ac88123770838234
Reviewed-on: https://chromium-review.googlesource.com/c/1334509
Commit-Queue: Lakshmi Kumar Dabbiru <dlkumar@google.com>
Reviewed-by: default avatarBecky Zhou <huayinz@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Reviewed-by: default avatarFabio Tirelo <ftirelo@chromium.org>
Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Reviewed-by: default avatarChangwan Ryu <changwan@chromium.org>
Reviewed-by: default avatarJared Saul <jsaul@google.com>
Cr-Commit-Position: refs/heads/master@{#610959}
parent 336bb21b
...@@ -282,7 +282,6 @@ void AwAutofillClient::ShowLocalCardMigrationDialog( ...@@ -282,7 +282,6 @@ void AwAutofillClient::ShowLocalCardMigrationDialog(
} }
void AwAutofillClient::ConfirmAccountNameFixFlow( void AwAutofillClient::ConfirmAccountNameFixFlow(
std::unique_ptr<base::DictionaryValue> legal_message,
base::OnceCallback<void(const base::string16&)> callback) { base::OnceCallback<void(const base::string16&)> callback) {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
} }
......
...@@ -80,7 +80,6 @@ class AwAutofillClient : public autofill::AutofillClient, ...@@ -80,7 +80,6 @@ class AwAutofillClient : public autofill::AutofillClient,
void ShowLocalCardMigrationDialog( void ShowLocalCardMigrationDialog(
base::OnceClosure show_migration_dialog_closure) override; base::OnceClosure show_migration_dialog_closure) override;
void ConfirmAccountNameFixFlow( void ConfirmAccountNameFixFlow(
std::unique_ptr<base::DictionaryValue> legal_message,
base::OnceCallback<void(const base::string16&)> callback) override; base::OnceCallback<void(const base::string16&)> callback) override;
void ConfirmMigrateLocalCardToCloud( void ConfirmMigrateLocalCardToCloud(
std::unique_ptr<base::DictionaryValue> legal_message, std::unique_ptr<base::DictionaryValue> legal_message,
......
...@@ -8,44 +8,44 @@ ...@@ -8,44 +8,44 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/pref_autofill_field_horizontal_padding" style="@style/AlertDialogContent"
android:minHeight="36dp" android:minHeight="36dp"
android:orientation="vertical" android:orientation="vertical"
android:gravity="center_vertical"> android:gravity="center_vertical">
<TextView <LinearLayout
android:id="@+id/cc_name_label_text"
android:labelFor="@+id/cc_name"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/pref_autofill_field_top_margin" android:layout_marginBottom="14dp"
android:layout_marginEnd="@dimen/pref_autofill_field_horizontal_padding" android:orientation="horizontal">
android:textAppearance="@style/BlackCaption"
android:text="@string/autofill_credit_card_editor_name" />
<org.chromium.chrome.browser.widget.CompatibilityTextInputLayout <org.chromium.chrome.browser.widget.CompatibilityTextInputLayout
android:id="@+id/cc_name" android:id="@+id/cc_name"
android:labelFor="@+id/cc_name_edit" android:labelFor="@+id/cc_name_edit"
android:layout_width="match_parent" android:layout_marginTop="6dp"
android:layout_height="wrap_content"> android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content">
<!-- TODO(crbug.com/900912): Fix and remove lint ignore --> <!-- TODO(crbug.com/900912): Fix and remove lint ignore -->
<EditText <EditText
tools:ignore="Autofill,LabelFor" tools:ignore="Autofill,LabelFor"
android:id="@+id/cc_name_edit" android:id="@+id/cc_name_edit"
android:layout_width="match_parent" android:hint="@string/autofill_card_holder_name"
android:layout_height="wrap_content" android:layout_width="match_parent"
android:imeOptions="flagNoExtractUi" android:layout_height="wrap_content"
android:inputType="textCapWords"/> android:imeOptions="flagNoExtractUi"
android:inputType="textCapWords"/>
</org.chromium.chrome.browser.widget.CompatibilityTextInputLayout> </org.chromium.chrome.browser.widget.CompatibilityTextInputLayout>
<TextView <ImageView
android:id="@+id/cc_name_legal_message" android:id="@+id/cc_name_tooltip_icon"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_marginTop="@dimen/pref_autofill_field_top_margin" android:layout_height="wrap_content"
android:layout_height="wrap_content" android:padding="12dp"
android:textAppearance="@style/BlackBody" android:src="@drawable/help_outline"
android:textColorLink="@color/infobar_accent_blue" /> android:contentDescription="@string/learn_more" />
</LinearLayout>
</LinearLayout> </LinearLayout>
...@@ -12,12 +12,8 @@ import org.chromium.base.annotations.JNINamespace; ...@@ -12,12 +12,8 @@ import org.chromium.base.annotations.JNINamespace;
import org.chromium.chrome.browser.ChromeActivity; import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.ResourceId; import org.chromium.chrome.browser.ResourceId;
import org.chromium.chrome.browser.autofill.AutofillNameFixFlowPrompt.AutofillNameFixFlowPromptDelegate; import org.chromium.chrome.browser.autofill.AutofillNameFixFlowPrompt.AutofillNameFixFlowPromptDelegate;
import org.chromium.chrome.browser.autofill.AutofillNameFixFlowPrompt.LegalMessageLine;
import org.chromium.ui.base.WindowAndroid; import org.chromium.ui.base.WindowAndroid;
import java.util.ArrayList;
import java.util.List;
/** /**
* JNI call glue for AutofillNameFixFlowPrompt C++ and Java objects. * JNI call glue for AutofillNameFixFlowPrompt C++ and Java objects.
*/ */
...@@ -29,7 +25,6 @@ final class AutofillNameFixFlowBridge implements AutofillNameFixFlowPromptDelega ...@@ -29,7 +25,6 @@ final class AutofillNameFixFlowBridge implements AutofillNameFixFlowPromptDelega
private final String mInferredName; private final String mInferredName;
private final String mConfirmButtonLabel; private final String mConfirmButtonLabel;
private final int mIconId; private final int mIconId;
private final List<LegalMessageLine> mLegalMessageLines = new ArrayList<LegalMessageLine>();
private AutofillNameFixFlowPrompt mNameFixFlowPrompt; private AutofillNameFixFlowPrompt mNameFixFlowPrompt;
private AutofillNameFixFlowBridge(long nativeCardNameFixFlowViewAndroid, String title, private AutofillNameFixFlowBridge(long nativeCardNameFixFlowViewAndroid, String title,
...@@ -58,29 +53,6 @@ final class AutofillNameFixFlowBridge implements AutofillNameFixFlowPromptDelega ...@@ -58,29 +53,6 @@ final class AutofillNameFixFlowBridge implements AutofillNameFixFlowPromptDelega
confirmButtonLabel, iconId, windowAndroid); confirmButtonLabel, iconId, windowAndroid);
} }
/**
* Adds a line of legal message plain text to the infobar.
*
* @param text The legal message plain text.
*/
@CalledByNative
private void addLegalMessageLine(String text) {
mLegalMessageLines.add(new LegalMessageLine(text));
}
/**
* Marks up the last added line of legal message text with a link.
*
* @param start The inclusive offset of the start of the link in the text.
* @param end The exclusive offset of the end of the link in the text.
* @param url The URL to open when the link is clicked.
*/
@CalledByNative
private void addLinkToLastLegalMessageLine(int start, int end, String url) {
mLegalMessageLines.get(mLegalMessageLines.size() - 1)
.links.add(new LegalMessageLine.Link(start, end, url));
}
@Override @Override
public void onPromptDismissed() { public void onPromptDismissed() {
nativePromptDismissed(mNativeCardNameFixFlowViewAndroid); nativePromptDismissed(mNativeCardNameFixFlowViewAndroid);
...@@ -91,18 +63,13 @@ final class AutofillNameFixFlowBridge implements AutofillNameFixFlowPromptDelega ...@@ -91,18 +63,13 @@ final class AutofillNameFixFlowBridge implements AutofillNameFixFlowPromptDelega
nativeOnUserAccept(mNativeCardNameFixFlowViewAndroid, name); nativeOnUserAccept(mNativeCardNameFixFlowViewAndroid, name);
} }
@Override
public void onLegalMessageLinkClicked(String url) {
nativeOnLegalMessageLinkClicked(mNativeCardNameFixFlowViewAndroid, url);
}
/** /**
* Shows a prompt for name fix flow. * Shows a prompt for name fix flow.
*/ */
@CalledByNative @CalledByNative
private void show(WindowAndroid windowAndroid) { private void show(WindowAndroid windowAndroid) {
mNameFixFlowPrompt = new AutofillNameFixFlowPrompt(mActivity, this, mTitle, mInferredName, mNameFixFlowPrompt = new AutofillNameFixFlowPrompt(mActivity, this, mTitle, mInferredName,
mLegalMessageLines, mConfirmButtonLabel, ResourceId.mapToDrawableId(mIconId)); mConfirmButtonLabel, ResourceId.mapToDrawableId(mIconId));
if (mNameFixFlowPrompt != null) { if (mNameFixFlowPrompt != null) {
mNameFixFlowPrompt.show((ChromeActivity) (windowAndroid.getActivity().get())); mNameFixFlowPrompt.show((ChromeActivity) (windowAndroid.getActivity().get()));
...@@ -119,6 +86,4 @@ final class AutofillNameFixFlowBridge implements AutofillNameFixFlowPromptDelega ...@@ -119,6 +86,4 @@ final class AutofillNameFixFlowBridge implements AutofillNameFixFlowPromptDelega
private native void nativePromptDismissed(long nativeCardNameFixFlowViewAndroid); private native void nativePromptDismissed(long nativeCardNameFixFlowViewAndroid);
private native void nativeOnUserAccept(long nativeCardNameFixFlowViewAndroid, String name); private native void nativeOnUserAccept(long nativeCardNameFixFlowViewAndroid, String name);
private native void nativeOnLegalMessageLinkClicked(
long nativeCardNameFixFlowViewAndroid, String url);
} }
...@@ -5,16 +5,15 @@ ...@@ -5,16 +5,15 @@
package org.chromium.chrome.browser.autofill; package org.chromium.chrome.browser.autofill;
import android.content.Context; import android.content.Context;
import android.text.SpannableString; import android.support.v4.view.MarginLayoutParamsCompat;
import android.text.SpannableStringBuilder; import android.support.v4.view.ViewCompat;
import android.text.Spanned;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.widget.EditText; import android.widget.EditText;
import android.widget.TextView; import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView.BufferType; import android.widget.TextView.BufferType;
import org.chromium.chrome.R; import org.chromium.chrome.R;
...@@ -27,69 +26,10 @@ import org.chromium.chrome.browser.modaldialog.ModalDialogViewBinder; ...@@ -27,69 +26,10 @@ import org.chromium.chrome.browser.modaldialog.ModalDialogViewBinder;
import org.chromium.chrome.browser.modelutil.PropertyModel; import org.chromium.chrome.browser.modelutil.PropertyModel;
import org.chromium.chrome.browser.modelutil.PropertyModelChangeProcessor; import org.chromium.chrome.browser.modelutil.PropertyModelChangeProcessor;
import java.util.ArrayList;
import java.util.List;
/** /**
* Prompt that asks users to confirm user's name before saving card to Google. * Prompt that asks users to confirm user's name before saving card to Google.
*/ */
public class AutofillNameFixFlowPrompt implements ModalDialogView.Controller { public class AutofillNameFixFlowPrompt implements ModalDialogView.Controller {
/**
* Legal message line with links to show in the fix flow prompt.
*/
public static class LegalMessageLine {
/**
* A link in the legal message line.
*/
public static class Link {
/**
* The starting inclusive index of the link position in the text.
*/
public int start;
/**
* The ending exclusive index of the link position in the text.
*/
public int end;
/**
* The URL of the link.
*/
public String url;
/**
* Creates a new instance of the link.
*
* @param start The starting inclusive index of the link position in the text.
* @param end The ending exclusive index of the link position in the text.
* @param url The URL of the link.
*/
public Link(int start, int end, String url) {
this.start = start;
this.end = end;
this.url = url;
}
}
/**
* The plain text legal message line.
*/
public String text;
/**
* A collection of links in the legal message line.
*/
public final List<Link> links = new ArrayList<Link>();
/**
* Creates a new instance of the legal message line.
*
* @param legalText The plain text legal message.
*/
public LegalMessageLine(String legalText) {
text = legalText;
}
}
/** /**
* An interface to handle the interaction with * An interface to handle the interaction with
...@@ -107,19 +47,15 @@ public class AutofillNameFixFlowPrompt implements ModalDialogView.Controller { ...@@ -107,19 +47,15 @@ public class AutofillNameFixFlowPrompt implements ModalDialogView.Controller {
* @param name Card holder name. * @param name Card holder name.
*/ */
void onUserAccept(String name); void onUserAccept(String name);
/**
* Called when user clicked on legal message.
*
* @param url Legal message URL that user clicked.
*/
void onLegalMessageLinkClicked(String url);
} }
private final AutofillNameFixFlowPromptDelegate mDelegate; private final AutofillNameFixFlowPromptDelegate mDelegate;
private final ModalDialogView mDialog; private final ModalDialogView mDialog;
private final View mDialogView;
private final EditText mUserNameInput; private final EditText mUserNameInput;
private final ImageView mNameFixFlowTooltipIcon;
private PopupWindow mNameFixFlowTooltipPopup;
private ModalDialogManager mModalDialogManager; private ModalDialogManager mModalDialogManager;
private Context mContext; private Context mContext;
...@@ -128,38 +64,23 @@ public class AutofillNameFixFlowPrompt implements ModalDialogView.Controller { ...@@ -128,38 +64,23 @@ public class AutofillNameFixFlowPrompt implements ModalDialogView.Controller {
* Fix flow prompt to confirm user name before saving the card to Google. * Fix flow prompt to confirm user name before saving the card to Google.
*/ */
public AutofillNameFixFlowPrompt(Context context, AutofillNameFixFlowPromptDelegate delegate, public AutofillNameFixFlowPrompt(Context context, AutofillNameFixFlowPromptDelegate delegate,
String title, String inferredName, List<LegalMessageLine> legalMessageLines, String title, String inferredName, String confirmButtonLabel, int drawableId) {
String confirmButtonLabel, int drawableId) {
mDelegate = delegate; mDelegate = delegate;
LayoutInflater inflater = LayoutInflater.from(context); LayoutInflater inflater = LayoutInflater.from(context);
View customView = inflater.inflate(R.layout.autofill_name_fixflow, null); mDialogView = inflater.inflate(R.layout.autofill_name_fixflow, null);
mUserNameInput = (EditText) customView.findViewById(R.id.cc_name_edit); mUserNameInput = (EditText) mDialogView.findViewById(R.id.cc_name_edit);
mUserNameInput.setText(inferredName, BufferType.EDITABLE); mUserNameInput.setText(inferredName, BufferType.EDITABLE);
mUserNameInput.setSelection(inferredName.length());
SpannableStringBuilder legalMessageText = new SpannableStringBuilder(); mNameFixFlowTooltipIcon = (ImageView) mDialogView.findViewById(R.id.cc_name_tooltip_icon);
for (LegalMessageLine line : legalMessageLines) { mNameFixFlowTooltipIcon.setOnClickListener((view) -> onTooltipIconClicked());
SpannableString text = new SpannableString(line.text);
for (final LegalMessageLine.Link link : line.links) {
text.setSpan(new ClickableSpan() {
@Override
public void onClick(View view) {
delegate.onLegalMessageLinkClicked(link.url);
}
}, link.start, link.end, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
}
legalMessageText.append(legalMessageText);
}
TextView legalMessageView = (TextView) customView.findViewById(R.id.cc_name_legal_message);
legalMessageView.setText(legalMessageText);
legalMessageView.setMovementMethod(LinkMovementMethod.getInstance());
PropertyModel model = PropertyModel model =
new PropertyModel.Builder(ModalDialogProperties.ALL_KEYS) new PropertyModel.Builder(ModalDialogProperties.ALL_KEYS)
.with(ModalDialogProperties.CONTROLLER, this) .with(ModalDialogProperties.CONTROLLER, this)
.with(ModalDialogProperties.TITLE, title) .with(ModalDialogProperties.TITLE, title)
.with(ModalDialogProperties.TITLE_ICON, context, drawableId) .with(ModalDialogProperties.TITLE_ICON, context, drawableId)
.with(ModalDialogProperties.CUSTOM_VIEW, customView) .with(ModalDialogProperties.CUSTOM_VIEW, mDialogView)
.with(ModalDialogProperties.POSITIVE_BUTTON_TEXT, confirmButtonLabel) .with(ModalDialogProperties.POSITIVE_BUTTON_TEXT, confirmButtonLabel)
.with(ModalDialogProperties.NEGATIVE_BUTTON_TEXT, context.getResources(), .with(ModalDialogProperties.NEGATIVE_BUTTON_TEXT, context.getResources(),
R.string.cancel) R.string.cancel)
...@@ -187,7 +108,6 @@ public class AutofillNameFixFlowPrompt implements ModalDialogView.Controller { ...@@ -187,7 +108,6 @@ public class AutofillNameFixFlowPrompt implements ModalDialogView.Controller {
mContext = activity; mContext = activity;
mModalDialogManager = activity.getModalDialogManager(); mModalDialogManager = activity.getModalDialogManager();
mModalDialogManager.showDialog(mDialog, ModalDialogManager.ModalDialogType.APP); mModalDialogManager.showDialog(mDialog, ModalDialogManager.ModalDialogType.APP);
} }
...@@ -195,6 +115,25 @@ public class AutofillNameFixFlowPrompt implements ModalDialogView.Controller { ...@@ -195,6 +115,25 @@ public class AutofillNameFixFlowPrompt implements ModalDialogView.Controller {
mModalDialogManager.dismissDialog(mDialog); mModalDialogManager.dismissDialog(mDialog);
} }
/**
* Handle tooltip icon clicked. If tooltip is already opened, don't show another. Otherwise
* create a new one.
*/
private void onTooltipIconClicked() {
if (mNameFixFlowTooltipPopup != null) return;
mNameFixFlowTooltipPopup = new PopupWindow(mContext);
int textWidth = mDialogView.getWidth() - ViewCompat.getPaddingEnd(mNameFixFlowTooltipIcon)
- MarginLayoutParamsCompat.getMarginEnd(
(LinearLayout.LayoutParams) mNameFixFlowTooltipIcon.getLayoutParams());
Runnable dismissAction = () -> {
mNameFixFlowTooltipPopup = null;
};
AutofillUiUtils.showTooltip(mContext, mNameFixFlowTooltipPopup,
R.string.autofill_save_card_prompt_cardholder_name_tooltip, textWidth,
mUserNameInput, dismissAction);
}
@Override @Override
public void onClick(@ModalDialogView.ButtonType int buttonType) { public void onClick(@ModalDialogView.ButtonType int buttonType) {
if (buttonType == ModalDialogView.ButtonType.POSITIVE) { if (buttonType == ModalDialogView.ButtonType.POSITIVE) {
......
// 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;
import android.content.Context;
import android.content.res.Resources;
import android.os.Handler;
import android.support.v4.view.ViewCompat;
import android.support.v4.widget.TextViewCompat;
import android.view.View;
import android.view.ViewGroup;
import android.widget.PopupWindow;
import android.widget.TextView;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.chrome.R;
/**
* Helper methods that can be used across multiple Autofill UIs.
*/
public class AutofillUiUtils {
// 200ms is chosen small enough not to be detectable to human eye, but big
// enough for to avoid any race conditions on modern machines.
private static final int TOOLTIP_DEFERRED_PERIOD_MS = 200;
/**
* Show Tooltip UI.
*
* @param context Context required to get resources.
* @param popup {@PopupWindow} that shows tooltip UI.
* @param text Text to be shown in tool tip UI.
* @param width Width of the textview.
* @param anchorView Anchor view under which tooltip popup has to be shown
* @param dismissAction Tooltip dismissive action.
*/
public static void showTooltip(Context context, PopupWindow popup, int text, int width,
View anchorView, final Runnable dismissAction) {
TextView textView = new TextView(context);
textView.setText(text);
textView.setWidth(width);
TextViewCompat.setTextAppearance(textView, R.style.WhiteBody);
Resources resources = context.getResources();
int hPadding = resources.getDimensionPixelSize(
R.dimen.autofill_card_unmask_tooltip_horizontal_padding);
int vPadding = resources.getDimensionPixelSize(
R.dimen.autofill_card_unmask_tooltip_vertical_padding);
textView.setPadding(hPadding, vPadding, hPadding, vPadding);
popup.setContentView(textView);
popup.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
popup.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
popup.setOutsideTouchable(true);
popup.setBackgroundDrawable(ApiCompatibilityUtils.getDrawable(
resources, R.drawable.store_locally_tooltip_background));
popup.setOnDismissListener(() -> {
Handler h = new Handler();
h.postDelayed(dismissAction, TOOLTIP_DEFERRED_PERIOD_MS);
});
popup.showAsDropDown(anchorView, ViewCompat.getPaddingStart(anchorView), 0);
textView.announceForAccessibility(textView.getText());
}
}
...@@ -459,6 +459,9 @@ CHAR-LIMIT guidelines: ...@@ -459,6 +459,9 @@ CHAR-LIMIT guidelines:
<message name="IDS_AUTOFILL_CREDIT_CARD_EDITOR_NAME" desc="Label for text input field containing the name on a credit card. [CHAR-LIMIT=32]"> <message name="IDS_AUTOFILL_CREDIT_CARD_EDITOR_NAME" desc="Label for text input field containing the name on a credit card. [CHAR-LIMIT=32]">
Name on card Name on card
</message> </message>
<message name="IDS_AUTOFILL_CARD_HOLDER_NAME" desc="Label for text input field containing the name on a credit card. [CHAR-LIMIT=32]">
Cardholder name
</message>
<message name="IDS_AUTOFILL_CREDIT_CARD_EDITOR_NUMBER" desc="Label for text input field containing a card number. This can be a credit, debit, or prepaid card. [CHAR-LIMIT=32]"> <message name="IDS_AUTOFILL_CREDIT_CARD_EDITOR_NUMBER" desc="Label for text input field containing a card number. This can be a credit, debit, or prepaid card. [CHAR-LIMIT=32]">
Card number Card number
</message> </message>
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
import("//chrome/android/feed/feed_java_sources.gni")
import("//components/feed/features.gni") import("//components/feed/features.gni")
import("//components/offline_pages/buildflags/features.gni") import("//components/offline_pages/buildflags/features.gni")
import("//device/vr/buildflags/buildflags.gni") import("//device/vr/buildflags/buildflags.gni")
import("//chrome/android/feed/feed_java_sources.gni")
chrome_java_sources = [ chrome_java_sources = [
"java/src/com/google/android/apps/chrome/appwidget/bookmarks/BookmarkThumbnailWidgetProvider.java", "java/src/com/google/android/apps/chrome/appwidget/bookmarks/BookmarkThumbnailWidgetProvider.java",
...@@ -93,6 +93,7 @@ chrome_java_sources = [ ...@@ -93,6 +93,7 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/autofill/AutofillNameFixFlowBridge.java", "java/src/org/chromium/chrome/browser/autofill/AutofillNameFixFlowBridge.java",
"java/src/org/chromium/chrome/browser/autofill/AutofillNameFixFlowPrompt.java", "java/src/org/chromium/chrome/browser/autofill/AutofillNameFixFlowPrompt.java",
"java/src/org/chromium/chrome/browser/autofill/AutofillPopupBridge.java", "java/src/org/chromium/chrome/browser/autofill/AutofillPopupBridge.java",
"java/src/org/chromium/chrome/browser/autofill/AutofillUiUtils.java",
"java/src/org/chromium/chrome/browser/autofill/CardUnmaskBridge.java", "java/src/org/chromium/chrome/browser/autofill/CardUnmaskBridge.java",
"java/src/org/chromium/chrome/browser/autofill/CardUnmaskPrompt.java", "java/src/org/chromium/chrome/browser/autofill/CardUnmaskPrompt.java",
"java/src/org/chromium/chrome/browser/autofill/CreditCardScannerBridge.java", "java/src/org/chromium/chrome/browser/autofill/CreditCardScannerBridge.java",
......
...@@ -45,17 +45,6 @@ void CardNameFixFlowViewAndroid::Show() { ...@@ -45,17 +45,6 @@ void CardNameFixFlowViewAndroid::Show() {
confirm, ResourceMapper::MapFromChromiumId(delegate_->GetIconId()), confirm, ResourceMapper::MapFromChromiumId(delegate_->GetIconId()),
view_android->GetWindowAndroid()->GetJavaObject())); view_android->GetWindowAndroid()->GetJavaObject()));
for (const auto& line : delegate_->GetLegalMessageLines()) {
Java_AutofillNameFixFlowBridge_addLegalMessageLine(
env, java_object_,
base::android::ConvertUTF16ToJavaString(env, line.text()));
for (const auto& link : line.links()) {
Java_AutofillNameFixFlowBridge_addLinkToLastLegalMessageLine(
env, java_object_, link.range.start(), link.range.end(),
base::android::ConvertUTF8ToJavaString(env, link.url.spec()));
}
}
Java_AutofillNameFixFlowBridge_show( Java_AutofillNameFixFlowBridge_show(
env, java_object_, view_android->GetWindowAndroid()->GetJavaObject()); env, java_object_, view_android->GetWindowAndroid()->GetJavaObject());
} }
...@@ -74,14 +63,4 @@ void CardNameFixFlowViewAndroid::PromptDismissed( ...@@ -74,14 +63,4 @@ void CardNameFixFlowViewAndroid::PromptDismissed(
delete this; delete this;
} }
void CardNameFixFlowViewAndroid::OnLegalMessageLinkClicked(
JNIEnv* env,
const JavaParamRef<jobject>& obj,
const JavaParamRef<jstring>& url) {
web_contents_->OpenURL(content::OpenURLParams(
GURL(base::android::ConvertJavaStringToUTF16(env, url)),
content::Referrer(), WindowOpenDisposition::NEW_FOREGROUND_TAB,
ui::PAGE_TRANSITION_AUTO_TOPLEVEL, /*is_renderer_initiated=*/false));
}
} // namespace autofill } // namespace autofill
...@@ -34,11 +34,6 @@ class CardNameFixFlowViewAndroid { ...@@ -34,11 +34,6 @@ class CardNameFixFlowViewAndroid {
void PromptDismissed(JNIEnv* env, void PromptDismissed(JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj); const base::android::JavaParamRef<jobject>& obj);
void OnLegalMessageLinkClicked(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj,
const base::android::JavaParamRef<jstring>& url);
void Show(); void Show();
private: private:
......
...@@ -318,12 +318,11 @@ void ChromeAutofillClient::ConfirmSaveCreditCardLocally( ...@@ -318,12 +318,11 @@ void ChromeAutofillClient::ConfirmSaveCreditCardLocally(
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
void ChromeAutofillClient::ConfirmAccountNameFixFlow( void ChromeAutofillClient::ConfirmAccountNameFixFlow(
std::unique_ptr<base::DictionaryValue> legal_message,
base::OnceCallback<void(const base::string16&)> callback) { base::OnceCallback<void(const base::string16&)> callback) {
std::unique_ptr<CardNameFixFlowViewDelegateMobile> std::unique_ptr<CardNameFixFlowViewDelegateMobile>
card_name_fix_flow_view_delegate_mobile = card_name_fix_flow_view_delegate_mobile =
std::make_unique<CardNameFixFlowViewDelegateMobile>( std::make_unique<CardNameFixFlowViewDelegateMobile>(
GetAccountHolderName(), std::move(legal_message), GetAccountHolderName(),
/*upload_save_card_callback=*/std::move(callback)); /*upload_save_card_callback=*/std::move(callback));
card_name_fix_flow_view_android_ = card_name_fix_flow_view_android_ =
......
...@@ -91,7 +91,6 @@ class ChromeAutofillClient ...@@ -91,7 +91,6 @@ class ChromeAutofillClient
UserAcceptedUploadCallback callback) override; UserAcceptedUploadCallback callback) override;
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
void ConfirmAccountNameFixFlow( void ConfirmAccountNameFixFlow(
std::unique_ptr<base::DictionaryValue> legal_message,
base::OnceCallback<void(const base::string16&)> callback) override; base::OnceCallback<void(const base::string16&)> callback) override;
#endif // defined(OS_ANDROID) #endif // defined(OS_ANDROID)
......
...@@ -211,9 +211,8 @@ class AutofillClient : public RiskDataLoader { ...@@ -211,9 +211,8 @@ class AutofillClient : public RiskDataLoader {
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
// Run |callback| if the card should be uploaded to payments with updated // Run |callback| if the card should be uploaded to payments with updated
// name from the user. Displays the contents of |legal_message| to the user. // name from the user.
virtual void ConfirmAccountNameFixFlow( virtual void ConfirmAccountNameFixFlow(
std::unique_ptr<base::DictionaryValue> legal_message,
base::OnceCallback<void(const base::string16&)> callback) = 0; base::OnceCallback<void(const base::string16&)> callback) = 0;
#endif // defined(OS_ANDROID) #endif // defined(OS_ANDROID)
......
...@@ -56,7 +56,8 @@ AutofillSaveCardInfoBarDelegateMobile::AutofillSaveCardInfoBarDelegateMobile( ...@@ -56,7 +56,8 @@ AutofillSaveCardInfoBarDelegateMobile::AutofillSaveCardInfoBarDelegateMobile(
DCHECK(upload_save_card_callback_.is_null()); DCHECK(upload_save_card_callback_.is_null());
DCHECK(!local_save_card_callback_.is_null()); DCHECK(!local_save_card_callback_.is_null());
} }
if (legal_message && !should_request_name_from_user) {
if (legal_message) {
if (!LegalMessageLine::Parse(*legal_message, &legal_messages_, if (!LegalMessageLine::Parse(*legal_message, &legal_messages_,
/*escape_apostrophes=*/true)) { /*escape_apostrophes=*/true)) {
AutofillMetrics::LogCreditCardInfoBarMetric( AutofillMetrics::LogCreditCardInfoBarMetric(
...@@ -96,8 +97,8 @@ void AutofillSaveCardInfoBarDelegateMobile::OnLegalMessageLinkClicked( ...@@ -96,8 +97,8 @@ void AutofillSaveCardInfoBarDelegateMobile::OnLegalMessageLinkClicked(
bool AutofillSaveCardInfoBarDelegateMobile::LegalMessagesParsedSuccessfully() { bool AutofillSaveCardInfoBarDelegateMobile::LegalMessagesParsedSuccessfully() {
// If we are uploading to the server, verify that legal lines have been parsed // If we are uploading to the server, verify that legal lines have been parsed
// into |legal_messages_| unless |should_request_name_from_user_| is enabled. // into |legal_messages_|.
return !upload_ || !legal_messages_.empty() || should_request_name_from_user_; return !upload_ || !legal_messages_.empty();
} }
bool AutofillSaveCardInfoBarDelegateMobile::IsGooglePayBrandingEnabled() const { bool AutofillSaveCardInfoBarDelegateMobile::IsGooglePayBrandingEnabled() const {
......
...@@ -446,20 +446,8 @@ void CreditCardSaveManager::OfferCardUploadSave() { ...@@ -446,20 +446,8 @@ void CreditCardSaveManager::OfferCardUploadSave() {
if (!is_mobile_build || show_save_prompt_.value()) { if (!is_mobile_build || show_save_prompt_.value()) {
user_did_accept_upload_prompt_ = false; user_did_accept_upload_prompt_ = false;
// legal_message_ ownership is always handled out to chrome autofill client
// and eventually to UI classes. In Android, cards name fix flows take two
// steps and legal messsage is shown only in second step, hence nullptr is
// sent now.
std::unique_ptr<base::DictionaryValue> legal_message_tmp;
#if defined(OS_ANDROID)
legal_message_tmp =
should_request_name_from_user_ ? nullptr : std::move(legal_message_);
#else
legal_message_tmp = std::move(legal_message_);
#endif // #if defined(OS_ANDROID)
client_->ConfirmSaveCreditCardToCloud( client_->ConfirmSaveCreditCardToCloud(
upload_request_.card, std::move(legal_message_tmp), upload_request_.card, std::move(legal_message_),
should_request_name_from_user_, should_request_name_from_user_,
should_request_expiration_date_from_user_, show_save_prompt_.value(), should_request_expiration_date_from_user_, show_save_prompt_.value(),
base::BindOnce(&CreditCardSaveManager::OnUserDidAcceptUpload, base::BindOnce(&CreditCardSaveManager::OnUserDidAcceptUpload,
...@@ -761,7 +749,6 @@ void CreditCardSaveManager::OnUserDidAcceptUpload( ...@@ -761,7 +749,6 @@ void CreditCardSaveManager::OnUserDidAcceptUpload(
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
if (should_request_name_from_user_) { if (should_request_name_from_user_) {
client_->ConfirmAccountNameFixFlow( client_->ConfirmAccountNameFixFlow(
std::move(legal_message_),
base::BindOnce( base::BindOnce(
&CreditCardSaveManager::OnUserDidAcceptAccountNameFixFlow, &CreditCardSaveManager::OnUserDidAcceptAccountNameFixFlow,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
......
...@@ -126,7 +126,6 @@ void TestAutofillClient::ConfirmSaveCreditCardLocally( ...@@ -126,7 +126,6 @@ void TestAutofillClient::ConfirmSaveCreditCardLocally(
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
void TestAutofillClient::ConfirmAccountNameFixFlow( void TestAutofillClient::ConfirmAccountNameFixFlow(
std::unique_ptr<base::DictionaryValue> legal_message,
base::OnceCallback<void(const base::string16&)> callback) { base::OnceCallback<void(const base::string16&)> callback) {
credit_card_name_fix_flow_bubble_was_shown_ = true; credit_card_name_fix_flow_bubble_was_shown_ = true;
std::move(callback).Run(base::string16(base::ASCIIToUTF16("Gaia Name"))); std::move(callback).Run(base::string16(base::ASCIIToUTF16("Gaia Name")));
......
...@@ -65,7 +65,6 @@ class TestAutofillClient : public AutofillClient { ...@@ -65,7 +65,6 @@ class TestAutofillClient : public AutofillClient {
base::OnceClosure callback) override; base::OnceClosure callback) override;
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
void ConfirmAccountNameFixFlow( void ConfirmAccountNameFixFlow(
std::unique_ptr<base::DictionaryValue> legal_message,
base::OnceCallback<void(const base::string16&)> callback) override; base::OnceCallback<void(const base::string16&)> callback) override;
#endif // defined(OS_ANDROID) #endif // defined(OS_ANDROID)
......
...@@ -17,16 +17,10 @@ namespace autofill { ...@@ -17,16 +17,10 @@ namespace autofill {
CardNameFixFlowViewDelegateMobile::CardNameFixFlowViewDelegateMobile( CardNameFixFlowViewDelegateMobile::CardNameFixFlowViewDelegateMobile(
const base::string16& inferred_cardholder_name, const base::string16& inferred_cardholder_name,
std::unique_ptr<base::DictionaryValue> legal_message,
base::OnceCallback<void(const base::string16&)> upload_save_card_callback) base::OnceCallback<void(const base::string16&)> upload_save_card_callback)
: inferred_cardholder_name_(inferred_cardholder_name), : inferred_cardholder_name_(inferred_cardholder_name),
upload_save_card_callback_(std::move(upload_save_card_callback)) { upload_save_card_callback_(std::move(upload_save_card_callback)) {
DCHECK(!upload_save_card_callback_.is_null()); DCHECK(!upload_save_card_callback_.is_null());
if (legal_message &&
!LegalMessageLine::Parse(*legal_message, &legal_messages_,
/*escape_apostrophes=*/true)) {
return;
}
} }
CardNameFixFlowViewDelegateMobile::~CardNameFixFlowViewDelegateMobile() {} CardNameFixFlowViewDelegateMobile::~CardNameFixFlowViewDelegateMobile() {}
......
...@@ -10,11 +10,6 @@ ...@@ -10,11 +10,6 @@
#include "base/callback.h" #include "base/callback.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "components/autofill/core/browser/legal_message_line.h"
namespace base {
class DictionaryValue;
}
namespace autofill { namespace autofill {
...@@ -24,16 +19,11 @@ class CardNameFixFlowViewDelegateMobile { ...@@ -24,16 +19,11 @@ class CardNameFixFlowViewDelegateMobile {
public: public:
CardNameFixFlowViewDelegateMobile( CardNameFixFlowViewDelegateMobile(
const base::string16& inferred_cardholder_name, const base::string16& inferred_cardholder_name,
std::unique_ptr<base::DictionaryValue> legal_message,
base::OnceCallback<void(const base::string16&)> base::OnceCallback<void(const base::string16&)>
upload_save_card_callback); upload_save_card_callback);
~CardNameFixFlowViewDelegateMobile(); ~CardNameFixFlowViewDelegateMobile();
const LegalMessageLines& GetLegalMessageLines() const {
return legal_messages_;
}
int GetIconId() const; int GetIconId() const;
base::string16 GetTitleText() const; base::string16 GetTitleText() const;
base::string16 GetInferredCardHolderName() const; base::string16 GetInferredCardHolderName() const;
...@@ -48,9 +38,6 @@ class CardNameFixFlowViewDelegateMobile { ...@@ -48,9 +38,6 @@ class CardNameFixFlowViewDelegateMobile {
// fix flow. // fix flow.
base::OnceCallback<void(const base::string16&)> upload_save_card_callback_; base::OnceCallback<void(const base::string16&)> upload_save_card_callback_;
// The legal messages to show in the fix flow.
LegalMessageLines legal_messages_;
DISALLOW_COPY_AND_ASSIGN(CardNameFixFlowViewDelegateMobile); DISALLOW_COPY_AND_ASSIGN(CardNameFixFlowViewDelegateMobile);
}; };
......
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
<message name="IDS_AUTOFILL_SAVE_CARD_PROMPT_CARDHOLDER_NAME" desc="The label text for the cardholder name textfield."> <message name="IDS_AUTOFILL_SAVE_CARD_PROMPT_CARDHOLDER_NAME" desc="The label text for the cardholder name textfield.">
Cardholder name Cardholder name
</message> </message>
<message name="IDS_AUTOFILL_SAVE_CARD_PROMPT_CARDHOLDER_NAME_TOOLTIP" desc="The tooltip text for the cardholder name textfield."> <message name="IDS_AUTOFILL_SAVE_CARD_PROMPT_CARDHOLDER_NAME_TOOLTIP" desc="The tooltip text for the cardholder name textfield." formatter_data="android_java">
This name is from your Google Account. This name is from your Google Account.
</message> </message>
<message name="IDS_AUTOFILL_SAVE_CARD_CARDHOLDER_NAME_FIX_FLOW_HEADER" desc="Header for the cardholder name fix flow."> <message name="IDS_AUTOFILL_SAVE_CARD_CARDHOLDER_NAME_FIX_FLOW_HEADER" desc="Header for the cardholder name fix flow.">
......
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