Commit 3312d7ac authored by Mohamed Amir Yosef's avatar Mohamed Amir Yosef Committed by Commit Bot

[Passwords] Move CreateUsernameEditableCombobox to SaveUpdate view files

Bug: 1044038
Change-Id: I81f8bbbd6d48fb8dedd3aa7ed4492168f93c7662
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2043845Reviewed-by: default avatarVasilii Sukhanov <vasilii@chromium.org>
Commit-Queue: Mohamed Amir Yosef <mamir@chromium.org>
Cr-Commit-Position: refs/heads/master@{#739431}
parent 0177ea4a
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "ui/views/controls/button/image_button.h" #include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/button/image_button_factory.h" #include "ui/views/controls/button/image_button_factory.h"
#include "ui/views/controls/button/md_text_button.h" #include "ui/views/controls/button/md_text_button.h"
#include "ui/views/controls/editable_combobox/editable_combobox.h"
#include "ui/views/controls/label.h" #include "ui/views/controls/label.h"
#include "ui/views/controls/link.h" #include "ui/views/controls/link.h"
#include "ui/views/layout/fill_layout.h" #include "ui/views/layout/fill_layout.h"
...@@ -121,31 +120,6 @@ std::unique_ptr<views::Label> CreateUsernameLabel( ...@@ -121,31 +120,6 @@ std::unique_ptr<views::Label> CreateUsernameLabel(
return label; return label;
} }
std::unique_ptr<views::EditableCombobox> CreateUsernameEditableCombobox(
const autofill::PasswordForm& form) {
std::vector<base::string16> usernames = {form.username_value};
for (const autofill::ValueElementPair& other_possible_username_pair :
form.all_possible_usernames) {
if (other_possible_username_pair.first != form.username_value)
usernames.push_back(other_possible_username_pair.first);
}
base::EraseIf(usernames, [](const base::string16& username) {
return username.empty();
});
bool display_arrow = !usernames.empty();
auto combobox = std::make_unique<views::EditableCombobox>(
std::make_unique<ui::SimpleComboboxModel>(std::move(usernames)),
/*filter_on_edit=*/false, /*show_on_empty=*/true,
views::EditableCombobox::Type::kRegular, views::style::CONTEXT_BUTTON,
views::style::STYLE_PRIMARY, display_arrow);
combobox->SetText(form.username_value);
combobox->SetAccessibleName(
l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_USERNAME_LABEL));
// In case of long username, ensure that the beginning of value is visible.
combobox->SelectRange(gfx::Range(0));
return combobox;
}
std::unique_ptr<views::Label> CreatePasswordLabel( std::unique_ptr<views::Label> CreatePasswordLabel(
const autofill::PasswordForm& form, const autofill::PasswordForm& form,
int federation_message_id, int federation_message_id,
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "ui/views/view.h" #include "ui/views/view.h"
namespace views { namespace views {
class EditableCombobox;
class Label; class Label;
} // namespace views } // namespace views
...@@ -27,8 +26,6 @@ std::unique_ptr<views::Label> CreatePasswordLabel( ...@@ -27,8 +26,6 @@ std::unique_ptr<views::Label> CreatePasswordLabel(
const autofill::PasswordForm& form, const autofill::PasswordForm& form,
int federation_message_id, int federation_message_id,
bool is_password_visible); bool is_password_visible);
std::unique_ptr<views::EditableCombobox> CreateUsernameEditableCombobox(
const autofill::PasswordForm& form);
// A dialog for managing stored password and federated login information for a // A dialog for managing stored password and federated login information for a
// specific site. A user can remove managed credentials for the site via this // specific site. A user can remove managed credentials for the site via this
......
...@@ -175,6 +175,33 @@ std::unique_ptr<views::ToggleImageButton> CreatePasswordViewButton( ...@@ -175,6 +175,33 @@ std::unique_ptr<views::ToggleImageButton> CreatePasswordViewButton(
return button; return button;
} }
// Creates an EditableCombobox from |PasswordForm.all_possible_usernames| or
// even just |PasswordForm.username_value|.
std::unique_ptr<views::EditableCombobox> CreateUsernameEditableCombobox(
const autofill::PasswordForm& form) {
std::vector<base::string16> usernames = {form.username_value};
for (const autofill::ValueElementPair& other_possible_username_pair :
form.all_possible_usernames) {
if (other_possible_username_pair.first != form.username_value)
usernames.push_back(other_possible_username_pair.first);
}
base::EraseIf(usernames, [](const base::string16& username) {
return username.empty();
});
bool display_arrow = !usernames.empty();
auto combobox = std::make_unique<views::EditableCombobox>(
std::make_unique<ui::SimpleComboboxModel>(std::move(usernames)),
/*filter_on_edit=*/false, /*show_on_empty=*/true,
views::EditableCombobox::Type::kRegular, views::style::CONTEXT_BUTTON,
views::style::STYLE_PRIMARY, display_arrow);
combobox->SetText(form.username_value);
combobox->SetAccessibleName(
l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_USERNAME_LABEL));
// In case of long username, ensure that the beginning of value is visible.
combobox->SelectRange(gfx::Range(0));
return combobox;
}
// Creates an EditableCombobox from |PasswordForm.all_possible_passwords| or // Creates an EditableCombobox from |PasswordForm.all_possible_passwords| or
// even just |PasswordForm.password_value|. // even just |PasswordForm.password_value|.
std::unique_ptr<views::EditableCombobox> CreatePasswordEditableCombobox( std::unique_ptr<views::EditableCombobox> CreatePasswordEditableCombobox(
......
...@@ -175,6 +175,33 @@ std::unique_ptr<views::ToggleImageButton> CreatePasswordViewButton( ...@@ -175,6 +175,33 @@ std::unique_ptr<views::ToggleImageButton> CreatePasswordViewButton(
return button; return button;
} }
// Creates an EditableCombobox from |PasswordForm.all_possible_usernames| or
// even just |PasswordForm.username_value|.
std::unique_ptr<views::EditableCombobox> CreateUsernameEditableCombobox(
const autofill::PasswordForm& form) {
std::vector<base::string16> usernames = {form.username_value};
for (const autofill::ValueElementPair& other_possible_username_pair :
form.all_possible_usernames) {
if (other_possible_username_pair.first != form.username_value)
usernames.push_back(other_possible_username_pair.first);
}
base::EraseIf(usernames, [](const base::string16& username) {
return username.empty();
});
bool display_arrow = !usernames.empty();
auto combobox = std::make_unique<views::EditableCombobox>(
std::make_unique<ui::SimpleComboboxModel>(std::move(usernames)),
/*filter_on_edit=*/false, /*show_on_empty=*/true,
views::EditableCombobox::Type::kRegular, views::style::CONTEXT_BUTTON,
views::style::STYLE_PRIMARY, display_arrow);
combobox->SetText(form.username_value);
combobox->SetAccessibleName(
l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_USERNAME_LABEL));
// In case of long username, ensure that the beginning of value is visible.
combobox->SelectRange(gfx::Range(0));
return combobox;
}
// Creates an EditableCombobox from |PasswordForm.all_possible_passwords| or // Creates an EditableCombobox from |PasswordForm.all_possible_passwords| or
// even just |PasswordForm.password_value|. // even just |PasswordForm.password_value|.
std::unique_ptr<views::EditableCombobox> CreatePasswordEditableCombobox( std::unique_ptr<views::EditableCombobox> CreatePasswordEditableCombobox(
......
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