Commit 0d33d678 authored by siashah's avatar siashah Committed by Commit Bot

[FIX] Change the fix flow objects from global unique pointers to local raw pointers.

BUG CAUSE:  When the fix flow prompt is dismissed, we intend to cleanup the memory
by calling delete this. However, chrome_autofill_client tries to call the
destructor of the unique pointer pointing to the deleted object resulting in a crash.

PROPOSED SOLUTION:
Since the fix flow objects are responsible for maintaining their lifecycle.
i.e. Delete themselves when the prompt is dismissed, we can change them to be local
raw pointers.

Bug: 929437
Change-Id: I539569dc32fbe6d0e4f535a57a2e2871e573a87c
Reviewed-on: https://chromium-review.googlesource.com/c/1468582Reviewed-by: default avatarTommy Martino <tmartino@chromium.org>
Reviewed-by: default avatarFabio Tirelo <ftirelo@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Reviewed-by: default avatarJared Saul <jsaul@google.com>
Commit-Queue: Siddharth Shah <siashah@chromium.org>
Cr-Commit-Position: refs/heads/master@{#635353}
parent 4e4b2619
......@@ -19,7 +19,8 @@ class WebContents;
namespace autofill {
class CardNameFixFlowViewDelegateMobile;
// This class is responsible for its destruction. Destruction is achieved by
// calling delete when the prompt is dismissed.
class CardNameFixFlowViewAndroid {
public:
CardNameFixFlowViewAndroid(
......
......@@ -319,10 +319,12 @@ void ChromeAutofillClient::ConfirmAccountNameFixFlow(
GetAccountHolderName(),
/*upload_save_card_callback=*/std::move(callback));
card_name_fix_flow_view_android_ =
std::make_unique<CardNameFixFlowViewAndroid>(
// Destruction is handled by the fix flow dialog by explicitly calling delete
// when the prompt is dismissed.
CardNameFixFlowViewAndroid* card_name_fix_flow_view_android =
new CardNameFixFlowViewAndroid(
std::move(card_name_fix_flow_view_delegate_mobile), web_contents());
card_name_fix_flow_view_android_->Show();
card_name_fix_flow_view_android->Show();
}
void ChromeAutofillClient::ConfirmExpirationDateFixFlow(
......@@ -333,11 +335,14 @@ void ChromeAutofillClient::ConfirmExpirationDateFixFlow(
std::make_unique<CardExpirationDateFixFlowViewDelegateMobile>(
/*upload_save_card_callback=*/std::move(callback));
card_expiration_date_fix_flow_view_android_ =
std::make_unique<CardExpirationDateFixFlowViewAndroid>(
std::move(card_expiration_date_fix_flow_view_delegate_mobile),
web_contents());
card_expiration_date_fix_flow_view_android_->Show();
// Destruction is handled by the fix flow dialog by explicitly calling delete
// when the prompt is dismissed.
CardExpirationDateFixFlowViewAndroid*
card_expiration_date_fix_flow_view_android =
new CardExpirationDateFixFlowViewAndroid(
std::move(card_expiration_date_fix_flow_view_delegate_mobile),
web_contents());
card_expiration_date_fix_flow_view_android->Show();
}
#endif
......
......@@ -34,8 +34,6 @@ class WebContents;
namespace autofill {
class AutofillPopupControllerImpl;
class CardExpirationDateFixFlowViewAndroid;
class CardNameFixFlowViewAndroid;
// Chrome implementation of AutofillClient.
class ChromeAutofillClient
......@@ -160,12 +158,6 @@ class ChromeAutofillClient
base::WeakPtr<AutofillPopupControllerImpl> popup_controller_;
CardUnmaskPromptControllerImpl unmask_controller_;
#if defined(OS_ANDROID)
std::unique_ptr<CardNameFixFlowViewAndroid> card_name_fix_flow_view_android_;
std::unique_ptr<CardExpirationDateFixFlowViewAndroid>
card_expiration_date_fix_flow_view_android_;
#endif // defined(OS_ANDROID)
WEB_CONTENTS_USER_DATA_KEY_DECL();
DISALLOW_COPY_AND_ASSIGN(ChromeAutofillClient);
......
......@@ -15,7 +15,9 @@
namespace autofill {
// Enables the user to accept or deny expiration date fix flow prompt.
// Only used on mobile.
// Only used on mobile. This class is responsible for its destruction.
// Destruction is achieved by calling delete when the prompt is
// dismissed.
class CardExpirationDateFixFlowViewDelegateMobile {
public:
CardExpirationDateFixFlowViewDelegateMobile(
......
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