| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/credentials_selection_view.h" | 5 #include "chrome/browser/ui/views/passwords/credentials_selection_view.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" | 9 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" |
| 10 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" |
| 11 #include "chrome/browser/ui/views/harmony/chrome_typography.h" |
| 10 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" | 12 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" |
| 11 #include "ui/base/models/simple_combobox_model.h" | 13 #include "ui/base/models/simple_combobox_model.h" |
| 12 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
| 13 #include "ui/views/controls/button/button.h" | 15 #include "ui/views/controls/button/button.h" |
| 14 #include "ui/views/controls/combobox/combobox.h" | 16 #include "ui/views/controls/combobox/combobox.h" |
| 15 #include "ui/views/controls/label.h" | 17 #include "ui/views/controls/label.h" |
| 16 #include "ui/views/layout/grid_layout.h" | 18 #include "ui/views/layout/grid_layout.h" |
| 17 #include "ui/views/layout/layout_constants.h" | |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 views::Label* GeneratePasswordLabel(const autofill::PasswordForm& form) { | 22 views::Label* GeneratePasswordLabel(const autofill::PasswordForm& form) { |
| 22 views::Label* label = new views::Label(form.password_value); | 23 views::Label* label = |
| 23 label->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( | 24 new views::Label(form.password_value, CONTEXT_DEPRECATED_SMALL); |
| 24 ui::ResourceBundle::SmallFont)); | |
| 25 label->SetHorizontalAlignment(gfx::ALIGN_CENTER); | 25 label->SetHorizontalAlignment(gfx::ALIGN_CENTER); |
| 26 label->SetObscured(true); | 26 label->SetObscured(true); |
| 27 return label; | 27 return label; |
| 28 } | 28 } |
| 29 | 29 |
| 30 } // namespace | 30 } // namespace |
| 31 | 31 |
| 32 CredentialsSelectionView::CredentialsSelectionView( | 32 CredentialsSelectionView::CredentialsSelectionView( |
| 33 ManagePasswordsBubbleModel* manage_passwords_bubble_model) | 33 ManagePasswordsBubbleModel* manage_passwords_bubble_model) |
| 34 : password_forms_(&manage_passwords_bubble_model->local_credentials()), | 34 : password_forms_(&manage_passwords_bubble_model->local_credentials()), |
| 35 default_index_(0), | 35 default_index_(0), |
| 36 is_default_best_match_(false), | 36 is_default_best_match_(false), |
| 37 is_default_preferred_(false), | 37 is_default_preferred_(false), |
| 38 action_reported_(false) { | 38 action_reported_(false) { |
| 39 DCHECK(!password_forms_->empty()); | 39 DCHECK(!password_forms_->empty()); |
| 40 | 40 |
| 41 // Layout. | 41 // Layout. |
| 42 views::GridLayout* layout = new views::GridLayout(this); | 42 views::GridLayout* layout = new views::GridLayout(this); |
| 43 SetLayoutManager(layout); | 43 SetLayoutManager(layout); |
| 44 | 44 |
| 45 // ColumnSet. | 45 // ColumnSet. |
| 46 int column_set_id = 0; | 46 int column_set_id = 0; |
| 47 views::ColumnSet* column_set = layout->AddColumnSet(column_set_id); | 47 views::ColumnSet* column_set = layout->AddColumnSet(column_set_id); |
| 48 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, | 48 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, |
| 49 views::GridLayout::FIXED, 0, 0); | 49 views::GridLayout::FIXED, 0, 0); |
| 50 column_set->AddPaddingColumn(0, views::kItemLabelSpacing); | 50 ChromeLayoutProvider* layout_provider = ChromeLayoutProvider::Get(); |
| 51 const int inner_padding = |
| 52 layout_provider->GetDistanceMetric(DISTANCE_RELATED_LABEL_HORIZONTAL); |
| 53 column_set->AddPaddingColumn(0, inner_padding); |
| 51 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, | 54 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, |
| 52 views::GridLayout::FIXED, 0, 0); | 55 views::GridLayout::FIXED, 0, 0); |
| 53 column_set->AddPaddingColumn(0, views::kItemLabelSpacing); | 56 column_set->AddPaddingColumn(0, inner_padding); |
| 54 | 57 |
| 55 // The username combobox and password label. | 58 // The username combobox and password label. |
| 56 layout->StartRowWithPadding(0, column_set_id, 0, | 59 layout->StartRow(0, column_set_id); |
| 57 views::kRelatedControlVerticalSpacing); | |
| 58 GenerateUsernameCombobox( | 60 GenerateUsernameCombobox( |
| 59 manage_passwords_bubble_model->pending_password().username_value); | 61 manage_passwords_bubble_model->pending_password().username_value); |
| 60 layout->AddView(combobox_.get()); | 62 layout->AddView(combobox_.get()); |
| 61 views::Label* label = | 63 views::Label* label = |
| 62 GeneratePasswordLabel(manage_passwords_bubble_model->pending_password()); | 64 GeneratePasswordLabel(manage_passwords_bubble_model->pending_password()); |
| 63 layout->AddView(label); | 65 layout->AddView(label); |
| 64 | 66 |
| 65 GetLayoutManager()->Layout(this); | 67 GetLayoutManager()->Layout(this); |
| 66 } | 68 } |
| 67 | 69 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 DEFAULT_ACCOUNT_PREFERRED_USER_CHANGED; | 148 DEFAULT_ACCOUNT_PREFERRED_USER_CHANGED; |
| 147 } else { | 149 } else { |
| 148 action = | 150 action = |
| 149 password_manager::metrics_util::DEFAULT_ACCOUNT_FIRST_USER_CHANGED; | 151 password_manager::metrics_util::DEFAULT_ACCOUNT_FIRST_USER_CHANGED; |
| 150 } | 152 } |
| 151 } | 153 } |
| 152 | 154 |
| 153 password_manager::metrics_util::LogMultiAccountUpdateBubbleUserAction(action); | 155 password_manager::metrics_util::LogMultiAccountUpdateBubbleUserAction(action); |
| 154 action_reported_ = true; | 156 action_reported_ = true; |
| 155 } | 157 } |
| OLD | NEW |