Skip to content

Commit

Permalink
Use bullet points instead of asterisk in the save password bubble.
Browse files Browse the repository at this point in the history
TBR=vasilii@chromium.org

(cherry picked from commit 1009ba6)

Bug: 774516
Change-Id: I17344d16d835a9db9daf1c87824ea9e40ec38baa
Reviewed-on: https://chromium-review.googlesource.com/721544
Commit-Queue: Vasilii Sukhanov <vasilii@chromium.org>
Reviewed-by: Tatiana Gornak <melandory@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#509366}
Reviewed-on: https://chromium-review.googlesource.com/727932
Reviewed-by: Vasilii Sukhanov <vasilii@chromium.org>
Cr-Commit-Position: refs/branch-heads/3239@{#64}
Cr-Branched-From: adb61db-refs/heads/master@{#508578}
  • Loading branch information
Vasilii Sukhanov committed Oct 19, 2017
1 parent bcf6b71 commit bb6e290
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#import "ui/base/cocoa/touch_bar_util.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/render_text.h"

namespace {

Expand All @@ -26,6 +27,8 @@
NSString* const kNeverTouchBarId = @"NEVER";
NSString* const kSaveTouchBarId = @"SAVE";

constexpr base::char16 kBulletChar = gfx::RenderText::kPasswordReplacementChar;

void InitEditableLabel(NSTextField* textField, const base::string16& text) {
[textField setStringValue:base::SysUTF16ToNSString(text)];
[textField setEditable:YES];
Expand All @@ -51,17 +54,17 @@ void FillPasswordCombobox(const autofill::PasswordForm& form,
for (const base::string16& possible_password : form.all_possible_passwords) {
[combobox
addItemWithObjectValue:base::SysUTF16ToNSString(
visible
? possible_password
: base::string16(
possible_password.length(), '*'))];
visible ? possible_password
: base::string16(
possible_password.length(),
kBulletChar))];
}
[combobox setEditable:visible];
[combobox
setStringValue:base::SysUTF16ToNSString(
visible ? form.password_value
: base::string16(form.password_value.length(),
'*'))];
kBulletChar))];
size_t index = std::distance(
form.all_possible_passwords.begin(),
std::find(form.all_possible_passwords.begin(),
Expand Down Expand Up @@ -149,7 +152,7 @@ - (void)onEyeClicked:(id)sender {
offsetY = NSMidY([passwordText_ frame]) - NSMidY(oldFrame);
} else {
InitLabel(passwordField_.get(),
base::string16(form.password_value.length(), '*'));
base::string16(form.password_value.length(), kBulletChar));
offsetY = NSMaxY([passwordText_ frame]) - NSMaxY(oldFrame);
}
[passwordField_ setFrame:NSOffsetRect(oldFrame, 0, offsetY)];
Expand Down Expand Up @@ -221,8 +224,8 @@ - (NSView*)createPasswordView {
passwordField_.reset([PasswordCombobox(form) retain]);
[passwordField_ setDelegate:self];
} else {
passwordField_.reset(
[Label(base::string16(form.password_value.length(), '*')) retain]);
passwordField_.reset([Label(
base::string16(form.password_value.length(), kBulletChar)) retain]);
// Overwrite the height of the password field because it's higher in the
// editable mode.
[passwordField_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include "testing/gtest_mac.h"
#import "ui/base/cocoa/touch_bar_forward_declarations.h"
#import "ui/events/test/cocoa_test_event_utils.h"
#include "ui/gfx/render_text.h"

// Gmock matcher
using testing::_;

Expand Down Expand Up @@ -133,7 +135,9 @@ void TearDown() override {
base::mac::ObjCCastStrict<NSComboBox>(controller().passwordField);
EXPECT_FALSE(passwordSelection.editable);
[passwordSelection selectItemAtIndex:1];
EXPECT_NSEQ(@"***", [passwordSelection stringValue]);
base::string16 expected(3, gfx::RenderText::kPasswordReplacementChar);
EXPECT_NSEQ(base::SysUTF16ToNSString(expected),
[passwordSelection stringValue]);

EXPECT_CALL(*ui_controller(), SavePassword(base::ASCIIToUTF16("username"),
base::ASCIIToUTF16("111")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ int ManagePasswordsBubbleView::auto_signin_toast_timeout_ = 3;

namespace {

constexpr base::char16 kBulletChar = gfx::RenderText::kPasswordReplacementChar;

enum ColumnSetType {
// | | (FILL, FILL) | |
// Used for the bubble's header, the credentials list, and for simple
Expand Down Expand Up @@ -231,7 +233,7 @@ std::unique_ptr<views::ToggleImageButton> CreatePasswordViewButton(
}

// Creates a dropdown from the other possible passwords.
// The items are made of '*'s if not visible.
// The items are made of kBulletChar if not visible.
std::unique_ptr<views::Combobox> CreatePasswordDropdownView(
const autofill::PasswordForm& form,
bool visible) {
Expand All @@ -242,7 +244,8 @@ std::unique_ptr<views::Combobox> CreatePasswordDropdownView(
} else {
for (const base::string16& possible_password :
form.all_possible_passwords) {
passwords.push_back(base::string16(possible_password.length(), '*'));
passwords.push_back(
base::string16(possible_password.length(), kBulletChar));
}
}
std::unique_ptr<views::Combobox> combobox = std::make_unique<views::Combobox>(
Expand Down

0 comments on commit bb6e290

Please sign in to comment.