Chromium Code Reviews| 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/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" | 12 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" |
| 13 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h" | 13 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h" |
| 14 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" | 14 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" |
| 15 #include "chrome/browser/ui/views/harmony/chrome_typography.h" | 15 #include "chrome/browser/ui/views/harmony/chrome_typography.h" |
| 16 #include "chrome/grit/generated_resources.h" | 16 #include "chrome/grit/generated_resources.h" |
| 17 #include "components/password_manager/core/common/password_manager_ui.h" | |
| 17 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 18 #include "ui/base/resource/resource_bundle.h" | 19 #include "ui/base/resource/resource_bundle.h" |
| 19 #include "ui/resources/grit/ui_resources.h" | 20 #include "ui/resources/grit/ui_resources.h" |
| 20 #include "ui/views/controls/button/button.h" | 21 #include "ui/views/controls/button/button.h" |
| 21 #include "ui/views/controls/button/image_button.h" | 22 #include "ui/views/controls/button/image_button.h" |
| 22 #include "ui/views/controls/label.h" | 23 #include "ui/views/controls/label.h" |
| 23 #include "ui/views/controls/link.h" | 24 #include "ui/views/controls/link.h" |
| 24 #include "ui/views/controls/link_listener.h" | 25 #include "ui/views/controls/link_listener.h" |
| 26 #include "ui/views/controls/textfield/textfield.h" | |
| 25 #include "ui/views/layout/fill_layout.h" | 27 #include "ui/views/layout/fill_layout.h" |
| 26 #include "ui/views/layout/grid_layout.h" | 28 #include "ui/views/layout/grid_layout.h" |
| 27 | 29 |
| 28 namespace { | 30 namespace { |
| 29 | 31 |
| 30 enum ColumnSets { | 32 enum ColumnSets { |
| 31 ONE_COLUMN_SET, | 33 ONE_COLUMN_SET, |
| 32 TWO_COLUMN_SET, | 34 TWO_COLUMN_SET, |
| 33 THREE_COLUMN_SET | 35 THREE_COLUMN_SET |
| 34 }; | 36 }; |
| 35 | 37 |
| 38 std::unique_ptr<views::Label> GenerateUsernameLabel( | |
|
vasilii
2017/07/03 17:15:30
You should move them out of the anonymous namespac
irmakk
2017/07/06 10:42:46
Done.
| |
| 39 const autofill::PasswordForm& form) { | |
| 40 auto label = base::MakeUnique<views::Label>(GetDisplayUsername(form), | |
| 41 CONTEXT_DEPRECATED_SMALL); | |
| 42 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
| 43 return label; | |
| 44 } | |
| 45 | |
| 46 std::unique_ptr<views::Textfield> GenerateUsernameEditable( | |
| 47 const autofill::PasswordForm& form) { | |
| 48 auto editable = base::MakeUnique<views::Textfield>(); | |
| 49 editable->SetText(GetDisplayUsername(form)); | |
|
vasilii
2017/07/03 17:15:31
I don't think we should fill <no username> there.
irmakk
2017/07/06 10:42:46
Done.
| |
| 50 return editable; | |
| 51 } | |
| 52 | |
| 53 std::unique_ptr<views::Label> GeneratePasswordLabel( | |
| 54 const autofill::PasswordForm& form) { | |
| 55 base::string16 text = | |
| 56 form.federation_origin.unique() | |
| 57 ? form.password_value | |
| 58 : l10n_util::GetStringFUTF16( | |
| 59 IDS_PASSWORDS_VIA_FEDERATION, | |
| 60 base::UTF8ToUTF16(form.federation_origin.host())); | |
| 61 auto label = base::MakeUnique<views::Label>(text, CONTEXT_DEPRECATED_SMALL); | |
| 62 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
| 63 if (form.federation_origin.unique()) | |
| 64 label->SetObscured(true); | |
| 65 return label; | |
| 66 } | |
| 67 | |
| 36 void BuildColumnSetIfNeeded(views::GridLayout* layout, int column_set_id) { | 68 void BuildColumnSetIfNeeded(views::GridLayout* layout, int column_set_id) { |
| 37 if (layout->GetColumnSet(column_set_id)) | 69 if (layout->GetColumnSet(column_set_id)) |
| 38 return; | 70 return; |
| 39 views::ColumnSet* column_set = layout->AddColumnSet(column_set_id); | 71 views::ColumnSet* column_set = layout->AddColumnSet(column_set_id); |
| 40 | 72 |
| 41 // The username/"Deleted!"/Border field. | 73 // The username/"Deleted!"/Border field. |
| 42 column_set->AddColumn(views::GridLayout::FILL, | 74 column_set->AddColumn(views::GridLayout::FILL, |
| 43 views::GridLayout::FILL, | 75 views::GridLayout::FILL, |
| 44 1, | 76 1, |
| 45 views::GridLayout::USE_PREF, | 77 views::GridLayout::USE_PREF, |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 63 column_set->AddPaddingColumn(0, column_divider); | 95 column_set->AddPaddingColumn(0, column_divider); |
| 64 column_set->AddColumn(views::GridLayout::TRAILING, | 96 column_set->AddColumn(views::GridLayout::TRAILING, |
| 65 views::GridLayout::FILL, | 97 views::GridLayout::FILL, |
| 66 0, | 98 0, |
| 67 views::GridLayout::USE_PREF, | 99 views::GridLayout::USE_PREF, |
| 68 0, | 100 0, |
| 69 0); | 101 0); |
| 70 } | 102 } |
| 71 } | 103 } |
| 72 | 104 |
| 73 std::unique_ptr<views::Label> GenerateUsernameLabel( | |
| 74 const autofill::PasswordForm& form) { | |
| 75 auto label = base::MakeUnique<views::Label>(GetDisplayUsername(form), | |
| 76 CONTEXT_DEPRECATED_SMALL); | |
| 77 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
| 78 return label; | |
| 79 } | |
| 80 | |
| 81 std::unique_ptr<views::Label> GeneratePasswordLabel( | |
| 82 const autofill::PasswordForm& form) { | |
| 83 base::string16 text = | |
| 84 form.federation_origin.unique() | |
| 85 ? form.password_value | |
| 86 : l10n_util::GetStringFUTF16( | |
| 87 IDS_PASSWORDS_VIA_FEDERATION, | |
| 88 base::UTF8ToUTF16(form.federation_origin.host())); | |
| 89 auto label = base::MakeUnique<views::Label>(text, CONTEXT_DEPRECATED_SMALL); | |
| 90 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
| 91 if (form.federation_origin.unique()) | |
| 92 label->SetObscured(true); | |
| 93 return label; | |
| 94 } | |
| 95 | |
| 96 std::unique_ptr<views::ImageButton> GenerateDeleteButton( | 105 std::unique_ptr<views::ImageButton> GenerateDeleteButton( |
| 97 views::ButtonListener* listener) { | 106 views::ButtonListener* listener) { |
| 98 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 107 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
| 99 std::unique_ptr<views::ImageButton> button(new views::ImageButton(listener)); | 108 std::unique_ptr<views::ImageButton> button(new views::ImageButton(listener)); |
| 100 button->SetImage(views::ImageButton::STATE_NORMAL, | 109 button->SetImage(views::ImageButton::STATE_NORMAL, |
| 101 rb->GetImageNamed(IDR_CLOSE_2).ToImageSkia()); | 110 rb->GetImageNamed(IDR_CLOSE_2).ToImageSkia()); |
| 102 button->SetImage(views::ImageButton::STATE_HOVERED, | 111 button->SetImage(views::ImageButton::STATE_HOVERED, |
| 103 rb->GetImageNamed(IDR_CLOSE_2_H).ToImageSkia()); | 112 rb->GetImageNamed(IDR_CLOSE_2_H).ToImageSkia()); |
| 104 button->SetImage(views::ImageButton::STATE_PRESSED, | 113 button->SetImage(views::ImageButton::STATE_PRESSED, |
| 105 rb->GetImageNamed(IDR_CLOSE_2_P).ToImageSkia()); | 114 rb->GetImageNamed(IDR_CLOSE_2_P).ToImageSkia()); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 309 deleted | 318 deleted |
| 310 ? ManagePasswordsBubbleModel::REMOVE_PASSWORD | 319 ? ManagePasswordsBubbleModel::REMOVE_PASSWORD |
| 311 : ManagePasswordsBubbleModel::ADD_PASSWORD); | 320 : ManagePasswordsBubbleModel::ADD_PASSWORD); |
| 312 } | 321 } |
| 313 | 322 |
| 314 void ManagePasswordItemsView::Refresh() { | 323 void ManagePasswordItemsView::Refresh() { |
| 315 DCHECK_NE(password_manager::ui::PENDING_PASSWORD_STATE, model_->state()); | 324 DCHECK_NE(password_manager::ui::PENDING_PASSWORD_STATE, model_->state()); |
| 316 RemoveAllChildViews(true); | 325 RemoveAllChildViews(true); |
| 317 AddRows(); | 326 AddRows(); |
| 318 } | 327 } |
| OLD | NEW |