Commit 30468bcb authored by Sidney San Martín's avatar Sidney San Martín Committed by Commit Bot

Mac: Show blank completions instead of toolbar buttons on the Touch Bar while entering a password.

The toolbar buttons were easy to hit by accident.

Bug: 999545
Change-Id: I7922fc6a942190e1f53bc37b49fe9bda09c516ad
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1783197Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Sidney San Martín <sdy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#692832}
parent 74cd9c6a
......@@ -380,6 +380,8 @@ void ExtractUnderlines(NSAttributedString* string,
return;
[touchBarItem
updateWithInsertionPointVisibility:textSelectionRange_.is_empty()];
if (textInputType_ == ui::TEXT_INPUT_TYPE_PASSWORD)
return;
if (!touchBarItem.candidateListVisible)
return;
if (!textSelectionRange_.IsValid() ||
......@@ -2201,8 +2203,7 @@ extern NSString* NSTextInputReplacementRangeAttributeName;
}
- (NSTouchBar*)makeTouchBar {
if (textInputType_ != ui::TEXT_INPUT_TYPE_NONE &&
textInputType_ != ui::TEXT_INPUT_TYPE_PASSWORD) {
if (textInputType_ != ui::TEXT_INPUT_TYPE_NONE) {
candidateListTouchBarItem_.reset([[NSCandidateListTouchBarItem alloc]
initWithIdentifier:NSTouchBarItemIdentifierCandidateList]);
auto* candidateListItem = candidateListTouchBarItem_.get();
......
......@@ -2067,7 +2067,7 @@ TEST_F(InputMethodMacTest, TouchBarTextSuggestionsPresence) {
if (@available(macOS 10.12.2, *)) {
EXPECT_NSEQ(nil, candidate_list_item());
SetTextInputType(tab_view(), ui::TEXT_INPUT_TYPE_PASSWORD);
EXPECT_NSEQ(nil, candidate_list_item());
EXPECT_NSNE(nil, candidate_list_item());
SetTextInputType(tab_view(), ui::TEXT_INPUT_TYPE_TEXT);
EXPECT_NSNE(nil, candidate_list_item());
}
......@@ -2133,6 +2133,27 @@ TEST_F(InputMethodMacTest, TouchBarTextSuggestionsReplacement) {
}
}
TEST_F(InputMethodMacTest, TouchBarTextSuggestionsNotRequestedForPasswords) {
base::test::ScopedFeatureList feature_list;
if (@available(macOS 10.12.2, *)) {
base::scoped_nsobject<FakeSpellChecker> spellChecker(
[[FakeSpellChecker alloc] init]);
tab_GetInProcessNSView().spellCheckerForTesting =
static_cast<NSSpellChecker*>(spellChecker.get());
SetTextInputType(tab_view(), ui::TEXT_INPUT_TYPE_PASSWORD);
EXPECT_NSNE(nil, candidate_list_item());
candidate_list_item().allowsCollapsing = NO;
const base::string16 kOriginalString = base::UTF8ToUTF16("abcxxxghi");
// Change the selection once; completions should *not* be requested.
tab_view()->SelectionChanged(kOriginalString, 3, gfx::Range(3, 3));
EXPECT_EQ(0U, [spellChecker sequenceNumber]);
}
}
// https://crbug.com/893038: There exist code paths which set the selection
// range to gfx::Range::InvalidRange(). I'm not sure how to exercise them in
// practice, but this has caused crashes in the field.
......
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