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

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: x 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..d0a5762a78ed456ae698eacbf58969deabe83e45 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 {
Evan Stade 2013/02/06 21:57:49 it doesn't seem like you should need this. Why not
Dan Beam 2013/02/07 01:22:40 The width of the views::Link is always 100% of the
Evan Stade 2013/02/07 01:54:42 I do not think that's by design. Fix that (now or
Dan Beam 2013/02/07 03:26:53 Done.
+ return GetTextSize().width();
+}
+
// AutofillDialogViews::NotificationArea ---------------------------------------
-AutofillDialogViews::NotificationArea::NotificationArea()
- : label_(new views::Label()) {
+AutofillDialogViews::NotificationArea::NotificationArea(
+ AccountChooserLink* point_at)
Evan Stade 2013/02/06 21:57:49 not point_at. point_at sounds like a gfx::Point.
Dan Beam 2013/02/07 01:22:40 Done.
+ : label_(new views::Label()),
+ point_at_(point_at) {
+ DCHECK(point_at_);
+
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() - point_at_->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,24 @@ void AutofillDialogViews::Hide() {
}
void AutofillDialogViews::UpdateAccountChooser() {
- DialogSignedInState state = controller_->SignedInState();
- sign_in_link_->SetEnabled(state != REQUIRES_RESPONSE);
- sign_in_link_->SetVisible(state != SIGNED_IN);
+ string16 text;
+ bool enabled;
+
+ if (!controller_->IsWalletAvailable()) {
+ // TODO(dbeam): hide account chooser combobox when it exists?
+ // TODO(dbeam): hide Google Wallet logo when it exists.
+ text = controller_->PayWithoutWallet();
+ enabled = false;
+ } else {
+ // TODO(dbeam): show fancy Google Wallet logo.
+ DialogSignedInState state = controller_->SignedInState();
+ text = state != SIGNED_IN ? controller_->SignInText() :
+ controller_->SignedInUser();
+ enabled = state != REQUIRES_RESPONSE && state != SIGNED_IN;
+ }
+
+ account_chooser_link_->SetText(text);
+ account_chooser_link_->SetEnabled(enabled);
}
void AutofillDialogViews::UpdateNotificationArea() {
@@ -583,8 +615,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_->IsWalletAvailable());
+ controller_->StartSignInFlow();
+ }
+ // TODO(dbeam): handle other clicks on the account chooser (i.e. combobox).
return;
}
@@ -660,13 +696,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