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