| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_item_view.h" | 5 #include "chrome/browser/ui/views/passwords/credentials_item_view.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h" | 9 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h" |
| 10 #include "chrome/grit/generated_resources.h" | 10 #include "chrome/grit/generated_resources.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 upper_label_ = new views::Label( | 95 upper_label_ = new views::Label( |
| 96 upper_text, rb->GetFontList(ui::ResourceBundle::SmallFont)); | 96 upper_text, rb->GetFontList(ui::ResourceBundle::SmallFont)); |
| 97 upper_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 97 upper_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 98 AddChildView(upper_label_); | 98 AddChildView(upper_label_); |
| 99 } | 99 } |
| 100 | 100 |
| 101 if (!lower_text.empty()) { | 101 if (!lower_text.empty()) { |
| 102 lower_label_ = new views::Label( | 102 lower_label_ = new views::Label( |
| 103 lower_text, rb->GetFontList(ui::ResourceBundle::SmallFont)); | 103 lower_text, rb->GetFontList(ui::ResourceBundle::SmallFont)); |
| 104 lower_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 104 lower_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 105 lower_label_->SetMultiLine(true); |
| 105 AddChildView(lower_label_); | 106 AddChildView(lower_label_); |
| 106 } | 107 } |
| 107 | 108 |
| 109 if (!upper_text.empty() && !lower_text.empty()) |
| 110 SetAccessibleName(upper_text + base::ASCIIToUTF16("\n") + lower_text); |
| 111 else |
| 112 SetAccessibleName(upper_text + lower_text); |
| 113 |
| 108 SetFocusBehavior(FocusBehavior::ALWAYS); | 114 SetFocusBehavior(FocusBehavior::ALWAYS); |
| 109 } | 115 } |
| 110 | 116 |
| 111 CredentialsItemView::~CredentialsItemView() = default; | 117 CredentialsItemView::~CredentialsItemView() = default; |
| 112 | 118 |
| 113 void CredentialsItemView::UpdateAvatar(const gfx::ImageSkia& image) { | 119 void CredentialsItemView::UpdateAvatar(const gfx::ImageSkia& image) { |
| 114 image_view_->SetImage(ScaleImageForAccountAvatar(image)); | 120 image_view_->SetImage(ScaleImageForAccountAvatar(image)); |
| 115 } | 121 } |
| 116 | 122 |
| 117 void CredentialsItemView::SetLowerLabelColor(SkColor color) { | 123 void CredentialsItemView::SetLowerLabelColor(SkColor color) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 lower_label_->SetBoundsRect(gfx::Rect(label_origin, lower_size)); | 175 lower_label_->SetBoundsRect(gfx::Rect(label_origin, lower_size)); |
| 170 } | 176 } |
| 171 } | 177 } |
| 172 | 178 |
| 173 void CredentialsItemView::OnPaint(gfx::Canvas* canvas) { | 179 void CredentialsItemView::OnPaint(gfx::Canvas* canvas) { |
| 174 if (state() == STATE_PRESSED || state() == STATE_HOVERED) | 180 if (state() == STATE_PRESSED || state() == STATE_HOVERED) |
| 175 canvas->DrawColor(hover_color_); | 181 canvas->DrawColor(hover_color_); |
| 176 | 182 |
| 177 LabelButton::OnPaint(canvas); | 183 LabelButton::OnPaint(canvas); |
| 178 } | 184 } |
| OLD | NEW |