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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 views::View::OnPaint(canvas); | 199 views::View::OnPaint(canvas); |
200 DrawArrow(canvas, width() / 2.0f, color_); | 200 DrawArrow(canvas, width() / 2.0f, color_); |
201 } | 201 } |
202 | 202 |
203 private: | 203 private: |
204 SkColor color_; | 204 SkColor color_; |
205 | 205 |
206 DISALLOW_COPY_AND_ASSIGN(ErrorBubbleContents); | 206 DISALLOW_COPY_AND_ASSIGN(ErrorBubbleContents); |
207 }; | 207 }; |
208 | 208 |
| 209 // ButtonStripView wraps the Autocheckout progress bar and the "[X] Save details |
| 210 // in Chrome" checkbox and listens for visibility changes. |
| 211 class ButtonStripView : public views::View { |
| 212 public: |
| 213 ButtonStripView() {} |
| 214 virtual ~ButtonStripView() {} |
| 215 |
| 216 protected: |
| 217 virtual void ChildVisibilityChanged(views::View* child) OVERRIDE { |
| 218 PreferredSizeChanged(); |
| 219 } |
| 220 |
| 221 private: |
| 222 DISALLOW_COPY_AND_ASSIGN(ButtonStripView); |
| 223 }; |
| 224 |
209 } // namespace | 225 } // namespace |
210 | 226 |
211 // AutofillDialogViews::SizeLimitedScrollView ---------------------------------- | 227 // AutofillDialogViews::SizeLimitedScrollView ---------------------------------- |
212 | 228 |
213 AutofillDialogViews::SizeLimitedScrollView::SizeLimitedScrollView( | 229 AutofillDialogViews::SizeLimitedScrollView::SizeLimitedScrollView( |
214 views::View* scroll_contents) | 230 views::View* scroll_contents) |
215 : max_height_(-1) { | 231 : max_height_(-1) { |
216 set_hide_horizontal_scrollbar(true); | 232 set_hide_horizontal_scrollbar(true); |
217 SetContents(scroll_contents); | 233 SetContents(scroll_contents); |
218 } | 234 } |
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 decorated_->textfield()->SetIcon(icon); | 735 decorated_->textfield()->SetIcon(icon); |
720 decorated_->SetVisible(true); | 736 decorated_->SetVisible(true); |
721 // The textfield will increase the height of the first row and cause the | 737 // 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. | 738 // label to be aligned properly, so the border is not necessary. |
723 label_->set_border(NULL); | 739 label_->set_border(NULL); |
724 } | 740 } |
725 | 741 |
726 // AutofilDialogViews::AutocheckoutProgressBar --------------------------------- | 742 // AutofilDialogViews::AutocheckoutProgressBar --------------------------------- |
727 | 743 |
728 AutofillDialogViews::AutocheckoutProgressBar::AutocheckoutProgressBar() {} | 744 AutofillDialogViews::AutocheckoutProgressBar::AutocheckoutProgressBar() {} |
| 745 AutofillDialogViews::AutocheckoutProgressBar::~AutocheckoutProgressBar() {} |
729 | 746 |
730 gfx::Size AutofillDialogViews::AutocheckoutProgressBar::GetPreferredSize() { | 747 gfx::Size AutofillDialogViews::AutocheckoutProgressBar::GetPreferredSize() { |
731 return gfx::Size(kAutocheckoutProgressBarWidth, | 748 return gfx::Size(kAutocheckoutProgressBarWidth, |
732 kAutocheckoutProgressBarHeight); | 749 kAutocheckoutProgressBarHeight); |
733 } | 750 } |
734 | 751 |
735 // AutofillDialogView ---------------------------------------------------------- | 752 // AutofillDialogView ---------------------------------------------------------- |
736 | 753 |
737 // static | 754 // static |
738 AutofillDialogView* AutofillDialogView::Create( | 755 AutofillDialogView* AutofillDialogView::Create( |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 void AutofillDialogViews::Hide() { | 826 void AutofillDialogViews::Hide() { |
810 if (window_) | 827 if (window_) |
811 window_->Close(); | 828 window_->Close(); |
812 } | 829 } |
813 | 830 |
814 void AutofillDialogViews::UpdateAccountChooser() { | 831 void AutofillDialogViews::UpdateAccountChooser() { |
815 account_chooser_->Update(); | 832 account_chooser_->Update(); |
816 | 833 |
817 // Update legal documents for the account. | 834 // Update legal documents for the account. |
818 if (footnote_view_) { | 835 if (footnote_view_) { |
819 string16 text = controller_->LegalDocumentsText(); | 836 const string16 text = controller_->LegalDocumentsText(); |
820 if (text.empty()) { | 837 legal_document_view_->SetText(text); |
821 footnote_view_->SetVisible(false); | |
822 } else { | |
823 footnote_view_->SetVisible(true); | |
824 legal_document_view_->SetText(text); | |
825 | 838 |
| 839 if (!text.empty()) { |
826 const std::vector<ui::Range>& link_ranges = | 840 const std::vector<ui::Range>& link_ranges = |
827 controller_->LegalDocumentLinks(); | 841 controller_->LegalDocumentLinks(); |
828 for (size_t i = 0; i < link_ranges.size(); ++i) { | 842 for (size_t i = 0; i < link_ranges.size(); ++i) { |
829 legal_document_view_->AddStyleRange( | 843 legal_document_view_->AddStyleRange( |
830 link_ranges[i], | 844 link_ranges[i], |
831 views::StyledLabel::RangeStyleInfo::CreateForLink()); | 845 views::StyledLabel::RangeStyleInfo::CreateForLink()); |
832 } | 846 } |
833 } | 847 } |
834 | 848 |
| 849 footnote_view_->SetVisible(!text.empty()); |
835 ContentsPreferredSizeChanged(); | 850 ContentsPreferredSizeChanged(); |
836 } | 851 } |
837 } | 852 } |
838 | 853 |
839 void AutofillDialogViews::UpdateButtonStrip() { | 854 void AutofillDialogViews::UpdateButtonStrip() { |
840 button_strip_extra_view_->SetVisible( | 855 button_strip_extra_view_->SetVisible( |
841 GetDialogButtons() != ui::DIALOG_BUTTON_NONE); | 856 GetDialogButtons() != ui::DIALOG_BUTTON_NONE); |
842 save_in_chrome_checkbox_->SetVisible(!(controller_->AutocheckoutIsRunning() || | 857 save_in_chrome_checkbox_->SetVisible(!(controller_->AutocheckoutIsRunning() || |
843 controller_->HadAutocheckoutError())); | 858 controller_->HadAutocheckoutError())); |
844 autocheckout_progress_bar_view_->SetVisible( | 859 autocheckout_progress_bar_view_->SetVisible( |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1174 DetailsGroup* group = GroupForView(combobox); | 1189 DetailsGroup* group = GroupForView(combobox); |
1175 ValidateGroup(*group, AutofillDialogController::VALIDATE_EDIT); | 1190 ValidateGroup(*group, AutofillDialogController::VALIDATE_EDIT); |
1176 } | 1191 } |
1177 | 1192 |
1178 void AutofillDialogViews::StyledLabelLinkClicked(const ui::Range& range, | 1193 void AutofillDialogViews::StyledLabelLinkClicked(const ui::Range& range, |
1179 int event_flags) { | 1194 int event_flags) { |
1180 controller_->LegalDocumentLinkClicked(range); | 1195 controller_->LegalDocumentLinkClicked(range); |
1181 } | 1196 } |
1182 | 1197 |
1183 void AutofillDialogViews::InitChildViews() { | 1198 void AutofillDialogViews::InitChildViews() { |
1184 button_strip_extra_view_ = new views::View(); | 1199 button_strip_extra_view_ = new ButtonStripView(); |
1185 button_strip_extra_view_->SetLayoutManager( | 1200 button_strip_extra_view_->SetLayoutManager( |
1186 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); | 1201 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); |
1187 | 1202 |
1188 save_in_chrome_checkbox_ = | 1203 save_in_chrome_checkbox_ = |
1189 new views::Checkbox(controller_->SaveLocallyText()); | 1204 new views::Checkbox(controller_->SaveLocallyText()); |
1190 button_strip_extra_view_->AddChildView(save_in_chrome_checkbox_); | 1205 button_strip_extra_view_->AddChildView(save_in_chrome_checkbox_); |
1191 | 1206 |
1192 autocheckout_progress_bar_view_ = new views::View(); | 1207 autocheckout_progress_bar_view_ = new views::View(); |
1193 autocheckout_progress_bar_view_->SetLayoutManager( | 1208 autocheckout_progress_bar_view_->SetLayoutManager( |
1194 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); | 1209 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) | 1705 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) |
1691 : section(section), | 1706 : section(section), |
1692 container(NULL), | 1707 container(NULL), |
1693 manual_input(NULL), | 1708 manual_input(NULL), |
1694 suggested_info(NULL), | 1709 suggested_info(NULL), |
1695 suggested_button(NULL) {} | 1710 suggested_button(NULL) {} |
1696 | 1711 |
1697 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} | 1712 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} |
1698 | 1713 |
1699 } // namespace autofill | 1714 } // namespace autofill |
OLD | NEW |