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

Side by Side Diff: chrome/browser/ui/views/autofill/autofill_popup_view_views.cc

Issue 2152243002: [Autofill] Tweak credit card signin promo visually. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: no curlies Created 4 years, 5 months 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/autofill/autofill_popup_base_view.cc ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/autofill/autofill_popup_view_views.h" 5 #include "chrome/browser/ui/views/autofill/autofill_popup_view_views.h"
6 6
7 #include "chrome/browser/ui/autofill/autofill_popup_controller.h" 7 #include "chrome/browser/ui/autofill/autofill_popup_controller.h"
8 #include "chrome/browser/ui/autofill/autofill_popup_layout_model.h" 8 #include "chrome/browser/ui/autofill/autofill_popup_layout_model.h"
9 #include "chrome/browser/ui/autofill/popup_constants.h"
9 #include "components/autofill/core/browser/popup_item_ids.h" 10 #include "components/autofill/core/browser/popup_item_ids.h"
10 #include "components/autofill/core/browser/suggestion.h" 11 #include "components/autofill/core/browser/suggestion.h"
11 #include "ui/base/resource/resource_bundle.h" 12 #include "ui/base/resource/resource_bundle.h"
12 #include "ui/events/keycodes/keyboard_codes.h" 13 #include "ui/events/keycodes/keyboard_codes.h"
13 #include "ui/gfx/canvas.h" 14 #include "ui/gfx/canvas.h"
14 #include "ui/gfx/geometry/point.h" 15 #include "ui/gfx/geometry/point.h"
15 #include "ui/gfx/geometry/rect.h" 16 #include "ui/gfx/geometry/rect.h"
16 #include "ui/gfx/image/image.h" 17 #include "ui/gfx/image/image.h"
17 #include "ui/gfx/native_widget_types.h" 18 #include "ui/gfx/native_widget_types.h"
18 #include "ui/gfx/text_utils.h" 19 #include "ui/gfx/text_utils.h"
(...skipping 30 matching lines...) Expand all
49 return; 50 return;
50 51
51 canvas->DrawColor(kPopupBackground); 52 canvas->DrawColor(kPopupBackground);
52 OnPaintBorder(canvas); 53 OnPaintBorder(canvas);
53 54
54 for (size_t i = 0; i < controller_->GetLineCount(); ++i) { 55 for (size_t i = 0; i < controller_->GetLineCount(); ++i) {
55 gfx::Rect line_rect = controller_->layout_model().GetRowBounds(i); 56 gfx::Rect line_rect = controller_->layout_model().GetRowBounds(i);
56 57
57 if (controller_->GetSuggestionAt(i).frontend_id == 58 if (controller_->GetSuggestionAt(i).frontend_id ==
58 POPUP_ITEM_ID_SEPARATOR) { 59 POPUP_ITEM_ID_SEPARATOR) {
59 canvas->FillRect(line_rect, kItemTextColor); 60 canvas->FillRect(line_rect, kLabelTextColor);
60 } else { 61 } else {
61 DrawAutofillEntry(canvas, i, line_rect); 62 DrawAutofillEntry(canvas, i, line_rect);
62 } 63 }
63 } 64 }
64 } 65 }
65 66
66 void AutofillPopupViewViews::InvalidateRow(size_t row) { 67 void AutofillPopupViewViews::InvalidateRow(size_t row) {
67 SchedulePaintInRect(controller_->layout_model().GetRowBounds(row)); 68 SchedulePaintInRect(controller_->layout_model().GetRowBounds(row));
68 } 69 }
69 70
70 void AutofillPopupViewViews::DrawAutofillEntry(gfx::Canvas* canvas, 71 void AutofillPopupViewViews::DrawAutofillEntry(gfx::Canvas* canvas,
71 int index, 72 int index,
72 const gfx::Rect& entry_rect) { 73 const gfx::Rect& entry_rect) {
73 if (controller_->selected_line() == index) 74 canvas->FillRect(entry_rect, controller_->GetBackgroundColorForRow(index));
74 canvas->FillRect(entry_rect, kHoveredBackgroundColor);
75 75
76 const bool is_rtl = controller_->IsRTL(); 76 const bool is_rtl = controller_->IsRTL();
77 const int text_align = 77 const int text_align =
78 is_rtl ? gfx::Canvas::TEXT_ALIGN_RIGHT : gfx::Canvas::TEXT_ALIGN_LEFT; 78 is_rtl ? gfx::Canvas::TEXT_ALIGN_RIGHT : gfx::Canvas::TEXT_ALIGN_LEFT;
79 gfx::Rect value_rect = entry_rect; 79 gfx::Rect value_rect = entry_rect;
80 value_rect.Inset(AutofillPopupLayoutModel::kEndPadding, 0); 80 value_rect.Inset(AutofillPopupLayoutModel::kEndPadding, 0);
81 canvas->DrawStringRectWithFlags( 81 canvas->DrawStringRectWithFlags(
82 controller_->GetElidedValueAt(index), 82 controller_->GetElidedValueAt(index),
83 controller_->GetValueFontListForRow(index), 83 controller_->GetValueFontListForRow(index),
84 controller_->IsWarning(index) ? kWarningTextColor : kValueTextColor, 84 controller_->IsWarning(index) ? kWarningTextColor : kValueTextColor,
(...skipping 25 matching lines...) Expand all
110 110
111 // Draw the label text. 111 // Draw the label text.
112 const int label_width = 112 const int label_width =
113 gfx::GetStringWidth(controller_->GetElidedLabelAt(index), 113 gfx::GetStringWidth(controller_->GetElidedLabelAt(index),
114 controller_->GetLabelFontList()); 114 controller_->GetLabelFontList());
115 if (!is_rtl) 115 if (!is_rtl)
116 x_align_left -= label_width; 116 x_align_left -= label_width;
117 117
118 canvas->DrawStringRectWithFlags( 118 canvas->DrawStringRectWithFlags(
119 controller_->GetElidedLabelAt(index), controller_->GetLabelFontList(), 119 controller_->GetElidedLabelAt(index), controller_->GetLabelFontList(),
120 kItemTextColor, 120 kLabelTextColor,
121 gfx::Rect(x_align_left, entry_rect.y(), label_width, entry_rect.height()), 121 gfx::Rect(x_align_left, entry_rect.y(), label_width, entry_rect.height()),
122 text_align); 122 text_align);
123 } 123 }
124 124
125 AutofillPopupView* AutofillPopupView::Create( 125 AutofillPopupView* AutofillPopupView::Create(
126 AutofillPopupController* controller) { 126 AutofillPopupController* controller) {
127 views::Widget* observing_widget = 127 views::Widget* observing_widget =
128 views::Widget::GetTopLevelWidgetForNativeView( 128 views::Widget::GetTopLevelWidgetForNativeView(
129 controller->container_view()); 129 controller->container_view());
130 130
131 // If the top level widget can't be found, cancel the popup since we can't 131 // If the top level widget can't be found, cancel the popup since we can't
132 // fully set it up. 132 // fully set it up.
133 if (!observing_widget) 133 if (!observing_widget)
134 return NULL; 134 return NULL;
135 135
136 return new AutofillPopupViewViews(controller, observing_widget); 136 return new AutofillPopupViewViews(controller, observing_widget);
137 } 137 }
138 138
139 } // namespace autofill 139 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/autofill/autofill_popup_base_view.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698