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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/autofill/autofill_dialog_views.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..b7b2554d131bec6ec2328d0ff2a70aca79fa69ec 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
@@ -479,6 +482,15 @@ void AutofillDialogViews::UpdateProgressBar(double value) {
autocheckout_progress_bar_->SetValue(value);
}
+void AutofillDialogViews::UpdateFootnote() {
+ PopulateFootnoteLinks();
+
+ if (GetWidget())
+ GetWidget()->SetSize(GetWidget()->non_client_view()->GetPreferredSize());
+
+ contents_->Layout();
+}
+
string16 AutofillDialogViews::GetWindowTitle() const {
return controller_->DialogTitle();
}
@@ -520,8 +532,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 +613,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 (source->parent()->parent() == footnote_view_) {
+ 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 +659,13 @@ 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();
+ 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 +700,98 @@ 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_->RemoveAllChildViews(true);
+ footnote_view_->SetVisible(has_links);
+ footnote_view_->set_border(views::Border::CreateEmptyBorder(
+ has_links ? views::kUnrelatedControlVerticalSpacing : 0, 0, 0, 0));
+
+ if (!has_links)
+ return;
+
+ // 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.
+ views::Label* text = new views::Label(link_parts[i]);
+ text->SetHorizontalAlignment(gfx::ALIGN_LEFT);
Dan Beam 2013/02/09 00:27:57 not sure if this is necessary
+ padding_layout->AddView(text);
+ } 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->SetHorizontalAlignment(gfx::ALIGN_LEFT);
Dan Beam 2013/02/09 00:27:57 nor this
+ 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::FILL,
+ 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.").
+ views::Label* accept_these_changes =
+ new views::Label(controller_->AcceptChangesText());
+ accept_these_changes->SetHorizontalAlignment(gfx::ALIGN_LEFT);
+
+ padding_layout->StartRowWithPadding(
+ 0, full_width_column_set, 0, views::kRelatedControlVerticalSpacing);
+ padding_layout->AddView(accept_these_changes);
+
+ padding_layout->StartRowWithPadding(
+ 0, full_width_column_set, 0, views::kUnrelatedControlVerticalSpacing);
+}
+
views::View* AutofillDialogViews::CreateDetailsContainer() {
views::View* view = new views::View();
// A box layout is used because it respects widget visibility.
« 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