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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
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_dialog_views.h" 5 #include "chrome/browser/ui/views/autofill/autofill_dialog_views.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 namespace { 43 namespace {
44 44
45 // Size of the triangular mark that indicates an invalid textfield. 45 // Size of the triangular mark that indicates an invalid textfield.
46 const size_t kDogEarSize = 10; 46 const size_t kDogEarSize = 10;
47 47
48 const size_t kAutocheckoutProgressBarWidth = 300; 48 const size_t kAutocheckoutProgressBarWidth = 300;
49 const size_t kAutocheckoutProgressBarHeight = 11; 49 const size_t kAutocheckoutProgressBarHeight = 11;
50 50
51 const size_t kArrowHeight = 7; 51 const size_t kArrowHeight = 7;
52 const size_t kArrowWidth = 2 * kArrowHeight; 52 const size_t kArrowWidth = 2 * kArrowHeight;
53 const int kArrowEndOffset = 83;
54 53
55 const char kDecoratedTextfieldClassName[] = "autofill/DecoratedTextfield"; 54 const char kDecoratedTextfieldClassName[] = "autofill/DecoratedTextfield";
56 const char kNotificationAreaClassName[] = "autofill/NotificationArea"; 55 const char kNotificationAreaClassName[] = "autofill/NotificationArea";
57 56
58 // Returns a label that describes a details section. 57 // Returns a label that describes a details section.
59 views::Label* CreateDetailsSectionLabel(const string16& text) { 58 views::Label* CreateDetailsSectionLabel(const string16& text) {
60 views::Label* label = new views::Label(text); 59 views::Label* label = new views::Label(text);
61 label->SetHorizontalAlignment(gfx::ALIGN_RIGHT); 60 label->SetHorizontalAlignment(gfx::ALIGN_RIGHT);
62 label->SetFont(label->font().DeriveFont(0, gfx::Font::BOLD)); 61 label->SetFont(label->font().DeriveFont(0, gfx::Font::BOLD));
63 // TODO(estade): this should be made to match the native textfield top 62 // TODO(estade): this should be made to match the native textfield top
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 dog_ear.lineTo(width(), 0); 117 dog_ear.lineTo(width(), 0);
119 dog_ear.lineTo(width(), kDogEarSize); 118 dog_ear.lineTo(width(), kDogEarSize);
120 dog_ear.close(); 119 dog_ear.close();
121 canvas->ClipPath(dog_ear); 120 canvas->ClipPath(dog_ear);
122 canvas->DrawColor(SK_ColorRED); 121 canvas->DrawColor(SK_ColorRED);
123 } 122 }
124 } 123 }
125 124
126 // AutofillDialogViews::NotificationArea --------------------------------------- 125 // AutofillDialogViews::NotificationArea ---------------------------------------
127 126
128 AutofillDialogViews::NotificationArea::NotificationArea() 127 AutofillDialogViews::NotificationArea::NotificationArea(
129 : label_(new views::Label()) { 128 views::View* arrow_centering_anchor)
129 : label_(new views::Label()),
130 arrow_centering_anchor_(arrow_centering_anchor) {
131 DCHECK(arrow_centering_anchor_);
132
130 views::BoxLayout* layout = 133 views::BoxLayout* layout =
131 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); 134 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0);
132 layout->set_spread_blank_space(true); 135 layout->set_spread_blank_space(true);
133 SetLayoutManager(layout); 136 SetLayoutManager(layout);
134 137
135 // This background is re-used and the color is changed in |SetNotification()|. 138 // This background is re-used and the color is changed in |SetNotification()|.
136 label_->set_background( 139 label_->set_background(
137 views::Background::CreateSolidBackground(SK_ColorTRANSPARENT)); 140 views::Background::CreateSolidBackground(SK_ColorTRANSPARENT));
138 label_->set_border(views::Border::CreateEmptyBorder(10, 10, 10, 10)); 141 label_->set_border(views::Border::CreateEmptyBorder(10, 10, 10, 10));
139 label_->set_collapse_when_hidden(true); 142 label_->set_collapse_when_hidden(true);
(...skipping 26 matching lines...) Expand all
166 std::string AutofillDialogViews::NotificationArea::GetClassName() const { 169 std::string AutofillDialogViews::NotificationArea::GetClassName() const {
167 return kNotificationAreaClassName; 170 return kNotificationAreaClassName;
168 } 171 }
169 172
170 void AutofillDialogViews::NotificationArea::OnPaint(gfx::Canvas* canvas) { 173 void AutofillDialogViews::NotificationArea::OnPaint(gfx::Canvas* canvas) {
171 views::View::OnPaint(canvas); 174 views::View::OnPaint(canvas);
172 175
173 if (notification_.HasArrow()) { 176 if (notification_.HasArrow()) {
174 // Not using GetMirroredXWithWidthInView() here because the code would still 177 // Not using GetMirroredXWithWidthInView() here because the code would still
175 // need to subtract the width of the arrow from the result in RTL. 178 // need to subtract the width of the arrow from the result in RTL.
176 const int start_x = base::i18n::IsRTL() ? kArrowEndOffset : 179 const int half_arrow = kArrowWidth / 2.0f;
177 width() - kArrowEndOffset - kArrowWidth; 180 const int arrow_middle = GetMirroredXInView(
181 width() - arrow_centering_anchor_->width() / 2.0f - half_arrow);
182 // 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.
183 // so this arrow is pointing at the wrong thing. Blame estade@.
Evan Stade 2013/02/07 06:13:21 s/blame/thank
184
178 SkPath arrow; 185 SkPath arrow;
179 arrow.moveTo(start_x, kArrowHeight); 186 arrow.moveTo(arrow_middle - half_arrow, kArrowHeight);
180 arrow.lineTo(start_x + kArrowWidth, kArrowHeight); 187 arrow.lineTo(arrow_middle + half_arrow, kArrowHeight);
181 arrow.lineTo(start_x + kArrowWidth / 2.0f, 0); 188 arrow.lineTo(arrow_middle, 0);
182 arrow.close(); 189 arrow.close();
183 canvas->ClipPath(arrow); 190 canvas->ClipPath(arrow);
184 canvas->DrawColor(notification_.GetBackgroundColor()); 191 canvas->DrawColor(notification_.GetBackgroundColor());
185 } 192 }
186 } 193 }
187 194
188 // AutofillDialogViews::SectionContainer --------------------------------------- 195 // AutofillDialogViews::SectionContainer ---------------------------------------
189 196
190 AutofillDialogViews::SectionContainer::SectionContainer( 197 AutofillDialogViews::SectionContainer::SectionContainer(
191 const string16& label, 198 const string16& label,
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 346
340 // AutofillDialogViews --------------------------------------------------------- 347 // AutofillDialogViews ---------------------------------------------------------
341 348
342 AutofillDialogViews::AutofillDialogViews(AutofillDialogController* controller) 349 AutofillDialogViews::AutofillDialogViews(AutofillDialogController* controller)
343 : controller_(controller), 350 : controller_(controller),
344 did_submit_(false), 351 did_submit_(false),
345 window_(NULL), 352 window_(NULL),
346 contents_(NULL), 353 contents_(NULL),
347 notification_area_(NULL), 354 notification_area_(NULL),
348 use_billing_for_shipping_(NULL), 355 use_billing_for_shipping_(NULL),
349 sign_in_link_(NULL), 356 account_chooser_link_(NULL),
350 sign_in_container_(NULL), 357 sign_in_container_(NULL),
351 cancel_sign_in_(NULL), 358 cancel_sign_in_(NULL),
352 sign_in_webview_(NULL), 359 sign_in_webview_(NULL),
353 main_container_(NULL), 360 main_container_(NULL),
354 button_strip_extra_view_(NULL), 361 button_strip_extra_view_(NULL),
355 save_in_chrome_checkbox_(NULL), 362 save_in_chrome_checkbox_(NULL),
356 autocheckout_progress_bar_view_(NULL), 363 autocheckout_progress_bar_view_(NULL),
357 autocheckout_progress_bar_(NULL), 364 autocheckout_progress_bar_(NULL),
358 focus_manager_(NULL) { 365 focus_manager_(NULL) {
359 DCHECK(controller); 366 DCHECK(controller);
(...skipping 23 matching lines...) Expand all
383 focus_manager_ = window_->GetFocusManager(); 390 focus_manager_ = window_->GetFocusManager();
384 focus_manager_->AddFocusChangeListener(this); 391 focus_manager_->AddFocusChangeListener(this);
385 } 392 }
386 393
387 void AutofillDialogViews::Hide() { 394 void AutofillDialogViews::Hide() {
388 if (window_) 395 if (window_)
389 window_->CloseWebContentsModalDialog(); 396 window_->CloseWebContentsModalDialog();
390 } 397 }
391 398
392 void AutofillDialogViews::UpdateAccountChooser() { 399 void AutofillDialogViews::UpdateAccountChooser() {
393 DialogSignedInState state = controller_->SignedInState(); 400 // TODO(dbeam): show/hide account chooser combobox when it exists?
394 sign_in_link_->SetEnabled(state != REQUIRES_RESPONSE); 401 // TODO(dbeam): show/hide fancy Google Wallet logo when it exists.
395 sign_in_link_->SetVisible(state != SIGNED_IN); 402 account_chooser_link_->SetText(controller_->AccountChooserText());
403 account_chooser_link_->SetEnabled(controller_->AccountChooserEnabled());
396 } 404 }
397 405
398 void AutofillDialogViews::UpdateNotificationArea() { 406 void AutofillDialogViews::UpdateNotificationArea() {
399 DCHECK(notification_area_); 407 DCHECK(notification_area_);
400 notification_area_->SetNotification(controller_->CurrentNotification()); 408 notification_area_->SetNotification(controller_->CurrentNotification());
401 409
402 if (GetWidget()) 410 if (GetWidget())
403 GetWidget()->SetSize(GetWidget()->non_client_view()->GetPreferredSize()); 411 GetWidget()->SetSize(GetWidget()->non_client_view()->GetPreferredSize());
404 412
405 contents_->Layout(); 413 contents_->Layout();
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 views::View* focused_now) { 584 views::View* focused_now) {
577 controller_->FocusMoved(); 585 controller_->FocusMoved();
578 } 586 }
579 587
580 void AutofillDialogViews::OnDidChangeFocus( 588 void AutofillDialogViews::OnDidChangeFocus(
581 views::View* focused_before, 589 views::View* focused_before,
582 views::View* focused_now) {} 590 views::View* focused_now) {}
583 591
584 void AutofillDialogViews::LinkClicked(views::Link* source, int event_flags) { 592 void AutofillDialogViews::LinkClicked(views::Link* source, int event_flags) {
585 // Sign in link. 593 // Sign in link.
586 if (source == sign_in_link_) { 594 if (source == account_chooser_link_) {
587 controller_->StartSignInFlow(); 595 if (controller_->SignedInState() != SIGNED_IN) {
596 DCHECK(controller_->CanPayWithWallet());
597 controller_->StartSignInFlow();
598 }
599 // TODO(dbeam): handle other clicks on the account chooser (i.e. combobox).
588 return; 600 return;
589 } 601 }
590 602
591 // Edit links. 603 // Edit links.
592 for (DetailGroupMap::iterator iter = detail_groups_.begin(); 604 for (DetailGroupMap::iterator iter = detail_groups_.begin();
593 iter != detail_groups_.end(); ++iter) { 605 iter != detail_groups_.end(); ++iter) {
594 if (iter->second.suggested_info->Contains(source)) { 606 if (iter->second.suggested_info->Contains(source)) {
595 controller_->EditClickedForSection(iter->first); 607 controller_->EditClickedForSection(iter->first);
596 return; 608 return;
597 } 609 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 column_set->AddColumn(views::GridLayout::FILL, 665 column_set->AddColumn(views::GridLayout::FILL,
654 views::GridLayout::FILL, 666 views::GridLayout::FILL,
655 1, 667 1,
656 views::GridLayout::USE_PREF, 668 views::GridLayout::USE_PREF,
657 0, 669 0,
658 0); 670 0);
659 671
660 layout->StartRow(0, single_column_set); 672 layout->StartRow(0, single_column_set);
661 // TODO(abodenha) Create a chooser control to allow account selection. 673 // TODO(abodenha) Create a chooser control to allow account selection.
662 // See http://crbug.com/169858 674 // See http://crbug.com/169858
663 sign_in_link_ = new views::Link(controller_->SignInText()); 675 account_chooser_link_ = new views::Link();
664 sign_in_link_->SetHorizontalAlignment(gfx::ALIGN_RIGHT); 676 account_chooser_link_->SetHorizontalAlignment(gfx::ALIGN_RIGHT);
665 sign_in_link_->set_listener(this); 677 account_chooser_link_->set_listener(this);
666 layout->AddView(sign_in_link_); 678 layout->AddView(account_chooser_link_);
667 679
668 layout->StartRow(0, single_column_set); 680 layout->StartRowWithPadding(0, single_column_set,
669 notification_area_ = new NotificationArea(); 681 0, views::kRelatedControlVerticalSpacing);
682 notification_area_ = new NotificationArea(account_chooser_link_);
670 layout->AddView(notification_area_); 683 layout->AddView(notification_area_);
671 684
672 layout->StartRowWithPadding(0, single_column_set, 685 layout->StartRowWithPadding(0, single_column_set,
673 0, views::kUnrelatedControlVerticalSpacing); 686 0, views::kUnrelatedControlVerticalSpacing);
674 layout->AddView(CreateDetailsContainer()); 687 layout->AddView(CreateDetailsContainer());
675 return main_container_; 688 return main_container_;
676 } 689 }
677 690
678 views::View* AutofillDialogViews::CreateDetailsContainer() { 691 views::View* AutofillDialogViews::CreateDetailsContainer() {
679 views::View* view = new views::View(); 692 views::View* view = new views::View();
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) 949 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section)
937 : section(section), 950 : section(section),
938 container(NULL), 951 container(NULL),
939 manual_input(NULL), 952 manual_input(NULL),
940 suggested_info(NULL), 953 suggested_info(NULL),
941 suggested_button(NULL) {} 954 suggested_button(NULL) {}
942 955
943 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} 956 AutofillDialogViews::DetailsGroup::~DetailsGroup() {}
944 957
945 } // namespace autofill 958 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698