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 c4786fbe95711f1c4cb9145e9b10f4d9c593cd8b..aedd6fd84830de2073987463413df4732fcde307 100644 |
--- a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc |
+++ b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc |
@@ -6,7 +6,6 @@ |
#include <utility> |
-#include "base/i18n/rtl.h" |
#include "base/utf_string_conversions.h" |
#include "chrome/browser/autofill/wallet/wallet_service_url.h" |
#include "chrome/browser/profiles/profile.h" |
@@ -50,7 +49,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 +123,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) { |
sky
2013/02/11 21:07:34
Can you instead get what you need from arrow_cente
Dan Beam
2013/02/11 21:53:54
The width of |arrow_centering_anchor_| varies a lo
sky
2013/02/11 22:05:55
No need to denote more heavily. I was hoping you c
Dan Beam
2013/02/11 23:11:43
It's not guaranteed to, and it probably depends on
|
+ DCHECK(arrow_centering_anchor_); |
+ |
views::BoxLayout* layout = |
new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); |
layout->set_spread_blank_space(true); |
@@ -171,14 +173,14 @@ void AutofillDialogViews::NotificationArea::OnPaint(gfx::Canvas* canvas) { |
views::View::OnPaint(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); |
+ |
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()); |
@@ -356,7 +358,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), |
@@ -400,9 +402,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() { |
@@ -603,8 +606,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; |
} |
@@ -679,13 +686,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, |