Commit a67ec2b6 authored by siyua's avatar siyua Committed by Commit Bot

Remove dead code for migration flow

Code regarding the dialog pending view is useless now since we've
changed the design.

Previously dialog would change to a pending state with all checkboxes
and buttons disabled after the user clicks the save button. And after
5 secs a close button would show.
New design is to dismiss the dialog directly.

Bug: 852904
Change-Id: Idb0ab56f80431a8c26a6bd178ef864bcc16887f0
Reviewed-on: https://chromium-review.googlesource.com/c/1282037Reviewed-by: default avatarEvan Stade <estade@chromium.org>
Commit-Queue: Siyu An <siyua@chromium.org>
Cr-Commit-Position: refs/heads/master@{#599857}
parent ee930d68
......@@ -6,7 +6,6 @@
#include "base/location.h"
#include "base/macros.h"
#include "base/metrics/field_trial_params.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/ui/autofill/local_card_migration_dialog_factory.h"
#include "chrome/browser/ui/autofill/local_card_migration_dialog_state.h"
......@@ -37,7 +36,6 @@
#include "ui/views/background.h"
#include "ui/views/border.h"
#include "ui/views/controls/button/checkbox.h"
#include "ui/views/controls/button/md_text_button.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/link.h"
......@@ -81,7 +79,6 @@ void LocalCardMigrationDialogView::CloseDialog() {
}
void LocalCardMigrationDialogView::OnMigrationFinished() {
show_close_button_timer_.Stop();
title_->SetText(GetDialogTitle());
explanation_text_->SetText(GetDialogInstruction());
for (int index = 0; index < card_list_view_->child_count(); index++) {
......@@ -90,7 +87,6 @@ void LocalCardMigrationDialogView::OnMigrationFinished() {
}
separator_->SetVisible(false);
// TODO(crbug/867194): Add tip value prompt.
SetMigrationIsPending(false);
}
const std::vector<std::string>
......@@ -122,13 +118,6 @@ void LocalCardMigrationDialogView::AddedToWidget() {
GetWidget()->AddObserver(this);
}
views::View* LocalCardMigrationDialogView::CreateExtraView() {
close_migration_dialog_button_ = views::MdTextButton::CreateSecondaryUiButton(
this, l10n_util::GetStringUTF16(IDS_CLOSE));
close_migration_dialog_button_->SetVisible(false);
return close_migration_dialog_button_;
}
bool LocalCardMigrationDialogView::ShouldShowCloseButton() const {
return false;
}
......@@ -141,10 +130,6 @@ base::string16 LocalCardMigrationDialogView::GetDialogButtonLabel(
bool LocalCardMigrationDialogView::IsDialogButtonEnabled(
ui::DialogButton button) const {
// The buttons will be disabled when card uploading is in progress.
if (migration_pending_)
return false;
// If all checkboxes are unchecked, disable the save button.
if (button == ui::DIALOG_BUTTON_OK)
return !GetSelectedCardGuids().empty();
......@@ -155,10 +140,8 @@ bool LocalCardMigrationDialogView::IsDialogButtonEnabled(
bool LocalCardMigrationDialogView::Accept() {
switch (controller_->GetViewState()) {
case LocalCardMigrationDialogState::kOffered:
UpdateDialogToPendingView();
controller_->OnSaveButtonClicked(GetSelectedCardGuids());
return !base::FeatureList::IsEnabled(
features::kAutofillLocalCardMigrationShowFeedback);
return true;
case LocalCardMigrationDialogState::kFinished:
case LocalCardMigrationDialogState::kActionRequired:
return true;
......@@ -185,16 +168,10 @@ void LocalCardMigrationDialogView::OnWidgetClosing(views::Widget* widget) {
// TODO(crbug/867194): Add button pressed logic for kDeleteCardButtonTag.
void LocalCardMigrationDialogView::ButtonPressed(views::Button* sender,
const ui::Event& event) {
// If button clicked is the |close_migration_dialog_button_|, close the
// dialog.
if (sender == close_migration_dialog_button_) {
CloseDialog();
} else {
// Otherwise it is a checkbox just clicked. Enable/disable the save
// button if needed.
DCHECK_EQ(sender->GetClassName(), views::Checkbox::kViewClassName);
DialogModelChanged();
}
// The button clicked is a checkbox just clicked. Enable/disable the save
// button if needed.
DCHECK_EQ(sender->GetClassName(), views::Checkbox::kViewClassName);
DialogModelChanged();
}
void LocalCardMigrationDialogView::StyledLabelLinkClicked(
......@@ -362,29 +339,6 @@ base::string16 LocalCardMigrationDialogView::GetCancelButtonLabel() const {
}
}
void LocalCardMigrationDialogView::SetMigrationIsPending(
bool migration_pending) {
migration_pending_ = migration_pending;
DialogModelChanged();
GetDialogClientView()->Layout();
}
void LocalCardMigrationDialogView::ShowCloseButton() {
close_migration_dialog_button_->SetVisible(true);
}
void LocalCardMigrationDialogView::UpdateDialogToPendingView() {
for (int index = 0; index < card_list_view_->child_count(); index++) {
// Checkboxes will be disabled when card uploading is in progress.
AsMigratableCardView(card_list_view_->child_at(index))
->SetCheckboxEnabled(false);
}
SetMigrationIsPending(true);
show_close_button_timer_.Start(
FROM_HERE, features::GetTimeoutForMigrationPromptFeedbackCloseButton(),
this, &LocalCardMigrationDialogView::ShowCloseButton);
}
LocalCardMigrationDialog* CreateLocalCardMigrationDialogView(
LocalCardMigrationDialogController* controller,
content::WebContents* web_contents) {
......
......@@ -49,7 +49,6 @@ class LocalCardMigrationDialogView : public LocalCardMigrationDialog,
gfx::Size CalculatePreferredSize() const override;
ui::ModalType GetModalType() const override;
void AddedToWidget() override;
views::View* CreateExtraView() override;
bool ShouldShowCloseButton() const override;
base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
bool IsDialogButtonEnabled(ui::DialogButton button) const override;
......@@ -74,9 +73,6 @@ class LocalCardMigrationDialogView : public LocalCardMigrationDialog,
int GetHeaderImageId() const;
base::string16 GetOkButtonLabel() const;
base::string16 GetCancelButtonLabel() const;
void SetMigrationIsPending(bool is_pending);
void ShowCloseButton();
void UpdateDialogToPendingView();
const std::vector<std::string> GetSelectedCardGuids() const;
LocalCardMigrationDialogController* controller_;
......@@ -93,23 +89,10 @@ class LocalCardMigrationDialogView : public LocalCardMigrationDialog,
// Separates the card scroll bar view and the legal message.
views::Separator* separator_ = nullptr;
// The button displays "Close". If clicked, will close the dialog
// in pending state.
views::View* close_migration_dialog_button_ = nullptr;
// The view that contains legal message and handles legal message links
// clicking.
LegalMessageView* legal_message_container_ = nullptr;
// Timer that will call ShowCloseButton() after the migration process
// has started and is pending for acertain amount of time which can be
// configured through Finch.
base::OneShotTimer show_close_button_timer_;
// Whether the uploading is in progress and results are
// pending.
bool migration_pending_ = false;
DISALLOW_COPY_AND_ASSIGN(LocalCardMigrationDialogView);
};
......
......@@ -298,9 +298,6 @@ const base::Feature kAutomaticPasswordGeneration = {
const base::Feature kSingleClickAutofill{"SingleClickAutofill",
base::FEATURE_ENABLED_BY_DEFAULT};
const char kAutofillLocalCardMigrationCloseButtonDelay[] =
"show_close_migration_dialog_button_delay";
const char kAutofillCreditCardLocalCardMigrationParameterName[] = "variant";
const char kAutofillCreditCardLocalCardMigrationParameterWithoutSettingsPage[] =
......@@ -337,14 +334,6 @@ LocalCardMigrationExperimentalFlag GetLocalCardMigrationExperimentalFlag() {
return LocalCardMigrationExperimentalFlag::kMigrationIncludeSettingsPage;
}
base::TimeDelta GetTimeoutForMigrationPromptFeedbackCloseButton() {
constexpr int show_close_button_timeout_in_seconds = 5;
return base::TimeDelta::FromSeconds(base::GetFieldTrialParamByFeatureAsInt(
kAutofillCreditCardLocalCardMigration,
kAutofillLocalCardMigrationCloseButtonDelay,
show_close_button_timeout_in_seconds));
}
bool IsAutofillUpstreamAlwaysRequestCardholderNameExperimentEnabled() {
return base::FeatureList::IsEnabled(
features::kAutofillUpstreamAlwaysRequestCardholderName);
......
......@@ -112,10 +112,6 @@ enum class LocalCardMigrationExperimentalFlag {
// settings page migration.
LocalCardMigrationExperimentalFlag GetLocalCardMigrationExperimentalFlag();
// Returns the time delay for the local card migration dialog to show the close
// button.
base::TimeDelta GetTimeoutForMigrationPromptFeedbackCloseButton();
// For testing purposes; not to be launched. When enabled, Chrome Upstream
// always requests that the user enters/confirms cardholder name in the
// offer-to-save dialog, regardless of if it was present or if the user is a
......
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