OLD | NEW |
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/bind.h" | 9 #include "base/bind.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 const string16& placeholder_text, | 716 const string16& placeholder_text, |
717 const gfx::ImageSkia& icon) { | 717 const gfx::ImageSkia& icon) { |
718 decorated_->textfield()->set_placeholder_text(placeholder_text); | 718 decorated_->textfield()->set_placeholder_text(placeholder_text); |
719 decorated_->textfield()->SetIcon(icon); | 719 decorated_->textfield()->SetIcon(icon); |
720 decorated_->SetVisible(true); | 720 decorated_->SetVisible(true); |
721 // The textfield will increase the height of the first row and cause the | 721 // The textfield will increase the height of the first row and cause the |
722 // label to be aligned properly, so the border is not necessary. | 722 // label to be aligned properly, so the border is not necessary. |
723 label_->set_border(NULL); | 723 label_->set_border(NULL); |
724 } | 724 } |
725 | 725 |
| 726 // AutofilDialogViews::ButtonStripView ----------------------------------------- |
| 727 |
| 728 AutofillDialogViews::ButtonStripView::ButtonStripView() {} |
| 729 AutofillDialogViews::ButtonStripView::~ButtonStripView() {} |
| 730 |
| 731 void AutofillDialogViews::ButtonStripView::ChildVisibilityChanged( |
| 732 views::View* child) { |
| 733 PreferredSizeChanged(); |
| 734 } |
| 735 |
726 // AutofilDialogViews::AutocheckoutProgressBar --------------------------------- | 736 // AutofilDialogViews::AutocheckoutProgressBar --------------------------------- |
727 | 737 |
728 AutofillDialogViews::AutocheckoutProgressBar::AutocheckoutProgressBar() {} | 738 AutofillDialogViews::AutocheckoutProgressBar::AutocheckoutProgressBar() {} |
| 739 AutofillDialogViews::AutocheckoutProgressBar::~AutocheckoutProgressBar() {} |
729 | 740 |
730 gfx::Size AutofillDialogViews::AutocheckoutProgressBar::GetPreferredSize() { | 741 gfx::Size AutofillDialogViews::AutocheckoutProgressBar::GetPreferredSize() { |
731 return gfx::Size(kAutocheckoutProgressBarWidth, | 742 return gfx::Size(kAutocheckoutProgressBarWidth, |
732 kAutocheckoutProgressBarHeight); | 743 kAutocheckoutProgressBarHeight); |
733 } | 744 } |
734 | 745 |
735 // AutofillDialogView ---------------------------------------------------------- | 746 // AutofillDialogView ---------------------------------------------------------- |
736 | 747 |
737 // static | 748 // static |
738 AutofillDialogView* AutofillDialogView::Create( | 749 AutofillDialogView* AutofillDialogView::Create( |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 void AutofillDialogViews::Hide() { | 820 void AutofillDialogViews::Hide() { |
810 if (window_) | 821 if (window_) |
811 window_->Close(); | 822 window_->Close(); |
812 } | 823 } |
813 | 824 |
814 void AutofillDialogViews::UpdateAccountChooser() { | 825 void AutofillDialogViews::UpdateAccountChooser() { |
815 account_chooser_->Update(); | 826 account_chooser_->Update(); |
816 | 827 |
817 // Update legal documents for the account. | 828 // Update legal documents for the account. |
818 if (footnote_view_) { | 829 if (footnote_view_) { |
819 string16 text = controller_->LegalDocumentsText(); | 830 const string16 text = controller_->LegalDocumentsText(); |
820 if (text.empty()) { | 831 legal_document_view_->SetText(text); |
821 footnote_view_->SetVisible(false); | |
822 } else { | |
823 footnote_view_->SetVisible(true); | |
824 legal_document_view_->SetText(text); | |
825 | 832 |
| 833 if (!text.empty()) { |
826 const std::vector<ui::Range>& link_ranges = | 834 const std::vector<ui::Range>& link_ranges = |
827 controller_->LegalDocumentLinks(); | 835 controller_->LegalDocumentLinks(); |
828 for (size_t i = 0; i < link_ranges.size(); ++i) { | 836 for (size_t i = 0; i < link_ranges.size(); ++i) { |
829 legal_document_view_->AddStyleRange( | 837 legal_document_view_->AddStyleRange( |
830 link_ranges[i], | 838 link_ranges[i], |
831 views::StyledLabel::RangeStyleInfo::CreateForLink()); | 839 views::StyledLabel::RangeStyleInfo::CreateForLink()); |
832 } | 840 } |
833 } | 841 } |
834 | 842 |
| 843 footnote_view_->SetVisible(!text.empty()); |
835 ContentsPreferredSizeChanged(); | 844 ContentsPreferredSizeChanged(); |
836 } | 845 } |
837 } | 846 } |
838 | 847 |
839 void AutofillDialogViews::UpdateButtonStrip() { | 848 void AutofillDialogViews::UpdateButtonStrip() { |
840 button_strip_extra_view_->SetVisible( | 849 button_strip_extra_view_->SetVisible( |
841 GetDialogButtons() != ui::DIALOG_BUTTON_NONE); | 850 GetDialogButtons() != ui::DIALOG_BUTTON_NONE); |
842 save_in_chrome_checkbox_->SetVisible(!(controller_->AutocheckoutIsRunning() || | 851 save_in_chrome_checkbox_->SetVisible(!(controller_->AutocheckoutIsRunning() || |
843 controller_->HadAutocheckoutError())); | 852 controller_->HadAutocheckoutError())); |
844 autocheckout_progress_bar_view_->SetVisible( | 853 autocheckout_progress_bar_view_->SetVisible( |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1174 DetailsGroup* group = GroupForView(combobox); | 1183 DetailsGroup* group = GroupForView(combobox); |
1175 ValidateGroup(*group, AutofillDialogController::VALIDATE_EDIT); | 1184 ValidateGroup(*group, AutofillDialogController::VALIDATE_EDIT); |
1176 } | 1185 } |
1177 | 1186 |
1178 void AutofillDialogViews::StyledLabelLinkClicked(const ui::Range& range, | 1187 void AutofillDialogViews::StyledLabelLinkClicked(const ui::Range& range, |
1179 int event_flags) { | 1188 int event_flags) { |
1180 controller_->LegalDocumentLinkClicked(range); | 1189 controller_->LegalDocumentLinkClicked(range); |
1181 } | 1190 } |
1182 | 1191 |
1183 void AutofillDialogViews::InitChildViews() { | 1192 void AutofillDialogViews::InitChildViews() { |
1184 button_strip_extra_view_ = new views::View(); | 1193 button_strip_extra_view_ = new ButtonStripView(); |
1185 button_strip_extra_view_->SetLayoutManager( | 1194 button_strip_extra_view_->SetLayoutManager( |
1186 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); | 1195 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); |
1187 | 1196 |
1188 save_in_chrome_checkbox_ = | 1197 save_in_chrome_checkbox_ = |
1189 new views::Checkbox(controller_->SaveLocallyText()); | 1198 new views::Checkbox(controller_->SaveLocallyText()); |
1190 button_strip_extra_view_->AddChildView(save_in_chrome_checkbox_); | 1199 button_strip_extra_view_->AddChildView(save_in_chrome_checkbox_); |
1191 | 1200 |
1192 autocheckout_progress_bar_view_ = new views::View(); | 1201 autocheckout_progress_bar_view_ = new views::View(); |
1193 autocheckout_progress_bar_view_->SetLayoutManager( | 1202 autocheckout_progress_bar_view_->SetLayoutManager( |
1194 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); | 1203 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1690 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) | 1699 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) |
1691 : section(section), | 1700 : section(section), |
1692 container(NULL), | 1701 container(NULL), |
1693 manual_input(NULL), | 1702 manual_input(NULL), |
1694 suggested_info(NULL), | 1703 suggested_info(NULL), |
1695 suggested_button(NULL) {} | 1704 suggested_button(NULL) {} |
1696 | 1705 |
1697 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} | 1706 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} |
1698 | 1707 |
1699 } // namespace autofill | 1708 } // namespace autofill |
OLD | NEW |