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

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..7249bc8c206f0ed9afd8e8becf8ef6ae796ec6f7 100644
--- a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc
+++ b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc
@@ -27,7 +27,6 @@
#include "ui/views/controls/combobox/combobox.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h"
-#include "ui/views/controls/link.h"
#include "ui/views/controls/menu/menu_model_adapter.h"
#include "ui/views/controls/menu/menu_runner.h"
#include "ui/views/controls/separator.h"
@@ -123,10 +122,26 @@ void AutofillDialogViews::DecoratedTextfield::OnPaint(gfx::Canvas* canvas) {
}
}
+// AutofillDialogViews::AccountChooserLink -------------------------------------
+
+AutofillDialogViews::AccountChooserLink::AccountChooserLink() : views::Link() {
+ SetHorizontalAlignment(gfx::ALIGN_RIGHT);
+}
+
+AutofillDialogViews::AccountChooserLink::~AccountChooserLink() {}
+
+size_t AutofillDialogViews::AccountChooserLink::GetTextWidth() const {
+ return GetTextSize().width();
+}
+
// AutofillDialogViews::NotificationArea ---------------------------------------
-AutofillDialogViews::NotificationArea::NotificationArea()
- : label_(new views::Label()) {
+AutofillDialogViews::NotificationArea::NotificationArea(
+ AccountChooserLink* 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 +188,14 @@ 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_->GetTextWidth() / 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());
@@ -346,7 +363,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 +407,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 +601,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 +682,13 @@ 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 AccountChooserLink();
+ 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