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/chrome_typography.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 (and the STYLE_ values below) against the spec on |
| 96 // http://crbug.com/651681. |
| 97 const int kLabelContext = |
| 98 ui::MaterialDesignController::IsSecondaryUiMaterial() |
| 99 ? CONTEXT_BODY_TEXT_SMALL |
| 100 : CONTEXT_DEPRECATED_SMALL; |
| 101 |
94 if (!upper_text.empty()) { | 102 if (!upper_text.empty()) { |
95 upper_label_ = new views::Label( | 103 upper_label_ = new views::Label(upper_text, kLabelContext, |
96 upper_text, rb->GetFontList(ui::ResourceBundle::SmallFont)); | 104 views::style::STYLE_PRIMARY); |
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_ = new views::Label(lower_text, kLabelContext, STYLE_SECONDARY); |
103 lower_text, rb->GetFontList(ui::ResourceBundle::SmallFont)); | |
104 lower_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 111 lower_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
105 lower_label_->SetMultiLine(true); | 112 lower_label_->SetMultiLine(true); |
106 AddChildView(lower_label_); | 113 AddChildView(lower_label_); |
107 } | 114 } |
108 | 115 |
109 if (form_->is_public_suffix_match) { | 116 if (form_->is_public_suffix_match) { |
110 info_icon_ = new views::TooltipIcon( | 117 info_icon_ = new views::TooltipIcon( |
111 base::UTF8ToUTF16(form_->origin.GetOrigin().spec())); | 118 base::UTF8ToUTF16(form_->origin.GetOrigin().spec())); |
112 AddChildView(info_icon_); | 119 AddChildView(info_icon_); |
113 } | 120 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 child_area.CenterPoint().y() - info_icon_->height() / 2)); | 194 child_area.CenterPoint().y() - info_icon_->height() / 2)); |
188 } | 195 } |
189 } | 196 } |
190 | 197 |
191 void CredentialsItemView::OnPaint(gfx::Canvas* canvas) { | 198 void CredentialsItemView::OnPaint(gfx::Canvas* canvas) { |
192 if (state() == STATE_PRESSED || state() == STATE_HOVERED) | 199 if (state() == STATE_PRESSED || state() == STATE_HOVERED) |
193 canvas->DrawColor(hover_color_); | 200 canvas->DrawColor(hover_color_); |
194 | 201 |
195 CustomButton::OnPaint(canvas); | 202 CustomButton::OnPaint(canvas); |
196 } | 203 } |
OLD | NEW |