| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/passwords/manage_password_items_view.h" | 5 #include "chrome/browser/ui/views/passwords/manage_password_items_view.h" |
| 6 | 6 |
| 7 #include <numeric> | 7 #include <numeric> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 67 |
| 68 scoped_ptr<views::Label> GenerateUsernameLabel( | 68 scoped_ptr<views::Label> GenerateUsernameLabel( |
| 69 const autofill::PasswordForm& form) { | 69 const autofill::PasswordForm& form) { |
| 70 scoped_ptr<views::Label> label(new views::Label( | 70 scoped_ptr<views::Label> label(new views::Label( |
| 71 form.username_value.empty() | 71 form.username_value.empty() |
| 72 ? l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_EMPTY_LOGIN) | 72 ? l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_EMPTY_LOGIN) |
| 73 : form.username_value)); | 73 : form.username_value)); |
| 74 label->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( | 74 label->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( |
| 75 ui::ResourceBundle::SmallFont)); | 75 ui::ResourceBundle::SmallFont)); |
| 76 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 76 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 77 return label.Pass(); | 77 return label; |
| 78 } | 78 } |
| 79 | 79 |
| 80 scoped_ptr<views::Label> GeneratePasswordLabel( | 80 scoped_ptr<views::Label> GeneratePasswordLabel( |
| 81 const autofill::PasswordForm& form) { | 81 const autofill::PasswordForm& form) { |
| 82 base::string16 text = form.federation_url.is_empty() | 82 base::string16 text = form.federation_url.is_empty() |
| 83 ? form.password_value | 83 ? form.password_value |
| 84 : l10n_util::GetStringFUTF16( | 84 : l10n_util::GetStringFUTF16( |
| 85 IDS_PASSWORDS_VIA_FEDERATION, | 85 IDS_PASSWORDS_VIA_FEDERATION, |
| 86 base::UTF8ToUTF16(form.federation_url.host())); | 86 base::UTF8ToUTF16(form.federation_url.host())); |
| 87 scoped_ptr<views::Label> label(new views::Label(text)); | 87 scoped_ptr<views::Label> label(new views::Label(text)); |
| 88 label->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( | 88 label->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( |
| 89 ui::ResourceBundle::SmallFont)); | 89 ui::ResourceBundle::SmallFont)); |
| 90 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 90 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 91 if (form.federation_url.is_empty()) | 91 if (form.federation_url.is_empty()) |
| 92 label->SetObscured(true); | 92 label->SetObscured(true); |
| 93 return label.Pass(); | 93 return label; |
| 94 } | 94 } |
| 95 | 95 |
| 96 scoped_ptr<views::ImageButton> GenerateDeleteButton( | 96 scoped_ptr<views::ImageButton> GenerateDeleteButton( |
| 97 views::ButtonListener* listener) { | 97 views::ButtonListener* listener) { |
| 98 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 98 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
| 99 scoped_ptr<views::ImageButton> button(new views::ImageButton(listener)); | 99 scoped_ptr<views::ImageButton> button(new views::ImageButton(listener)); |
| 100 button->SetImage(views::ImageButton::STATE_NORMAL, | 100 button->SetImage(views::ImageButton::STATE_NORMAL, |
| 101 rb->GetImageNamed(IDR_CLOSE_2).ToImageSkia()); | 101 rb->GetImageNamed(IDR_CLOSE_2).ToImageSkia()); |
| 102 button->SetImage(views::ImageButton::STATE_HOVERED, | 102 button->SetImage(views::ImageButton::STATE_HOVERED, |
| 103 rb->GetImageNamed(IDR_CLOSE_2_H).ToImageSkia()); | 103 rb->GetImageNamed(IDR_CLOSE_2_H).ToImageSkia()); |
| 104 button->SetImage(views::ImageButton::STATE_PRESSED, | 104 button->SetImage(views::ImageButton::STATE_PRESSED, |
| 105 rb->GetImageNamed(IDR_CLOSE_2_P).ToImageSkia()); | 105 rb->GetImageNamed(IDR_CLOSE_2_P).ToImageSkia()); |
| 106 return button.Pass(); | 106 return button; |
| 107 } | 107 } |
| 108 | 108 |
| 109 scoped_ptr<views::Label> GenerateDeletedPasswordLabel() { | 109 scoped_ptr<views::Label> GenerateDeletedPasswordLabel() { |
| 110 scoped_ptr<views::Label> text(new views::Label( | 110 scoped_ptr<views::Label> text(new views::Label( |
| 111 l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_DELETED))); | 111 l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_DELETED))); |
| 112 text->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 112 text->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 113 text->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( | 113 text->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( |
| 114 ui::ResourceBundle::SmallFont)); | 114 ui::ResourceBundle::SmallFont)); |
| 115 return text.Pass(); | 115 return text; |
| 116 } | 116 } |
| 117 | 117 |
| 118 scoped_ptr<views::Link> GenerateUndoLink(views::LinkListener* listener) { | 118 scoped_ptr<views::Link> GenerateUndoLink(views::LinkListener* listener) { |
| 119 scoped_ptr<views::Link> undo_link(new views::Link( | 119 scoped_ptr<views::Link> undo_link(new views::Link( |
| 120 l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_UNDO))); | 120 l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_UNDO))); |
| 121 undo_link->SetHorizontalAlignment(gfx::ALIGN_RIGHT); | 121 undo_link->SetHorizontalAlignment(gfx::ALIGN_RIGHT); |
| 122 undo_link->set_listener(listener); | 122 undo_link->set_listener(listener); |
| 123 undo_link->SetUnderline(false); | 123 undo_link->SetUnderline(false); |
| 124 undo_link->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( | 124 undo_link->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( |
| 125 ui::ResourceBundle::SmallFont)); | 125 ui::ResourceBundle::SmallFont)); |
| 126 return undo_link.Pass(); | 126 return undo_link; |
| 127 } | 127 } |
| 128 | 128 |
| 129 } // namespace | 129 } // namespace |
| 130 | 130 |
| 131 // Manage credentials: stores credentials state and adds proper row to layout | 131 // Manage credentials: stores credentials state and adds proper row to layout |
| 132 // based on credential state. | 132 // based on credential state. |
| 133 class ManagePasswordItemsView::PasswordFormRow : public views::ButtonListener, | 133 class ManagePasswordItemsView::PasswordFormRow : public views::ButtonListener, |
| 134 public views::LinkListener { | 134 public views::LinkListener { |
| 135 public: | 135 public: |
| 136 PasswordFormRow(ManagePasswordItemsView* host, | 136 PasswordFormRow(ManagePasswordItemsView* host, |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 deleted | 295 deleted |
| 296 ? ManagePasswordsBubbleModel::REMOVE_PASSWORD | 296 ? ManagePasswordsBubbleModel::REMOVE_PASSWORD |
| 297 : ManagePasswordsBubbleModel::ADD_PASSWORD); | 297 : ManagePasswordsBubbleModel::ADD_PASSWORD); |
| 298 } | 298 } |
| 299 | 299 |
| 300 void ManagePasswordItemsView::Refresh() { | 300 void ManagePasswordItemsView::Refresh() { |
| 301 DCHECK_NE(password_manager::ui::PENDING_PASSWORD_STATE, model_->state()); | 301 DCHECK_NE(password_manager::ui::PENDING_PASSWORD_STATE, model_->state()); |
| 302 RemoveAllChildViews(true); | 302 RemoveAllChildViews(true); |
| 303 AddRows(); | 303 AddRows(); |
| 304 } | 304 } |
| OLD | NEW |