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

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

Issue 1391893003: NOT FOR REVIEW: Aura on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
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 "components/autofill/core/browser/popup_item_ids.h" 8 #include "components/autofill/core/browser/popup_item_ids.h"
9 #include "components/autofill/core/browser/suggestion.h" 9 #include "components/autofill/core/browser/suggestion.h"
10 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 int index, 70 int index,
71 const gfx::Rect& entry_rect) { 71 const gfx::Rect& entry_rect) {
72 if (controller_->selected_line() == index) 72 if (controller_->selected_line() == index)
73 canvas->FillRect(entry_rect, kHoveredBackgroundColor); 73 canvas->FillRect(entry_rect, kHoveredBackgroundColor);
74 74
75 const bool is_rtl = controller_->IsRTL(); 75 const bool is_rtl = controller_->IsRTL();
76 const int text_align = 76 const int text_align =
77 is_rtl ? gfx::Canvas::TEXT_ALIGN_RIGHT : gfx::Canvas::TEXT_ALIGN_LEFT; 77 is_rtl ? gfx::Canvas::TEXT_ALIGN_RIGHT : gfx::Canvas::TEXT_ALIGN_LEFT;
78 gfx::Rect value_rect = entry_rect; 78 gfx::Rect value_rect = entry_rect;
79 value_rect.Inset(kEndPadding, 0); 79 value_rect.Inset(kEndPadding, 0);
80 #if !defined(OS_ANDROID)
80 canvas->DrawStringRectWithFlags( 81 canvas->DrawStringRectWithFlags(
81 controller_->GetElidedValueAt(index), 82 controller_->GetElidedValueAt(index),
82 controller_->GetValueFontListForRow(index), 83 controller_->GetValueFontListForRow(index),
83 controller_->IsWarning(index) ? kWarningTextColor : kValueTextColor, 84 controller_->IsWarning(index) ? kWarningTextColor : kValueTextColor,
84 value_rect, text_align); 85 value_rect, text_align);
86 #endif
85 87
86 // Use this to figure out where all the other Autofill items should be placed. 88 // Use this to figure out where all the other Autofill items should be placed.
87 int x_align_left = is_rtl ? kEndPadding : entry_rect.right() - kEndPadding; 89 int x_align_left = is_rtl ? kEndPadding : entry_rect.right() - kEndPadding;
88 90
89 // Draw the Autofill icon, if one exists 91 // Draw the Autofill icon, if one exists
90 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 92 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
91 int row_height = controller_->GetRowBounds(index).height(); 93 int row_height = controller_->GetRowBounds(index).height();
92 if (!controller_->GetSuggestionAt(index).icon.empty()) { 94 if (!controller_->GetSuggestionAt(index).icon.empty()) {
93 int icon = controller_->GetIconResourceID( 95 int icon = controller_->GetIconResourceID(
94 controller_->GetSuggestionAt(index).icon); 96 controller_->GetSuggestionAt(index).icon);
95 DCHECK_NE(-1, icon); 97 DCHECK_NE(-1, icon);
96 const gfx::ImageSkia* image = rb.GetImageSkiaNamed(icon); 98 const gfx::ImageSkia* image = rb.GetImageSkiaNamed(icon);
97 int icon_y = entry_rect.y() + (row_height - image->height()) / 2; 99 int icon_y = entry_rect.y() + (row_height - image->height()) / 2;
98 100
99 x_align_left += is_rtl ? 0 : -image->width(); 101 x_align_left += is_rtl ? 0 : -image->width();
100 102
101 canvas->DrawImageInt(*image, x_align_left, icon_y); 103 canvas->DrawImageInt(*image, x_align_left, icon_y);
102 104
103 x_align_left += is_rtl ? image->width() + kIconPadding : -kIconPadding; 105 x_align_left += is_rtl ? image->width() + kIconPadding : -kIconPadding;
104 } 106 }
105 107
108 #if !defined(OS_ANDROID)
106 // Draw the label text. 109 // Draw the label text.
107 const int label_width = 110 const int label_width =
108 gfx::GetStringWidth(controller_->GetElidedLabelAt(index), 111 gfx::GetStringWidth(controller_->GetElidedLabelAt(index),
109 controller_->GetLabelFontList()); 112 controller_->GetLabelFontList());
113 #else
114 const int label_width = 100;
115 #endif
110 if (!is_rtl) 116 if (!is_rtl)
111 x_align_left -= label_width; 117 x_align_left -= label_width;
112 118
113 canvas->DrawStringRectWithFlags( 119 canvas->DrawStringRectWithFlags(
114 controller_->GetElidedLabelAt(index), controller_->GetLabelFontList(), 120 controller_->GetElidedLabelAt(index), controller_->GetLabelFontList(),
115 kItemTextColor, 121 kItemTextColor,
116 gfx::Rect(x_align_left, entry_rect.y(), label_width, entry_rect.height()), 122 gfx::Rect(x_align_left, entry_rect.y(), label_width, entry_rect.height()),
117 text_align); 123 text_align);
118 } 124 }
119 125
120 AutofillPopupView* AutofillPopupView::Create( 126 AutofillPopupView* AutofillPopupView::Create(
121 AutofillPopupController* controller) { 127 AutofillPopupController* controller) {
122 views::Widget* observing_widget = 128 views::Widget* observing_widget =
123 views::Widget::GetTopLevelWidgetForNativeView( 129 views::Widget::GetTopLevelWidgetForNativeView(
124 controller->container_view()); 130 controller->container_view());
125 131
126 // If the top level widget can't be found, cancel the popup since we can't 132 // If the top level widget can't be found, cancel the popup since we can't
127 // fully set it up. 133 // fully set it up.
128 if (!observing_widget) 134 if (!observing_widget)
129 return NULL; 135 return NULL;
130 136
131 return new AutofillPopupViewViews(controller, observing_widget); 137 return new AutofillPopupViewViews(controller, observing_widget);
132 } 138 }
133 139
134 } // namespace autofill 140 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698