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

Side by Side Diff: chrome/browser/ui/views/autofill/autofill_dialog_views.cc

Issue 12225095: Interactive autofill: Adds footnote view to accept legal documents in the UI. (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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 icon_->SetImage(image.AsImageSkia()); 325 icon_->SetImage(image.AsImageSkia());
326 } 326 }
327 327
328 void AutofillDialogViews::SuggestionView::ShowTextfield( 328 void AutofillDialogViews::SuggestionView::ShowTextfield(
329 const string16& placeholder_text) { 329 const string16& placeholder_text) {
330 decorated_->textfield()->set_placeholder_text(placeholder_text); 330 decorated_->textfield()->set_placeholder_text(placeholder_text);
331 decorated_->SetVisible(true); 331 decorated_->SetVisible(true);
332 } 332 }
333 333
334 // AutofilDialogViews::AutocheckoutProgressBar --------------------------------- 334 // AutofilDialogViews::AutocheckoutProgressBar ---------------------------------
335
335 AutofillDialogViews::AutocheckoutProgressBar::AutocheckoutProgressBar() {} 336 AutofillDialogViews::AutocheckoutProgressBar::AutocheckoutProgressBar() {}
336 337
337 gfx::Size AutofillDialogViews::AutocheckoutProgressBar::GetPreferredSize() { 338 gfx::Size AutofillDialogViews::AutocheckoutProgressBar::GetPreferredSize() {
338 return gfx::Size(kAutocheckoutProgressBarWidth, 339 return gfx::Size(kAutocheckoutProgressBarWidth,
339 kAutocheckoutProgressBarHeight); 340 kAutocheckoutProgressBarHeight);
340 } 341 }
341 342
342 // AutofillDialogView ---------------------------------------------------------- 343 // AutofillDialogView ----------------------------------------------------------
343 344
344 // static 345 // static
(...skipping 13 matching lines...) Expand all
358 use_billing_for_shipping_(NULL), 359 use_billing_for_shipping_(NULL),
359 sign_in_link_(NULL), 360 sign_in_link_(NULL),
360 sign_in_container_(NULL), 361 sign_in_container_(NULL),
361 cancel_sign_in_(NULL), 362 cancel_sign_in_(NULL),
362 sign_in_webview_(NULL), 363 sign_in_webview_(NULL),
363 main_container_(NULL), 364 main_container_(NULL),
364 button_strip_extra_view_(NULL), 365 button_strip_extra_view_(NULL),
365 save_in_chrome_checkbox_(NULL), 366 save_in_chrome_checkbox_(NULL),
366 autocheckout_progress_bar_view_(NULL), 367 autocheckout_progress_bar_view_(NULL),
367 autocheckout_progress_bar_(NULL), 368 autocheckout_progress_bar_(NULL),
369 footnote_view_(NULL),
370 terms_of_service_link_(NULL),
371 privacy_policy_link_(NULL),
368 focus_manager_(NULL) { 372 focus_manager_(NULL) {
369 DCHECK(controller); 373 DCHECK(controller);
370 detail_groups_.insert(std::make_pair(SECTION_EMAIL, 374 detail_groups_.insert(std::make_pair(SECTION_EMAIL,
371 DetailsGroup(SECTION_EMAIL))); 375 DetailsGroup(SECTION_EMAIL)));
372 detail_groups_.insert(std::make_pair(SECTION_CC, 376 detail_groups_.insert(std::make_pair(SECTION_CC,
373 DetailsGroup(SECTION_CC))); 377 DetailsGroup(SECTION_CC)));
374 detail_groups_.insert(std::make_pair(SECTION_BILLING, 378 detail_groups_.insert(std::make_pair(SECTION_BILLING,
375 DetailsGroup(SECTION_BILLING))); 379 DetailsGroup(SECTION_BILLING)));
376 detail_groups_.insert(std::make_pair(SECTION_SHIPPING, 380 detail_groups_.insert(std::make_pair(SECTION_SHIPPING,
377 DetailsGroup(SECTION_SHIPPING))); 381 DetailsGroup(SECTION_SHIPPING)));
378 } 382 }
379 383
380 AutofillDialogViews::~AutofillDialogViews() { 384 AutofillDialogViews::~AutofillDialogViews() {
381 DCHECK(!window_); 385 DCHECK(!window_);
382 } 386 }
383 387
384 void AutofillDialogViews::Show() { 388 void AutofillDialogViews::Show() {
385 InitChildViews(); 389 InitChildViews();
386 UpdateAccountChooser(); 390 UpdateAccountChooser();
387 UpdateNotificationArea(); 391 UpdateNotificationArea();
392 UpdateFootnote();
388 393
389 // Ownership of |contents_| is handed off by this call. The 394 // Ownership of |contents_| is handed off by this call. The
390 // WebContentsModalDialog will take care of deleting itself after calling 395 // WebContentsModalDialog will take care of deleting itself after calling
391 // DeleteDelegate(). 396 // DeleteDelegate().
392 window_ = ConstrainedWindowViews::Create(controller_->web_contents(), this); 397 window_ = ConstrainedWindowViews::Create(controller_->web_contents(), this);
393 focus_manager_ = window_->GetFocusManager(); 398 focus_manager_ = window_->GetFocusManager();
394 focus_manager_->AddFocusChangeListener(this); 399 focus_manager_->AddFocusChangeListener(this);
395 } 400 }
396 401
397 void AutofillDialogViews::Hide() { 402 void AutofillDialogViews::Hide() {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 477
473 void AutofillDialogViews::HideSignIn() { 478 void AutofillDialogViews::HideSignIn() {
474 sign_in_container_->SetVisible(false); 479 sign_in_container_->SetVisible(false);
475 main_container_->SetVisible(true); 480 main_container_->SetVisible(true);
476 } 481 }
477 482
478 void AutofillDialogViews::UpdateProgressBar(double value) { 483 void AutofillDialogViews::UpdateProgressBar(double value) {
479 autocheckout_progress_bar_->SetValue(value); 484 autocheckout_progress_bar_->SetValue(value);
480 } 485 }
481 486
487 void AutofillDialogViews::UpdateFootnote() {
488 footnote_view_->SetVisible(controller_->IsFootnoteShowing());
489 footnote_view_->SetSize(
Evan Stade 2013/02/08 15:38:53 You shouldn't have to explicitly set the size.
Dan Beam 2013/02/08 20:53:06 I did when I wanted to make this wrap, otherwise i
490 gfx::Size(contents_->width(), footnote_view_->height()));
491
492 if (GetWidget())
493 GetWidget()->SetSize(GetWidget()->non_client_view()->GetPreferredSize());
494
495 contents_->Layout();
496 }
497
482 string16 AutofillDialogViews::GetWindowTitle() const { 498 string16 AutofillDialogViews::GetWindowTitle() const {
483 return controller_->DialogTitle(); 499 return controller_->DialogTitle();
484 } 500 }
485 501
486 void AutofillDialogViews::WindowClosing() { 502 void AutofillDialogViews::WindowClosing() {
487 focus_manager_->RemoveFocusChangeListener(this); 503 focus_manager_->RemoveFocusChangeListener(this);
488 } 504 }
489 505
490 void AutofillDialogViews::DeleteDelegate() { 506 void AutofillDialogViews::DeleteDelegate() {
491 window_ = NULL; 507 window_ = NULL;
(...skipping 21 matching lines...) Expand all
513 529
514 bool AutofillDialogViews::IsDialogButtonEnabled(ui::DialogButton button) const { 530 bool AutofillDialogViews::IsDialogButtonEnabled(ui::DialogButton button) const {
515 return true; 531 return true;
516 } 532 }
517 533
518 views::View* AutofillDialogViews::GetExtraView() { 534 views::View* AutofillDialogViews::GetExtraView() {
519 return button_strip_extra_view_; 535 return button_strip_extra_view_;
520 } 536 }
521 537
522 views::View* AutofillDialogViews::GetFootnoteView() { 538 views::View* AutofillDialogViews::GetFootnoteView() {
523 // TODO(estade): add a view to contain the terms of service. 539 return footnote_view_;
524 return NULL;
525 } 540 }
526 541
527 bool AutofillDialogViews::Cancel() { 542 bool AutofillDialogViews::Cancel() {
528 return true; 543 return true;
529 } 544 }
530 545
531 bool AutofillDialogViews::Accept() { 546 bool AutofillDialogViews::Accept() {
532 if (!ValidateForm()) 547 if (!ValidateForm())
533 return false; 548 return false;
534 549
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 views::View* focused_before, 610 views::View* focused_before,
596 views::View* focused_now) { 611 views::View* focused_now) {
597 controller_->FocusMoved(); 612 controller_->FocusMoved();
598 } 613 }
599 614
600 void AutofillDialogViews::OnDidChangeFocus( 615 void AutofillDialogViews::OnDidChangeFocus(
601 views::View* focused_before, 616 views::View* focused_before,
602 views::View* focused_now) {} 617 views::View* focused_now) {}
603 618
604 void AutofillDialogViews::LinkClicked(views::Link* source, int event_flags) { 619 void AutofillDialogViews::LinkClicked(views::Link* source, int event_flags) {
605 // Sign in link.
606 if (source == sign_in_link_) { 620 if (source == sign_in_link_) {
607 controller_->StartSignInFlow(); 621 controller_->StartSignInFlow();
608 return; 622 } else if (source == terms_of_service_link_) {
609 } 623 controller_->ShowTermsOfService();
610 624 } else if (source == privacy_policy_link_) {
611 // Edit links. 625 controller_->ShowPrivacyPolicy();
612 for (DetailGroupMap::iterator iter = detail_groups_.begin(); 626 } else {
613 iter != detail_groups_.end(); ++iter) { 627 // Edit links.
614 if (iter->second.suggested_info->Contains(source)) { 628 for (DetailGroupMap::iterator iter = detail_groups_.begin();
615 controller_->EditClickedForSection(iter->first); 629 iter != detail_groups_.end(); ++iter) {
616 return; 630 if (iter->second.suggested_info->Contains(source)) {
631 controller_->EditClickedForSection(iter->first);
632 return;
633 }
617 } 634 }
618 } 635 }
619 } 636 }
620 637
621 void AutofillDialogViews::InitChildViews() { 638 void AutofillDialogViews::InitChildViews() {
622 button_strip_extra_view_ = new views::View(); 639 button_strip_extra_view_ = new views::View();
623 button_strip_extra_view_->SetLayoutManager( 640 button_strip_extra_view_->SetLayoutManager(
624 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); 641 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0));
625 642
626 save_in_chrome_checkbox_ = 643 save_in_chrome_checkbox_ =
(...skipping 13 matching lines...) Expand all
640 autocheckout_progress_bar_ = new AutocheckoutProgressBar(); 657 autocheckout_progress_bar_ = new AutocheckoutProgressBar();
641 autocheckout_progress_bar_view_->AddChildView(autocheckout_progress_bar_); 658 autocheckout_progress_bar_view_->AddChildView(autocheckout_progress_bar_);
642 659
643 button_strip_extra_view_->AddChildView(autocheckout_progress_bar_view_); 660 button_strip_extra_view_->AddChildView(autocheckout_progress_bar_view_);
644 661
645 contents_ = new views::View(); 662 contents_ = new views::View();
646 contents_->SetLayoutManager( 663 contents_->SetLayoutManager(
647 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); 664 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0));
648 contents_->AddChildView(CreateMainContainer()); 665 contents_->AddChildView(CreateMainContainer());
649 contents_->AddChildView(CreateSignInContainer()); 666 contents_->AddChildView(CreateSignInContainer());
667
668 footnote_view_ = new views::View();
Evan Stade 2013/02/08 15:38:53 Can you pull this new code into a separate functio
Dan Beam 2013/02/08 20:53:06 Done.
669 footnote_view_->set_border(views::Border::CreateEmptyBorder(
670 views::kUnrelatedControlVerticalSpacing, 0, 0, 0));
671
672 views::BoxLayout* box_layout =
673 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0);
674 box_layout->set_spread_blank_space(true);
675 footnote_view_->SetLayoutManager(box_layout);
676
677 // TODO(dbeam): pull out hardcoded colors / theme?
678 views::View* footnote_padding = new views::View();
679 footnote_padding->set_background(views::Background::CreateSolidBackground(
680 SkColorSetRGB(0xf3, 0xf3, 0xf4)));
681 footnote_padding->set_border(views::Border::CreateSolidSidedBorder(
682 1, 0, 0, 0, SkColorSetRGB(0xea, 0xea, 0xeb)));
683
684 footnote_view_->AddChildView(footnote_padding);
685
686 views::GridLayout* padding_layout = new views::GridLayout(footnote_padding);
687 footnote_padding->SetLayoutManager(padding_layout);
688
689 const std::pair<std::vector<string16>, string16>& footnote_parts =
690 controller_->FootnoteTextParts();
691
692 const int links_column_set = 1;
693 views::ColumnSet* column_set = padding_layout->AddColumnSet(links_column_set);
694
695 for (size_t i = 0; i < footnote_parts.first.size(); ++i) {
696 column_set->AddColumn(views::GridLayout::LEADING,
697 views::GridLayout::FILL,
698 1,
699 views::GridLayout::USE_PREF,
700 0,
701 0);
702 }
703
704 column_set->AddColumn(views::GridLayout::FILL,
705 views::GridLayout::FILL,
706 1,
707 views::GridLayout::USE_PREF,
708 0,
709 0);
710
711 // Padding between border and slew of labels/links.
712 padding_layout->StartRowWithPadding(
713 0, links_column_set, 0, views::kUnrelatedControlVerticalSpacing);
714
715 // ""
716 padding_layout->AddView(new views::Label(footnote_parts.first[0]));
717
718 // "Google Wallet Terms of Service" (link).
719 terms_of_service_link_ = new views::Link(footnote_parts.first[1]);
720 terms_of_service_link_->set_listener(this);
721 padding_layout->AddView(terms_of_service_link_);
722
723 // " and ".
724 padding_layout->AddView(new views::Label(footnote_parts.first[2]));
725
726 // "Privacy Policy" (link).
727 privacy_policy_link_ = new views::Link(footnote_parts.first[3]);
728 privacy_policy_link_->set_listener(this);
729 padding_layout->AddView(privacy_policy_link_);
730
731 // " have been updated.".
732 padding_layout->AddView(new views::Label(footnote_parts.first[4]));
733
734 // TODO(dbeam): make this padding column work.
Evan Stade 2013/02/08 15:38:53 Please fix this instead of leaving a todo
Dan Beam 2013/02/08 20:53:06 Done. (that sucked)
735 padding_layout->SkipColumns(1);
736
737 const int full_width = 2;
Evan Stade 2013/02/08 15:38:53 full_width_column_set
Dan Beam 2013/02/08 20:53:06 Done.
738 padding_layout->AddColumnSet(full_width)->AddColumn(
739 views::GridLayout::FILL,
740 views::GridLayout::FILL,
741 1,
742 views::GridLayout::USE_PREF,
743 0,
744 0);
745
746 // "By clicking submit you verify that you accept these changes.".
747 views::Label* accept_these_changes = new views::Label(footnote_parts.second);
748 accept_these_changes->SetHorizontalAlignment(gfx::ALIGN_LEFT);
749
750 padding_layout->StartRowWithPadding(
751 0, full_width, 0, views::kRelatedControlVerticalSpacing);
752 padding_layout->AddView(accept_these_changes);
753
754 padding_layout->StartRowWithPadding(
755 0, full_width, 0, views::kUnrelatedControlVerticalSpacing);
650 } 756 }
651 757
652 views::View* AutofillDialogViews::CreateSignInContainer() { 758 views::View* AutofillDialogViews::CreateSignInContainer() {
653 sign_in_container_ = new views::View(); 759 sign_in_container_ = new views::View();
654 sign_in_container_->SetLayoutManager( 760 sign_in_container_->SetLayoutManager(
655 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); 761 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
656 sign_in_container_->SetVisible(false); 762 sign_in_container_->SetVisible(false);
657 sign_in_webview_ = new views::WebView(controller_->profile()); 763 sign_in_webview_ = new views::WebView(controller_->profile());
658 cancel_sign_in_ = new views::TextButton(this, 764 cancel_sign_in_ = new views::TextButton(this,
659 controller_->CancelSignInText()); 765 controller_->CancelSignInText());
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) 1084 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section)
979 : section(section), 1085 : section(section),
980 container(NULL), 1086 container(NULL),
981 manual_input(NULL), 1087 manual_input(NULL),
982 suggested_info(NULL), 1088 suggested_info(NULL),
983 suggested_button(NULL) {} 1089 suggested_button(NULL) {}
984 1090
985 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} 1091 AutofillDialogViews::DetailsGroup::~DetailsGroup() {}
986 1092
987 } // namespace autofill 1093 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698