| 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" |
| 11 #include "chrome/grit/theme_resources.h" | 11 #include "chrome/grit/theme_resources.h" |
| 12 #include "components/autofill/core/common/password_form.h" | 12 #include "components/autofill/core/common/password_form.h" |
| 13 #include "ui/base/material_design/material_design_controller.h" |
| 13 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
| 14 #include "ui/gfx/canvas.h" | 15 #include "ui/gfx/canvas.h" |
| 15 #include "ui/gfx/path.h" | 16 #include "ui/gfx/path.h" |
| 16 #include "ui/views/border.h" | 17 #include "ui/views/border.h" |
| 17 #include "ui/views/bubble/tooltip_icon.h" | 18 #include "ui/views/bubble/tooltip_icon.h" |
| 18 #include "ui/views/controls/image_view.h" | 19 #include "ui/views/controls/image_view.h" |
| 19 #include "ui/views/controls/label.h" | 20 #include "ui/views/controls/label.h" |
| 20 #include "ui/views/layout/layout_constants.h" | 21 #include "ui/views/layout/layout_constants.h" |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 image.Height() >= kAvatarImageSize); | 84 image.Height() >= kAvatarImageSize); |
| 84 UpdateAvatar(image.AsImageSkia()); | 85 UpdateAvatar(image.AsImageSkia()); |
| 85 if (form_->icon_url.is_valid()) { | 86 if (form_->icon_url.is_valid()) { |
| 86 // Fetch the actual avatar. | 87 // Fetch the actual avatar. |
| 87 AccountAvatarFetcher* fetcher = new AccountAvatarFetcher( | 88 AccountAvatarFetcher* fetcher = new AccountAvatarFetcher( |
| 88 form_->icon_url, weak_ptr_factory_.GetWeakPtr()); | 89 form_->icon_url, weak_ptr_factory_.GetWeakPtr()); |
| 89 fetcher->Start(request_context); | 90 fetcher->Start(request_context); |
| 90 } | 91 } |
| 91 AddChildView(image_view_); | 92 AddChildView(image_view_); |
| 92 | 93 |
| 93 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 94 // TODO(tapted): Check these against the spec on http://crbug.com/651681. |
| 95 const views::TextContext kLabelContext = |
| 96 ui::MaterialDesignController::IsSecondaryUiMaterial() |
| 97 ? views::TextContext::DIALOG_TEXT_SMALL |
| 98 : views::TextContext::DEPRECATED_SMALL; |
| 99 constexpr views::TextStyle kUpperLabelStyle = views::TextStyle::PRIMARY; |
| 100 constexpr views::TextStyle kLowerLabelStyle = views::TextStyle::SECONDARY; |
| 101 |
| 94 if (!upper_text.empty()) { | 102 if (!upper_text.empty()) { |
| 95 upper_label_ = new views::Label( | 103 upper_label_ = |
| 96 upper_text, rb->GetFontList(ui::ResourceBundle::SmallFont)); | 104 new views::Label(upper_text, kLabelContext, kUpperLabelStyle); |
| 97 upper_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 105 upper_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 98 AddChildView(upper_label_); | 106 AddChildView(upper_label_); |
| 99 } | 107 } |
| 100 | 108 |
| 101 if (!lower_text.empty()) { | 109 if (!lower_text.empty()) { |
| 102 lower_label_ = new views::Label( | 110 lower_label_ = |
| 103 lower_text, rb->GetFontList(ui::ResourceBundle::SmallFont)); | 111 new views::Label(lower_text, kLabelContext, kLowerLabelStyle); |
| 104 lower_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 112 lower_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 105 lower_label_->SetMultiLine(true); | 113 lower_label_->SetMultiLine(true); |
| 106 AddChildView(lower_label_); | 114 AddChildView(lower_label_); |
| 107 } | 115 } |
| 108 | 116 |
| 109 if (form_->is_public_suffix_match) { | 117 if (form_->is_public_suffix_match) { |
| 110 info_icon_ = new views::TooltipIcon( | 118 info_icon_ = new views::TooltipIcon( |
| 111 base::UTF8ToUTF16(form_->origin.GetOrigin().spec())); | 119 base::UTF8ToUTF16(form_->origin.GetOrigin().spec())); |
| 112 AddChildView(info_icon_); | 120 AddChildView(info_icon_); |
| 113 } | 121 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 child_area.CenterPoint().y() - info_icon_->height() / 2)); | 195 child_area.CenterPoint().y() - info_icon_->height() / 2)); |
| 188 } | 196 } |
| 189 } | 197 } |
| 190 | 198 |
| 191 void CredentialsItemView::OnPaint(gfx::Canvas* canvas) { | 199 void CredentialsItemView::OnPaint(gfx::Canvas* canvas) { |
| 192 if (state() == STATE_PRESSED || state() == STATE_HOVERED) | 200 if (state() == STATE_PRESSED || state() == STATE_HOVERED) |
| 193 canvas->DrawColor(hover_color_); | 201 canvas->DrawColor(hover_color_); |
| 194 | 202 |
| 195 CustomButton::OnPaint(canvas); | 203 CustomButton::OnPaint(canvas); |
| 196 } | 204 } |
| OLD | NEW |