Commit 13f472e9 authored by spqchan's avatar spqchan Committed by Commit Bot

[Mac] Potential AutofillPopupControllerImplMac crash fix

A crash in the AutofillPopupControllerImplMac might
be caused by checking the layout model to see if the popup
is for a credit card. This CL potentially fix the issue by
storing that value.

Bug: 838660
Change-Id: I3bbe0b53139d4582313e4eabe91a42e6f3816f3e
Reviewed-on: https://chromium-review.googlesource.com/1048969Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Commit-Queue: Sarah Chan <spqchan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558008}
parent a7b306ef
......@@ -37,7 +37,10 @@ class AutofillPopupControllerImplMac : public AutofillPopupControllerImpl {
private:
// The controller providing the autofill touch bar.
WebTextfieldTouchBarController* touchBarController_; // weak.
WebTextfieldTouchBarController* touch_bar_controller_; // weak.
// True if the popup contains credit card items.
BOOL is_credit_card_popup_;
DISALLOW_COPY_AND_ASSIGN(AutofillPopupControllerImplMac);
};
......
......@@ -9,6 +9,7 @@
#import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h"
#import "chrome/browser/ui/cocoa/web_textfield_touch_bar_controller.h"
#include "components/autofill/core/browser/autofill_experiments.h"
#include "components/autofill/core/browser/autofill_popup_delegate.h"
#include "components/autofill/core/browser/popup_item_ids.h"
using base::WeakPtr;
......@@ -49,7 +50,8 @@ AutofillPopupControllerImplMac::AutofillPopupControllerImplMac(
container_view,
element_bounds,
text_direction),
touchBarController_(nil) {}
touch_bar_controller_(nil),
is_credit_card_popup_(delegate->IsCreditCardPopup()) {}
AutofillPopupControllerImplMac::~AutofillPopupControllerImplMac() {}
......@@ -60,7 +62,7 @@ void AutofillPopupControllerImplMac::Show(
if (!autofill::IsCreditCardAutofillTouchBarExperimentEnabled())
return;
if (!GetLineCount() || !layout_model().is_credit_card_popup())
if (!GetLineCount() || !is_credit_card_popup_)
return;
if (@available(macOS 10.12.2, *)) {
......@@ -68,10 +70,10 @@ void AutofillPopupControllerImplMac::Show(
browserWindowControllerForWindow:[container_view() window]];
TabContentsController* tabContentsController =
[[bwc tabStripController] activeTabContentsController];
touchBarController_ =
touch_bar_controller_ =
[tabContentsController webTextfieldTouchBarController];
[touchBarController_ showCreditCardAutofillWithController:this];
[touch_bar_controller_ showCreditCardAutofillWithController:this];
}
}
......@@ -79,15 +81,15 @@ void AutofillPopupControllerImplMac::UpdateDataListValues(
const std::vector<base::string16>& values,
const std::vector<base::string16>& labels) {
AutofillPopupControllerImpl::UpdateDataListValues(values, labels);
if (touchBarController_) {
[touchBarController_ invalidateTouchBar];
if (touch_bar_controller_) {
[touch_bar_controller_ invalidateTouchBar];
}
}
void AutofillPopupControllerImplMac::Hide() {
if (touchBarController_) {
[touchBarController_ hideCreditCardAutofillTouchBar];
touchBarController_ = nil;
if (touch_bar_controller_) {
[touch_bar_controller_ hideCreditCardAutofillTouchBar];
touch_bar_controller_ = nil;
}
AutofillPopupControllerImpl::Hide();
......
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