| 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 c4786fbe95711f1c4cb9145e9b10f4d9c593cd8b..8249fc57f5cdcd2c58491ba404a373b7a4716d53 100644
|
| --- a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc
|
| +++ b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc
|
| @@ -332,6 +332,7 @@ void AutofillDialogViews::SuggestionView::ShowTextfield(
|
| }
|
|
|
| // AutofilDialogViews::AutocheckoutProgressBar ---------------------------------
|
| +
|
| AutofillDialogViews::AutocheckoutProgressBar::AutocheckoutProgressBar() {}
|
|
|
| gfx::Size AutofillDialogViews::AutocheckoutProgressBar::GetPreferredSize() {
|
| @@ -365,6 +366,7 @@ AutofillDialogViews::AutofillDialogViews(AutofillDialogController* controller)
|
| save_in_chrome_checkbox_(NULL),
|
| autocheckout_progress_bar_view_(NULL),
|
| autocheckout_progress_bar_(NULL),
|
| + footnote_view_(NULL),
|
| focus_manager_(NULL) {
|
| DCHECK(controller);
|
| detail_groups_.insert(std::make_pair(SECTION_EMAIL,
|
| @@ -385,6 +387,7 @@ void AutofillDialogViews::Show() {
|
| InitChildViews();
|
| UpdateAccountChooser();
|
| UpdateNotificationArea();
|
| + UpdateFootnote();
|
|
|
| // Ownership of |contents_| is handed off by this call. The
|
| // WebContentsModalDialog will take care of deleting itself after calling
|
| @@ -408,11 +411,7 @@ void AutofillDialogViews::UpdateAccountChooser() {
|
| void AutofillDialogViews::UpdateNotificationArea() {
|
| DCHECK(notification_area_);
|
| notification_area_->SetNotification(controller_->CurrentNotification());
|
| -
|
| - if (GetWidget())
|
| - GetWidget()->SetSize(GetWidget()->non_client_view()->GetPreferredSize());
|
| -
|
| - contents_->Layout();
|
| + ContentsResized();
|
| }
|
|
|
| void AutofillDialogViews::UpdateSection(DialogSection section) {
|
| @@ -479,6 +478,11 @@ void AutofillDialogViews::UpdateProgressBar(double value) {
|
| autocheckout_progress_bar_->SetValue(value);
|
| }
|
|
|
| +void AutofillDialogViews::UpdateFootnote() {
|
| + PopulateFootnoteLinks();
|
| + ContentsResized();
|
| +}
|
| +
|
| string16 AutofillDialogViews::GetWindowTitle() const {
|
| return controller_->DialogTitle();
|
| }
|
| @@ -520,8 +524,7 @@ views::View* AutofillDialogViews::GetExtraView() {
|
| }
|
|
|
| views::View* AutofillDialogViews::GetFootnoteView() {
|
| - // TODO(estade): add a view to contain the terms of service.
|
| - return NULL;
|
| + return footnote_view_;
|
| }
|
|
|
| bool AutofillDialogViews::Cancel() {
|
| @@ -602,18 +605,19 @@ void AutofillDialogViews::OnDidChangeFocus(
|
| views::View* focused_now) {}
|
|
|
| void AutofillDialogViews::LinkClicked(views::Link* source, int event_flags) {
|
| - // Sign in link.
|
| if (source == sign_in_link_) {
|
| controller_->StartSignInFlow();
|
| - return;
|
| - }
|
| -
|
| - // Edit links.
|
| - for (DetailGroupMap::iterator iter = detail_groups_.begin();
|
| - iter != detail_groups_.end(); ++iter) {
|
| - if (iter->second.suggested_info->Contains(source)) {
|
| - controller_->EditClickedForSection(iter->first);
|
| - return;
|
| + } else if (footnote_view_->Contains(source)) {
|
| + const size_t link_index = (source->parent()->GetIndexOf(source) - 1) / 2;
|
| + controller_->LegalDocumentLinkClicked(link_index);
|
| + } else {
|
| + // Edit links.
|
| + for (DetailGroupMap::iterator iter = detail_groups_.begin();
|
| + iter != detail_groups_.end(); ++iter) {
|
| + if (iter->second.suggested_info->Contains(source)) {
|
| + controller_->EditClickedForSection(iter->first);
|
| + return;
|
| + }
|
| }
|
| }
|
| }
|
| @@ -647,19 +651,15 @@ void AutofillDialogViews::InitChildViews() {
|
| new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0));
|
| contents_->AddChildView(CreateMainContainer());
|
| contents_->AddChildView(CreateSignInContainer());
|
| -}
|
|
|
| -views::View* AutofillDialogViews::CreateSignInContainer() {
|
| - sign_in_container_ = new views::View();
|
| - sign_in_container_->SetLayoutManager(
|
| - new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
|
| - sign_in_container_->SetVisible(false);
|
| - sign_in_webview_ = new views::WebView(controller_->profile());
|
| - cancel_sign_in_ = new views::TextButton(this,
|
| - controller_->CancelSignInText());
|
| - sign_in_container_->AddChildView(cancel_sign_in_);
|
| - sign_in_container_->AddChildView(sign_in_webview_);
|
| - return sign_in_container_;
|
| + // |foonote_view_| is added to View hierarchy by |GetFootnoteView()|.
|
| + footnote_view_ = new views::View();
|
| + footnote_view_->set_border(views::Border::CreateEmptyBorder(
|
| + views::kUnrelatedControlVerticalSpacing, 0, 0, 0));
|
| + views::BoxLayout* box_layout =
|
| + new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0);
|
| + box_layout->set_spread_blank_space(true);
|
| + footnote_view_->SetLayoutManager(box_layout);
|
| }
|
|
|
| views::View* AutofillDialogViews::CreateMainContainer() {
|
| @@ -694,6 +694,89 @@ views::View* AutofillDialogViews::CreateMainContainer() {
|
| return main_container_;
|
| }
|
|
|
| +views::View* AutofillDialogViews::CreateSignInContainer() {
|
| + sign_in_container_ = new views::View();
|
| + sign_in_container_->SetLayoutManager(
|
| + new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
|
| + sign_in_container_->SetVisible(false);
|
| + sign_in_webview_ = new views::WebView(controller_->profile());
|
| + cancel_sign_in_ = new views::TextButton(this,
|
| + controller_->CancelSignInText());
|
| + sign_in_container_->AddChildView(cancel_sign_in_);
|
| + sign_in_container_->AddChildView(sign_in_webview_);
|
| + return sign_in_container_;
|
| +}
|
| +
|
| +void AutofillDialogViews::PopulateFootnoteLinks() {
|
| + const std::vector<string16>& link_parts = controller_->FootnoteLinkParts();
|
| +
|
| + const bool has_links = !link_parts.empty();
|
| + footnote_view_->SetVisible(has_links);
|
| + if (!has_links)
|
| + return;
|
| +
|
| + footnote_view_->RemoveAllChildViews(true);
|
| +
|
| + // TODO(dbeam): pull out hardcoded colors / theme?
|
| + views::View* footnote_padding = new views::View();
|
| + footnote_padding->set_background(views::Background::CreateSolidBackground(
|
| + SkColorSetRGB(0xf3, 0xf3, 0xf4)));
|
| + footnote_padding->set_border(views::Border::CreateSolidSidedBorder(
|
| + 1, 0, 0, 0, SkColorSetRGB(0xea, 0xea, 0xeb)));
|
| +
|
| + footnote_view_->AddChildView(footnote_padding);
|
| +
|
| + views::GridLayout* padding_layout = new views::GridLayout(footnote_padding);
|
| + footnote_padding->SetLayoutManager(padding_layout);
|
| +
|
| + const int links_column_set = 1;
|
| + views::ColumnSet* column_set = padding_layout->AddColumnSet(links_column_set);
|
| +
|
| + for (size_t i = 0; i < link_parts.size(); ++i) {
|
| + column_set->AddColumn(views::GridLayout::LEADING,
|
| + views::GridLayout::FILL,
|
| + 0,
|
| + views::GridLayout::USE_PREF,
|
| + 0,
|
| + 0);
|
| + }
|
| +
|
| + // Padding between border and slew of labels/links.
|
| + padding_layout->StartRowWithPadding(
|
| + 0, links_column_set, 0, views::kUnrelatedControlVerticalSpacing);
|
| +
|
| + for (size_t i = 0; i < link_parts.size(); ++i) {
|
| + if (i % 2 == 0) {
|
| + // Text between links.
|
| + padding_layout->AddView(new views::Label(link_parts[i]));
|
| + } else {
|
| + // Link to a legal document (i.e. Terms Of Service, Privacy Policy).
|
| + views::Link* link = new views::Link(link_parts[i]);
|
| + link->SetEnabledColor(SkColorSetRGB(0x64, 0x64, 0x64));
|
| + link->set_listener(this);
|
| + padding_layout->AddView(link);
|
| + }
|
| + }
|
| +
|
| + const int full_width_column_set = 2;
|
| + padding_layout->AddColumnSet(full_width_column_set)->AddColumn(
|
| + views::GridLayout::LEADING,
|
| + views::GridLayout::FILL,
|
| + 1,
|
| + views::GridLayout::USE_PREF,
|
| + 0,
|
| + 0);
|
| +
|
| + // Text after links explaining that by clicking you agree (i.e. "By clicking
|
| + // submit you verify that you accept these changes.").
|
| + padding_layout->StartRowWithPadding(
|
| + 0, full_width_column_set, 0, views::kRelatedControlVerticalSpacing);
|
| + padding_layout->AddView(
|
| + new views::Label(controller_->AcceptFootnoteLinksText()));
|
| +
|
| + padding_layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing);
|
| +}
|
| +
|
| views::View* AutofillDialogViews::CreateDetailsContainer() {
|
| views::View* view = new views::View();
|
| // A box layout is used because it respects widget visibility.
|
| @@ -881,8 +964,7 @@ void AutofillDialogViews::UpdateDetailsGroupState(const DetailsGroup& group) {
|
| if (group.container)
|
| group.container->SetForwardMouseEvents(show_suggestions);
|
|
|
| - if (GetWidget())
|
| - GetWidget()->SetSize(GetWidget()->non_client_view()->GetPreferredSize());
|
| + ContentsResized();
|
| }
|
|
|
| bool AutofillDialogViews::AtLeastOneSectionIsEditing() {
|
| @@ -970,6 +1052,11 @@ void AutofillDialogViews::TextfieldEditedOrActivated(
|
| decorated->SetInvalid(!controller_->InputIsValid(type, textfield->text()));
|
| }
|
|
|
| +void AutofillDialogViews::ContentsResized() {
|
| + if (GetWidget())
|
| + GetWidget()->SetSize(GetWidget()->non_client_view()->GetPreferredSize());
|
| +}
|
| +
|
| AutofillDialogViews::DetailsGroup* AutofillDialogViews::GroupForSection(
|
| DialogSection section) {
|
| return &detail_groups_.find(section)->second;
|
|
|