| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 gfx::Rect bounds(GetImageBounds()); | 52 gfx::Rect bounds(GetImageBounds()); |
| 53 gfx::Path circular_mask; | 53 gfx::Path circular_mask; |
| 54 circular_mask.addCircle( | 54 circular_mask.addCircle( |
| 55 SkIntToScalar(bounds.x() + bounds.right()) / 2, | 55 SkIntToScalar(bounds.x() + bounds.right()) / 2, |
| 56 SkIntToScalar(bounds.y() + bounds.bottom()) / 2, | 56 SkIntToScalar(bounds.y() + bounds.bottom()) / 2, |
| 57 SkIntToScalar(std::min(bounds.height(), bounds.width())) / 2); | 57 SkIntToScalar(std::min(bounds.height(), bounds.width())) / 2); |
| 58 canvas->ClipPath(circular_mask, true); | 58 canvas->ClipPath(circular_mask, true); |
| 59 ImageView::OnPaint(canvas); | 59 ImageView::OnPaint(canvas); |
| 60 } | 60 } |
| 61 | 61 |
| 62 // An ImageView that consumes the mouse events. |
| 63 class InfoImageView : public views::ImageView { |
| 64 public: |
| 65 // View: |
| 66 bool OnMousePressed(const ui::MouseEvent& event) override { return true; } |
| 67 bool OnMouseDragged(const ui::MouseEvent& event) override { return true; } |
| 68 }; |
| 69 |
| 62 } // namespace | 70 } // namespace |
| 63 | 71 |
| 64 CredentialsItemView::CredentialsItemView( | 72 CredentialsItemView::CredentialsItemView( |
| 65 views::ButtonListener* button_listener, | 73 views::ButtonListener* button_listener, |
| 66 const base::string16& upper_text, | 74 const base::string16& upper_text, |
| 67 const base::string16& lower_text, | 75 const base::string16& lower_text, |
| 68 SkColor hover_color, | 76 SkColor hover_color, |
| 69 const autofill::PasswordForm* form, | 77 const autofill::PasswordForm* form, |
| 70 net::URLRequestContextGetter* request_context) | 78 net::URLRequestContextGetter* request_context) |
| 71 : LabelButton(button_listener, base::string16()), | 79 : LabelButton(button_listener, base::string16()), |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 111 |
| 104 if (!lower_text.empty()) { | 112 if (!lower_text.empty()) { |
| 105 lower_label_ = new views::Label( | 113 lower_label_ = new views::Label( |
| 106 lower_text, rb->GetFontList(ui::ResourceBundle::SmallFont)); | 114 lower_text, rb->GetFontList(ui::ResourceBundle::SmallFont)); |
| 107 lower_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 115 lower_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 108 lower_label_->SetMultiLine(true); | 116 lower_label_->SetMultiLine(true); |
| 109 AddChildView(lower_label_); | 117 AddChildView(lower_label_); |
| 110 } | 118 } |
| 111 | 119 |
| 112 if (form_->is_public_suffix_match) { | 120 if (form_->is_public_suffix_match) { |
| 113 info_icon_ = new views::ImageView; | 121 info_icon_ = new InfoImageView; |
| 114 info_icon_->SetImage(gfx::CreateVectorIcon(gfx::VectorIconId::INFO_OUTLINE, | 122 info_icon_->SetImage(gfx::CreateVectorIcon(gfx::VectorIconId::INFO_OUTLINE, |
| 115 kInfoIconSize, | 123 kInfoIconSize, |
| 116 gfx::kChromeIconGrey)); | 124 gfx::kChromeIconGrey)); |
| 117 info_icon_->SetTooltipText( | 125 info_icon_->SetTooltipText( |
| 118 base::UTF8ToUTF16(form_->origin.GetOrigin().spec())); | 126 base::UTF8ToUTF16(form_->origin.GetOrigin().spec())); |
| 119 AddChildView(info_icon_); | 127 AddChildView(info_icon_); |
| 120 } | 128 } |
| 121 | 129 |
| 122 if (!upper_text.empty() && !lower_text.empty()) | 130 if (!upper_text.empty() && !lower_text.empty()) |
| 123 SetAccessibleName(upper_text + base::ASCIIToUTF16("\n") + lower_text); | 131 SetAccessibleName(upper_text + base::ASCIIToUTF16("\n") + lower_text); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 child_area.CenterPoint().y() - info_icon_->height() / 2)); | 202 child_area.CenterPoint().y() - info_icon_->height() / 2)); |
| 195 } | 203 } |
| 196 } | 204 } |
| 197 | 205 |
| 198 void CredentialsItemView::OnPaint(gfx::Canvas* canvas) { | 206 void CredentialsItemView::OnPaint(gfx::Canvas* canvas) { |
| 199 if (state() == STATE_PRESSED || state() == STATE_HOVERED) | 207 if (state() == STATE_PRESSED || state() == STATE_HOVERED) |
| 200 canvas->DrawColor(hover_color_); | 208 canvas->DrawColor(hover_color_); |
| 201 | 209 |
| 202 LabelButton::OnPaint(canvas); | 210 LabelButton::OnPaint(canvas); |
| 203 } | 211 } |
| OLD | NEW |