Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2797)

Unified Diff: chrome/browser/ui/views/passwords/credentials_item_view.cc

Issue 924733003: Credential Manager API pops up an auto-signin toast. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/passwords/credentials_item_view.cc
diff --git a/chrome/browser/ui/views/passwords/credentials_item_view.cc b/chrome/browser/ui/views/passwords/credentials_item_view.cc
index 6a82ec1f1faa7104ea1945c96dbdf92361739738..acf8710dc97e5ffc8cc8fe24a503e268f87c799d 100644
--- a/chrome/browser/ui/views/passwords/credentials_item_view.cc
+++ b/chrome/browser/ui/views/passwords/credentials_item_view.cc
@@ -30,20 +30,32 @@ gfx::Size GetTextLabelsSize(const views::Label* upper_label,
upper_label_size.height() + lower_label_size.height());
}
-// Returns either full name or username if the former is empty.
-const base::string16& GetUpperLabelText(const autofill::PasswordForm& form) {
- return form.display_name.empty() ? form.username_value : form.display_name;
+// Returns the bold upper text for the button.
+base::string16 GetUpperLabelText(const autofill::PasswordForm& form,
+ CredentialsItemView::Style style) {
+ switch (style) {
+ case CredentialsItemView::ACCOUNT_CHOOSER:
+ return form.display_name.empty() ? form.username_value
+ : form.display_name;
+ case CredentialsItemView::AUTO_SIGNIN:
+ return l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_AUTO_SIGNIN_TITLE);
+ }
}
-// Returns IDP information for federated credentials and username or empty
-// string for non-federated ones.
-base::string16 GetLowerLabelText(const autofill::PasswordForm& form) {
+// Returns the lower text for the button.
+base::string16 GetLowerLabelText(const autofill::PasswordForm& form,
+ CredentialsItemView::Style style) {
if (!form.federation_url.is_empty()) {
return l10n_util::GetStringFUTF16(
IDS_MANAGE_PASSWORDS_IDENTITY_PROVIDER,
base::ASCIIToUTF16(form.federation_url.host()));
}
- return form.display_name.empty() ? base::string16() : form.username_value;
+ switch (style) {
+ case CredentialsItemView::ACCOUNT_CHOOSER:
+ return form.display_name.empty() ? base::string16() : form.username_value;
+ case CredentialsItemView::AUTO_SIGNIN:
+ return form.username_value;
+ }
}
class CircularImageView : public views::ImageView {
@@ -75,6 +87,7 @@ CredentialsItemView::CredentialsItemView(
views::ButtonListener* button_listener,
const autofill::PasswordForm& form,
password_manager::CredentialType credential_type,
+ Style style,
net::URLRequestContextGetter* request_context)
: LabelButton(button_listener, base::string16()),
form_(form),
@@ -102,11 +115,12 @@ CredentialsItemView::CredentialsItemView(
ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
upper_label_ = new views::Label(
- GetUpperLabelText(form_), rb->GetFontList(ui::ResourceBundle::BoldFont));
+ GetUpperLabelText(form_, style),
+ rb->GetFontList(ui::ResourceBundle::BoldFont));
upper_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
AddChildView(upper_label_);
- base::string16 lower_text = GetLowerLabelText(form_);
+ base::string16 lower_text = GetLowerLabelText(form_, style);
if (!lower_text.empty()) {
lower_label_ = new views::Label(
lower_text, rb->GetFontList(ui::ResourceBundle::SmallFont));

Powered by Google App Engine
This is Rietveld 408576698