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

Unified Diff: chrome/browser/ui/views/autofill/autofill_dialog_views.cc

Issue 12221040: Interactive autofill: Handle Online Wallet being unavailable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/autofill/autofill_dialog_views.cc
diff --git a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc
index b19765d72704ee6b41d787d049887523c3aa3d48..7c0ed7fa93b854e0baa2f40237c57426cf2db16b 100644
--- a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc
+++ b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc
@@ -50,7 +50,6 @@ const size_t kAutocheckoutProgressBarHeight = 11;
const size_t kArrowHeight = 7;
const size_t kArrowWidth = 2 * kArrowHeight;
-const int kArrowEndOffset = 83;
const char kDecoratedTextfieldClassName[] = "autofill/DecoratedTextfield";
const char kNotificationAreaClassName[] = "autofill/NotificationArea";
@@ -125,8 +124,12 @@ void AutofillDialogViews::DecoratedTextfield::OnPaint(gfx::Canvas* canvas) {
// AutofillDialogViews::NotificationArea ---------------------------------------
-AutofillDialogViews::NotificationArea::NotificationArea()
- : label_(new views::Label()) {
+AutofillDialogViews::NotificationArea::NotificationArea(
+ views::View* arrow_centering_anchor)
+ : label_(new views::Label()),
+ arrow_centering_anchor_(arrow_centering_anchor) {
+ DCHECK(arrow_centering_anchor_);
+
views::BoxLayout* layout =
new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0);
layout->set_spread_blank_space(true);
@@ -173,12 +176,16 @@ void AutofillDialogViews::NotificationArea::OnPaint(gfx::Canvas* canvas) {
if (notification_.HasArrow()) {
// Not using GetMirroredXWithWidthInView() here because the code would still
// need to subtract the width of the arrow from the result in RTL.
- const int start_x = base::i18n::IsRTL() ? kArrowEndOffset :
- width() - kArrowEndOffset - kArrowWidth;
+ const int half_arrow = kArrowWidth / 2.0f;
+ const int arrow_middle = GetMirroredXInView(
+ width() - arrow_centering_anchor_->width() / 2.0f - half_arrow);
+ // TODO(dbeam): |arrow_centering_anchor_| is too big (not just text width),
Evan Stade 2013/02/07 06:13:21 either put something useful in this todo (i.e. som
Dan Beam 2013/02/07 18:22:36 Removed.
+ // so this arrow is pointing at the wrong thing. Blame estade@.
Evan Stade 2013/02/07 06:13:21 s/blame/thank
+
SkPath arrow;
- arrow.moveTo(start_x, kArrowHeight);
- arrow.lineTo(start_x + kArrowWidth, kArrowHeight);
- arrow.lineTo(start_x + kArrowWidth / 2.0f, 0);
+ arrow.moveTo(arrow_middle - half_arrow, kArrowHeight);
+ arrow.lineTo(arrow_middle + half_arrow, kArrowHeight);
+ arrow.lineTo(arrow_middle, 0);
arrow.close();
canvas->ClipPath(arrow);
canvas->DrawColor(notification_.GetBackgroundColor());
@@ -346,7 +353,7 @@ AutofillDialogViews::AutofillDialogViews(AutofillDialogController* controller)
contents_(NULL),
notification_area_(NULL),
use_billing_for_shipping_(NULL),
- sign_in_link_(NULL),
+ account_chooser_link_(NULL),
sign_in_container_(NULL),
cancel_sign_in_(NULL),
sign_in_webview_(NULL),
@@ -390,9 +397,10 @@ void AutofillDialogViews::Hide() {
}
void AutofillDialogViews::UpdateAccountChooser() {
- DialogSignedInState state = controller_->SignedInState();
- sign_in_link_->SetEnabled(state != REQUIRES_RESPONSE);
- sign_in_link_->SetVisible(state != SIGNED_IN);
+ // TODO(dbeam): show/hide account chooser combobox when it exists?
+ // TODO(dbeam): show/hide fancy Google Wallet logo when it exists.
+ account_chooser_link_->SetText(controller_->AccountChooserText());
+ account_chooser_link_->SetEnabled(controller_->AccountChooserEnabled());
}
void AutofillDialogViews::UpdateNotificationArea() {
@@ -583,8 +591,12 @@ void AutofillDialogViews::OnDidChangeFocus(
void AutofillDialogViews::LinkClicked(views::Link* source, int event_flags) {
// Sign in link.
- if (source == sign_in_link_) {
- controller_->StartSignInFlow();
+ if (source == account_chooser_link_) {
+ if (controller_->SignedInState() != SIGNED_IN) {
+ DCHECK(controller_->CanPayWithWallet());
+ controller_->StartSignInFlow();
+ }
+ // TODO(dbeam): handle other clicks on the account chooser (i.e. combobox).
return;
}
@@ -660,13 +672,14 @@ views::View* AutofillDialogViews::CreateMainContainer() {
layout->StartRow(0, single_column_set);
// TODO(abodenha) Create a chooser control to allow account selection.
// See http://crbug.com/169858
- sign_in_link_ = new views::Link(controller_->SignInText());
- sign_in_link_->SetHorizontalAlignment(gfx::ALIGN_RIGHT);
- sign_in_link_->set_listener(this);
- layout->AddView(sign_in_link_);
+ account_chooser_link_ = new views::Link();
+ account_chooser_link_->SetHorizontalAlignment(gfx::ALIGN_RIGHT);
+ account_chooser_link_->set_listener(this);
+ layout->AddView(account_chooser_link_);
- layout->StartRow(0, single_column_set);
- notification_area_ = new NotificationArea();
+ layout->StartRowWithPadding(0, single_column_set,
+ 0, views::kRelatedControlVerticalSpacing);
+ notification_area_ = new NotificationArea(account_chooser_link_);
layout->AddView(notification_area_);
layout->StartRowWithPadding(0, single_column_set,

Powered by Google App Engine
This is Rietveld 408576698