Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Side by Side Diff: chrome/browser/ui/views/passwords/credentials_item_view.cc

Issue 2532313003: Show an info icon with a tooltip for PSL-matches in the account chooser on Views. (Closed)
Patch Set: fix include Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/resource/resource_bundle.h" 13 #include "ui/base/resource/resource_bundle.h"
14 #include "ui/gfx/canvas.h" 14 #include "ui/gfx/canvas.h"
15 #include "ui/gfx/color_palette.h"
15 #include "ui/gfx/image/image.h" 16 #include "ui/gfx/image/image.h"
16 #include "ui/gfx/path.h" 17 #include "ui/gfx/path.h"
18 #include "ui/gfx/vector_icons_public.h"
17 #include "ui/views/border.h" 19 #include "ui/views/border.h"
20 #include "ui/views/controls/button/vector_icon_button.h"
18 #include "ui/views/controls/image_view.h" 21 #include "ui/views/controls/image_view.h"
19 #include "ui/views/controls/label.h" 22 #include "ui/views/controls/label.h"
20 #include "ui/views/layout/layout_constants.h" 23 #include "ui/views/layout/layout_constants.h"
21 24
22 namespace { 25 namespace {
23 // The default spacing between the icon and text. 26 // The default spacing between the icon and text.
24 const int kSpacing = 12; 27 const int kSpacing = 12;
25 28
26 gfx::Size GetTextLabelsSize(const views::Label* upper_label, 29 gfx::Size GetTextLabelsSize(const views::Label* upper_label,
27 const views::Label* lower_label) { 30 const views::Label* lower_label) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 views::ButtonListener* button_listener, 65 views::ButtonListener* button_listener,
63 const base::string16& upper_text, 66 const base::string16& upper_text,
64 const base::string16& lower_text, 67 const base::string16& lower_text,
65 SkColor hover_color, 68 SkColor hover_color,
66 const autofill::PasswordForm* form, 69 const autofill::PasswordForm* form,
67 net::URLRequestContextGetter* request_context) 70 net::URLRequestContextGetter* request_context)
68 : LabelButton(button_listener, base::string16()), 71 : LabelButton(button_listener, base::string16()),
69 form_(form), 72 form_(form),
70 upper_label_(nullptr), 73 upper_label_(nullptr),
71 lower_label_(nullptr), 74 lower_label_(nullptr),
75 info_button_(nullptr),
72 hover_color_(hover_color), 76 hover_color_(hover_color),
73 weak_ptr_factory_(this) { 77 weak_ptr_factory_(this) {
74 set_notify_enter_exit_on_child(true); 78 set_notify_enter_exit_on_child(true);
75 // Create an image-view for the avatar. Make sure it ignores events so that 79 // Create an image-view for the avatar. Make sure it ignores events so that
76 // the parent can receive the events instead. 80 // the parent can receive the events instead.
77 image_view_ = new CircularImageView; 81 image_view_ = new CircularImageView;
78 image_view_->set_interactive(false); 82 image_view_->set_interactive(false);
79 gfx::Image image = ResourceBundle::GetSharedInstance().GetImageNamed( 83 gfx::Image image = ResourceBundle::GetSharedInstance().GetImageNamed(
80 IDR_PROFILE_AVATAR_PLACEHOLDER_LARGE); 84 IDR_PROFILE_AVATAR_PLACEHOLDER_LARGE);
81 DCHECK(image.Width() >= kAvatarImageSize && 85 DCHECK(image.Width() >= kAvatarImageSize &&
(...skipping 16 matching lines...) Expand all
98 } 102 }
99 103
100 if (!lower_text.empty()) { 104 if (!lower_text.empty()) {
101 lower_label_ = new views::Label( 105 lower_label_ = new views::Label(
102 lower_text, rb->GetFontList(ui::ResourceBundle::SmallFont)); 106 lower_text, rb->GetFontList(ui::ResourceBundle::SmallFont));
103 lower_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 107 lower_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
104 lower_label_->SetMultiLine(true); 108 lower_label_->SetMultiLine(true);
105 AddChildView(lower_label_); 109 AddChildView(lower_label_);
106 } 110 }
107 111
112 if (form_->is_public_suffix_match) {
113 info_button_ = new views::VectorIconButton(this);
114 info_button_->SetIcon(gfx::VectorIconId::INFORMATION);
115 info_button_->SetTooltipText(
116 base::UTF8ToUTF16(form_->origin.GetOrigin().spec()));
117 AddChildView(info_button_);
118 }
119
108 if (!upper_text.empty() && !lower_text.empty()) 120 if (!upper_text.empty() && !lower_text.empty())
109 SetAccessibleName(upper_text + base::ASCIIToUTF16("\n") + lower_text); 121 SetAccessibleName(upper_text + base::ASCIIToUTF16("\n") + lower_text);
110 else 122 else
111 SetAccessibleName(upper_text + lower_text); 123 SetAccessibleName(upper_text + lower_text);
112 124
113 SetFocusBehavior(FocusBehavior::ALWAYS); 125 SetFocusBehavior(FocusBehavior::ALWAYS);
114 } 126 }
115 127
116 CredentialsItemView::~CredentialsItemView() = default; 128 CredentialsItemView::~CredentialsItemView() = default;
117 129
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 int y_offset = (child_area.height() - 178 int y_offset = (child_area.height() -
167 (upper_size.height() + lower_size.height())) / 2; 179 (upper_size.height() + lower_size.height())) / 2;
168 gfx::Point label_origin(image_origin.x() + image_size.width() + kSpacing, 180 gfx::Point label_origin(image_origin.x() + image_size.width() + kSpacing,
169 child_area.origin().y() + y_offset); 181 child_area.origin().y() + y_offset);
170 if (upper_label_) 182 if (upper_label_)
171 upper_label_->SetBoundsRect(gfx::Rect(label_origin, upper_size)); 183 upper_label_->SetBoundsRect(gfx::Rect(label_origin, upper_size));
172 if (lower_label_) { 184 if (lower_label_) {
173 label_origin.Offset(0, upper_size.height()); 185 label_origin.Offset(0, upper_size.height());
174 lower_label_->SetBoundsRect(gfx::Rect(label_origin, lower_size)); 186 lower_label_->SetBoundsRect(gfx::Rect(label_origin, lower_size));
175 } 187 }
188 if (info_button_) {
189 gfx::Rect icon_rect(child_area.top_right(),
190 gfx::Size(kInfoIconSize, kInfoIconSize));
191 icon_rect.Offset(-kInfoIconSize, (child_area.height() - kInfoIconSize) / 2);
Evan Stade 2016/11/29 15:06:50 I had a hard time reading this (the screenshot hel
vasilii 2016/11/29 17:23:03 Done.
192 info_button_->SetBoundsRect(icon_rect);
193 }
176 } 194 }
177 195
178 void CredentialsItemView::OnPaint(gfx::Canvas* canvas) { 196 void CredentialsItemView::OnPaint(gfx::Canvas* canvas) {
179 if (state() == STATE_PRESSED || state() == STATE_HOVERED) 197 if (state() == STATE_PRESSED || state() == STATE_HOVERED)
180 canvas->DrawColor(hover_color_); 198 canvas->DrawColor(hover_color_);
181 199
182 LabelButton::OnPaint(canvas); 200 LabelButton::OnPaint(canvas);
183 } 201 }
202
203 void CredentialsItemView::ButtonPressed(views::Button* sender,
204 const ui::Event& event) {
205 DCHECK(sender == info_button_);
Evan Stade 2016/11/29 15:06:50 DCHECK_EQ but why is this a button if you don't c
vasilii 2016/11/29 17:23:03 Done. I'll ask the designer. I feel that many rows
vasilii 2016/11/30 13:17:45 Hwi said that the autofill dialog should switch to
206 }
207
208 SkColor CredentialsItemView::GetVectorIconBaseColor() const {
209 return gfx::kChromeIconGrey;
210 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698