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

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: <=3 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
« no previous file with comments | « chrome/browser/ui/views/autofill/autofill_dialog_views.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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),
368 focus_manager_(NULL) { 370 focus_manager_(NULL) {
369 DCHECK(controller); 371 DCHECK(controller);
370 detail_groups_.insert(std::make_pair(SECTION_EMAIL, 372 detail_groups_.insert(std::make_pair(SECTION_EMAIL,
371 DetailsGroup(SECTION_EMAIL))); 373 DetailsGroup(SECTION_EMAIL)));
372 detail_groups_.insert(std::make_pair(SECTION_CC, 374 detail_groups_.insert(std::make_pair(SECTION_CC,
373 DetailsGroup(SECTION_CC))); 375 DetailsGroup(SECTION_CC)));
374 detail_groups_.insert(std::make_pair(SECTION_BILLING, 376 detail_groups_.insert(std::make_pair(SECTION_BILLING,
375 DetailsGroup(SECTION_BILLING))); 377 DetailsGroup(SECTION_BILLING)));
376 detail_groups_.insert(std::make_pair(SECTION_SHIPPING, 378 detail_groups_.insert(std::make_pair(SECTION_SHIPPING,
377 DetailsGroup(SECTION_SHIPPING))); 379 DetailsGroup(SECTION_SHIPPING)));
378 } 380 }
379 381
380 AutofillDialogViews::~AutofillDialogViews() { 382 AutofillDialogViews::~AutofillDialogViews() {
381 DCHECK(!window_); 383 DCHECK(!window_);
382 } 384 }
383 385
384 void AutofillDialogViews::Show() { 386 void AutofillDialogViews::Show() {
385 InitChildViews(); 387 InitChildViews();
386 UpdateAccountChooser(); 388 UpdateAccountChooser();
387 UpdateNotificationArea(); 389 UpdateNotificationArea();
390 UpdateFootnote();
388 391
389 // Ownership of |contents_| is handed off by this call. The 392 // Ownership of |contents_| is handed off by this call. The
390 // WebContentsModalDialog will take care of deleting itself after calling 393 // WebContentsModalDialog will take care of deleting itself after calling
391 // DeleteDelegate(). 394 // DeleteDelegate().
392 window_ = ConstrainedWindowViews::Create(controller_->web_contents(), this); 395 window_ = ConstrainedWindowViews::Create(controller_->web_contents(), this);
393 focus_manager_ = window_->GetFocusManager(); 396 focus_manager_ = window_->GetFocusManager();
394 focus_manager_->AddFocusChangeListener(this); 397 focus_manager_->AddFocusChangeListener(this);
395 } 398 }
396 399
397 void AutofillDialogViews::Hide() { 400 void AutofillDialogViews::Hide() {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 475
473 void AutofillDialogViews::HideSignIn() { 476 void AutofillDialogViews::HideSignIn() {
474 sign_in_container_->SetVisible(false); 477 sign_in_container_->SetVisible(false);
475 main_container_->SetVisible(true); 478 main_container_->SetVisible(true);
476 } 479 }
477 480
478 void AutofillDialogViews::UpdateProgressBar(double value) { 481 void AutofillDialogViews::UpdateProgressBar(double value) {
479 autocheckout_progress_bar_->SetValue(value); 482 autocheckout_progress_bar_->SetValue(value);
480 } 483 }
481 484
485 void AutofillDialogViews::UpdateFootnote() {
486 PopulateFootnoteLinks();
487
488 if (GetWidget())
489 GetWidget()->SetSize(GetWidget()->non_client_view()->GetPreferredSize());
490
491 contents_->Layout();
492 }
493
482 string16 AutofillDialogViews::GetWindowTitle() const { 494 string16 AutofillDialogViews::GetWindowTitle() const {
483 return controller_->DialogTitle(); 495 return controller_->DialogTitle();
484 } 496 }
485 497
486 void AutofillDialogViews::WindowClosing() { 498 void AutofillDialogViews::WindowClosing() {
487 focus_manager_->RemoveFocusChangeListener(this); 499 focus_manager_->RemoveFocusChangeListener(this);
488 } 500 }
489 501
490 void AutofillDialogViews::DeleteDelegate() { 502 void AutofillDialogViews::DeleteDelegate() {
491 window_ = NULL; 503 window_ = NULL;
(...skipping 21 matching lines...) Expand all
513 525
514 bool AutofillDialogViews::IsDialogButtonEnabled(ui::DialogButton button) const { 526 bool AutofillDialogViews::IsDialogButtonEnabled(ui::DialogButton button) const {
515 return true; 527 return true;
516 } 528 }
517 529
518 views::View* AutofillDialogViews::GetExtraView() { 530 views::View* AutofillDialogViews::GetExtraView() {
519 return button_strip_extra_view_; 531 return button_strip_extra_view_;
520 } 532 }
521 533
522 views::View* AutofillDialogViews::GetFootnoteView() { 534 views::View* AutofillDialogViews::GetFootnoteView() {
523 // TODO(estade): add a view to contain the terms of service. 535 return footnote_view_;
524 return NULL;
525 } 536 }
526 537
527 bool AutofillDialogViews::Cancel() { 538 bool AutofillDialogViews::Cancel() {
528 return true; 539 return true;
529 } 540 }
530 541
531 bool AutofillDialogViews::Accept() { 542 bool AutofillDialogViews::Accept() {
532 if (!ValidateForm()) 543 if (!ValidateForm())
533 return false; 544 return false;
534 545
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 views::View* focused_before, 606 views::View* focused_before,
596 views::View* focused_now) { 607 views::View* focused_now) {
597 controller_->FocusMoved(); 608 controller_->FocusMoved();
598 } 609 }
599 610
600 void AutofillDialogViews::OnDidChangeFocus( 611 void AutofillDialogViews::OnDidChangeFocus(
601 views::View* focused_before, 612 views::View* focused_before,
602 views::View* focused_now) {} 613 views::View* focused_now) {}
603 614
604 void AutofillDialogViews::LinkClicked(views::Link* source, int event_flags) { 615 void AutofillDialogViews::LinkClicked(views::Link* source, int event_flags) {
605 // Sign in link.
606 if (source == sign_in_link_) { 616 if (source == sign_in_link_) {
607 controller_->StartSignInFlow(); 617 controller_->StartSignInFlow();
608 return; 618 } else if (source->parent()->parent() == footnote_view_) {
609 } 619 const size_t link_index = (source->parent()->GetIndexOf(source) - 1) / 2;
610 620 controller_->LegalDocumentLinkClicked(link_index);
611 // Edit links. 621 } else {
612 for (DetailGroupMap::iterator iter = detail_groups_.begin(); 622 // Edit links.
613 iter != detail_groups_.end(); ++iter) { 623 for (DetailGroupMap::iterator iter = detail_groups_.begin();
614 if (iter->second.suggested_info->Contains(source)) { 624 iter != detail_groups_.end(); ++iter) {
615 controller_->EditClickedForSection(iter->first); 625 if (iter->second.suggested_info->Contains(source)) {
616 return; 626 controller_->EditClickedForSection(iter->first);
627 return;
628 }
617 } 629 }
618 } 630 }
619 } 631 }
620 632
621 void AutofillDialogViews::InitChildViews() { 633 void AutofillDialogViews::InitChildViews() {
622 button_strip_extra_view_ = new views::View(); 634 button_strip_extra_view_ = new views::View();
623 button_strip_extra_view_->SetLayoutManager( 635 button_strip_extra_view_->SetLayoutManager(
624 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); 636 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0));
625 637
626 save_in_chrome_checkbox_ = 638 save_in_chrome_checkbox_ =
(...skipping 13 matching lines...) Expand all
640 autocheckout_progress_bar_ = new AutocheckoutProgressBar(); 652 autocheckout_progress_bar_ = new AutocheckoutProgressBar();
641 autocheckout_progress_bar_view_->AddChildView(autocheckout_progress_bar_); 653 autocheckout_progress_bar_view_->AddChildView(autocheckout_progress_bar_);
642 654
643 button_strip_extra_view_->AddChildView(autocheckout_progress_bar_view_); 655 button_strip_extra_view_->AddChildView(autocheckout_progress_bar_view_);
644 656
645 contents_ = new views::View(); 657 contents_ = new views::View();
646 contents_->SetLayoutManager( 658 contents_->SetLayoutManager(
647 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); 659 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0));
648 contents_->AddChildView(CreateMainContainer()); 660 contents_->AddChildView(CreateMainContainer());
649 contents_->AddChildView(CreateSignInContainer()); 661 contents_->AddChildView(CreateSignInContainer());
650 }
651 662
652 views::View* AutofillDialogViews::CreateSignInContainer() { 663 // |foonote_view_| is added to View hierarchy by |GetFootnoteView()|.
653 sign_in_container_ = new views::View(); 664 footnote_view_ = new views::View();
654 sign_in_container_->SetLayoutManager( 665 views::BoxLayout* box_layout =
655 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); 666 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0);
656 sign_in_container_->SetVisible(false); 667 box_layout->set_spread_blank_space(true);
657 sign_in_webview_ = new views::WebView(controller_->profile()); 668 footnote_view_->SetLayoutManager(box_layout);
658 cancel_sign_in_ = new views::TextButton(this,
659 controller_->CancelSignInText());
660 sign_in_container_->AddChildView(cancel_sign_in_);
661 sign_in_container_->AddChildView(sign_in_webview_);
662 return sign_in_container_;
663 } 669 }
664 670
665 views::View* AutofillDialogViews::CreateMainContainer() { 671 views::View* AutofillDialogViews::CreateMainContainer() {
666 main_container_ = new views::View(); 672 main_container_ = new views::View();
667 views::GridLayout* layout = new views::GridLayout(main_container_); 673 views::GridLayout* layout = new views::GridLayout(main_container_);
668 main_container_->SetLayoutManager(layout); 674 main_container_->SetLayoutManager(layout);
669 675
670 const int single_column_set = 0; 676 const int single_column_set = 0;
671 views::ColumnSet* column_set = layout->AddColumnSet(single_column_set); 677 views::ColumnSet* column_set = layout->AddColumnSet(single_column_set);
672 column_set->AddColumn(views::GridLayout::FILL, 678 column_set->AddColumn(views::GridLayout::FILL,
(...skipping 14 matching lines...) Expand all
687 layout->StartRow(0, single_column_set); 693 layout->StartRow(0, single_column_set);
688 notification_area_ = new NotificationArea(); 694 notification_area_ = new NotificationArea();
689 layout->AddView(notification_area_); 695 layout->AddView(notification_area_);
690 696
691 layout->StartRowWithPadding(0, single_column_set, 697 layout->StartRowWithPadding(0, single_column_set,
692 0, views::kUnrelatedControlVerticalSpacing); 698 0, views::kUnrelatedControlVerticalSpacing);
693 layout->AddView(CreateDetailsContainer()); 699 layout->AddView(CreateDetailsContainer());
694 return main_container_; 700 return main_container_;
695 } 701 }
696 702
703 views::View* AutofillDialogViews::CreateSignInContainer() {
704 sign_in_container_ = new views::View();
705 sign_in_container_->SetLayoutManager(
706 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
707 sign_in_container_->SetVisible(false);
708 sign_in_webview_ = new views::WebView(controller_->profile());
709 cancel_sign_in_ = new views::TextButton(this,
710 controller_->CancelSignInText());
711 sign_in_container_->AddChildView(cancel_sign_in_);
712 sign_in_container_->AddChildView(sign_in_webview_);
713 return sign_in_container_;
714 }
715
716 void AutofillDialogViews::PopulateFootnoteLinks() {
717 const std::vector<string16>& link_parts = controller_->FootnoteLinkParts();
718 const bool has_links = !link_parts.empty();
719
720 footnote_view_->RemoveAllChildViews(true);
721 footnote_view_->SetVisible(has_links);
722 footnote_view_->set_border(views::Border::CreateEmptyBorder(
723 has_links ? views::kUnrelatedControlVerticalSpacing : 0, 0, 0, 0));
724
725 if (!has_links)
726 return;
727
728 // TODO(dbeam): pull out hardcoded colors / theme?
729 views::View* footnote_padding = new views::View();
730 footnote_padding->set_background(views::Background::CreateSolidBackground(
731 SkColorSetRGB(0xf3, 0xf3, 0xf4)));
732 footnote_padding->set_border(views::Border::CreateSolidSidedBorder(
733 1, 0, 0, 0, SkColorSetRGB(0xea, 0xea, 0xeb)));
734
735 footnote_view_->AddChildView(footnote_padding);
736
737 views::GridLayout* padding_layout = new views::GridLayout(footnote_padding);
738 footnote_padding->SetLayoutManager(padding_layout);
739
740 const int links_column_set = 1;
741 views::ColumnSet* column_set = padding_layout->AddColumnSet(links_column_set);
742
743 for (size_t i = 0; i < link_parts.size(); ++i) {
744 column_set->AddColumn(views::GridLayout::LEADING,
745 views::GridLayout::FILL,
746 0,
747 views::GridLayout::USE_PREF,
748 0,
749 0);
750 }
751
752 // Padding between border and slew of labels/links.
753 padding_layout->StartRowWithPadding(
754 0, links_column_set, 0, views::kUnrelatedControlVerticalSpacing);
755
756 for (size_t i = 0; i < link_parts.size(); ++i) {
757 if (i % 2 == 0) {
758 // Text between links.
759 views::Label* text = new views::Label(link_parts[i]);
760 text->SetHorizontalAlignment(gfx::ALIGN_LEFT);
Dan Beam 2013/02/09 00:27:57 not sure if this is necessary
761 padding_layout->AddView(text);
762 } else {
763 // Link to a legal document (i.e. Terms Of Service, Privacy Policy).
764 views::Link* link = new views::Link(link_parts[i]);
765 link->SetEnabledColor(SkColorSetRGB(0x64, 0x64, 0x64));
766 link->SetHorizontalAlignment(gfx::ALIGN_LEFT);
Dan Beam 2013/02/09 00:27:57 nor this
767 link->set_listener(this);
768 padding_layout->AddView(link);
769 }
770 }
771
772 const int full_width_column_set = 2;
773 padding_layout->AddColumnSet(full_width_column_set)->AddColumn(
774 views::GridLayout::FILL,
775 views::GridLayout::FILL,
776 1,
777 views::GridLayout::USE_PREF,
778 0,
779 0);
780
781 // Text after links explaining that by clicking you agree (i.e. "By clicking
782 // submit you verify that you accept these changes.").
783 views::Label* accept_these_changes =
784 new views::Label(controller_->AcceptChangesText());
785 accept_these_changes->SetHorizontalAlignment(gfx::ALIGN_LEFT);
786
787 padding_layout->StartRowWithPadding(
788 0, full_width_column_set, 0, views::kRelatedControlVerticalSpacing);
789 padding_layout->AddView(accept_these_changes);
790
791 padding_layout->StartRowWithPadding(
792 0, full_width_column_set, 0, views::kUnrelatedControlVerticalSpacing);
793 }
794
697 views::View* AutofillDialogViews::CreateDetailsContainer() { 795 views::View* AutofillDialogViews::CreateDetailsContainer() {
698 views::View* view = new views::View(); 796 views::View* view = new views::View();
699 // A box layout is used because it respects widget visibility. 797 // A box layout is used because it respects widget visibility.
700 view->SetLayoutManager( 798 view->SetLayoutManager(
701 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 799 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0,
702 views::kRelatedControlVerticalSpacing)); 800 views::kRelatedControlVerticalSpacing));
703 for (DetailGroupMap::iterator iter = detail_groups_.begin(); 801 for (DetailGroupMap::iterator iter = detail_groups_.begin();
704 iter != detail_groups_.end(); ++iter) { 802 iter != detail_groups_.end(); ++iter) {
705 CreateDetailsSection(iter->second.section); 803 CreateDetailsSection(iter->second.section);
706 view->AddChildView(iter->second.container); 804 view->AddChildView(iter->second.container);
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
978 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) 1076 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section)
979 : section(section), 1077 : section(section),
980 container(NULL), 1078 container(NULL),
981 manual_input(NULL), 1079 manual_input(NULL),
982 suggested_info(NULL), 1080 suggested_info(NULL),
983 suggested_button(NULL) {} 1081 suggested_button(NULL) {}
984 1082
985 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} 1083 AutofillDialogViews::DetailsGroup::~DetailsGroup() {}
986 1084
987 } // namespace autofill 1085 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/autofill/autofill_dialog_views.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698