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

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: delete the icon 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
« no previous file with comments | « chrome/browser/ui/views/passwords/credentials_item_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
17 #include "ui/gfx/paint_vector_icon.h"
16 #include "ui/gfx/path.h" 18 #include "ui/gfx/path.h"
19 #include "ui/gfx/vector_icons_public.h"
17 #include "ui/views/border.h" 20 #include "ui/views/border.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,
(...skipping 35 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_icon_(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_icon_ = new views::ImageView;
114 info_icon_->SetImage(gfx::CreateVectorIcon(gfx::VectorIconId::INFO_OUTLINE,
115 kInfoIconSize,
116 gfx::kChromeIconGrey));
117 info_icon_->SetTooltipText(
118 base::UTF8ToUTF16(form_->origin.GetOrigin().spec()));
119 AddChildView(info_icon_);
120 }
121
108 if (!upper_text.empty() && !lower_text.empty()) 122 if (!upper_text.empty() && !lower_text.empty())
109 SetAccessibleName(upper_text + base::ASCIIToUTF16("\n") + lower_text); 123 SetAccessibleName(upper_text + base::ASCIIToUTF16("\n") + lower_text);
110 else 124 else
111 SetAccessibleName(upper_text + lower_text); 125 SetAccessibleName(upper_text + lower_text);
112 126
113 SetFocusBehavior(FocusBehavior::ALWAYS); 127 SetFocusBehavior(FocusBehavior::ALWAYS);
114 } 128 }
115 129
116 CredentialsItemView::~CredentialsItemView() = default; 130 CredentialsItemView::~CredentialsItemView() = default;
117 131
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 int y_offset = (child_area.height() - 180 int y_offset = (child_area.height() -
167 (upper_size.height() + lower_size.height())) / 2; 181 (upper_size.height() + lower_size.height())) / 2;
168 gfx::Point label_origin(image_origin.x() + image_size.width() + kSpacing, 182 gfx::Point label_origin(image_origin.x() + image_size.width() + kSpacing,
169 child_area.origin().y() + y_offset); 183 child_area.origin().y() + y_offset);
170 if (upper_label_) 184 if (upper_label_)
171 upper_label_->SetBoundsRect(gfx::Rect(label_origin, upper_size)); 185 upper_label_->SetBoundsRect(gfx::Rect(label_origin, upper_size));
172 if (lower_label_) { 186 if (lower_label_) {
173 label_origin.Offset(0, upper_size.height()); 187 label_origin.Offset(0, upper_size.height());
174 lower_label_->SetBoundsRect(gfx::Rect(label_origin, lower_size)); 188 lower_label_->SetBoundsRect(gfx::Rect(label_origin, lower_size));
175 } 189 }
190 if (info_icon_) {
191 info_icon_->SizeToPreferredSize();
192 info_icon_->SetPosition(
193 gfx::Point(child_area.right() - info_icon_->width(),
194 child_area.CenterPoint().y() - info_icon_->height() / 2));
195 }
176 } 196 }
177 197
178 void CredentialsItemView::OnPaint(gfx::Canvas* canvas) { 198 void CredentialsItemView::OnPaint(gfx::Canvas* canvas) {
179 if (state() == STATE_PRESSED || state() == STATE_HOVERED) 199 if (state() == STATE_PRESSED || state() == STATE_HOVERED)
180 canvas->DrawColor(hover_color_); 200 canvas->DrawColor(hover_color_);
181 201
182 LabelButton::OnPaint(canvas); 202 LabelButton::OnPaint(canvas);
183 } 203 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/passwords/credentials_item_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698