| 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/location.h" | 10 #include "base/location.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 combobox->SetSelectedIndex(combobox->model()->GetDefaultIndex()); | 159 combobox->SetSelectedIndex(combobox->model()->GetDefaultIndex()); |
| 160 } | 160 } |
| 161 | 161 |
| 162 // This class handles layout for the first row of a SuggestionView. | 162 // This class handles layout for the first row of a SuggestionView. |
| 163 // It exists to circumvent shortcomings of GridLayout and BoxLayout (namely that | 163 // It exists to circumvent shortcomings of GridLayout and BoxLayout (namely that |
| 164 // the former doesn't fully respect child visibility, and that the latter won't | 164 // the former doesn't fully respect child visibility, and that the latter won't |
| 165 // expand a single child). | 165 // expand a single child). |
| 166 class SectionRowView : public views::View { | 166 class SectionRowView : public views::View { |
| 167 public: | 167 public: |
| 168 SectionRowView() { | 168 SectionRowView() { |
| 169 set_border(views::Border::CreateEmptyBorder(10, 0, 0, 0)); | 169 SetBorder(views::Border::CreateEmptyBorder(10, 0, 0, 0)); |
| 170 } | 170 } |
| 171 | 171 |
| 172 virtual ~SectionRowView() {} | 172 virtual ~SectionRowView() {} |
| 173 | 173 |
| 174 // views::View implementation: | 174 // views::View implementation: |
| 175 virtual gfx::Size GetPreferredSize() OVERRIDE { | 175 virtual gfx::Size GetPreferredSize() OVERRIDE { |
| 176 int height = 0; | 176 int height = 0; |
| 177 int width = 0; | 177 int width = 0; |
| 178 for (int i = 0; i < child_count(); ++i) { | 178 for (int i = 0; i < child_count(); ++i) { |
| 179 if (child_at(i)->visible()) { | 179 if (child_at(i)->visible()) { |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 label_view.reset(label.release()); | 298 label_view.reset(label.release()); |
| 299 } | 299 } |
| 300 | 300 |
| 301 AddChildView(label_view.release()); | 301 AddChildView(label_view.release()); |
| 302 | 302 |
| 303 if (!data.tooltip_text().empty()) | 303 if (!data.tooltip_text().empty()) |
| 304 AddChildView(new TooltipIcon(data.tooltip_text())); | 304 AddChildView(new TooltipIcon(data.tooltip_text())); |
| 305 | 305 |
| 306 set_background( | 306 set_background( |
| 307 views::Background::CreateSolidBackground(data.GetBackgroundColor())); | 307 views::Background::CreateSolidBackground(data.GetBackgroundColor())); |
| 308 set_border(views::Border::CreateSolidSidedBorder(1, 0, 1, 0, | 308 SetBorder(views::Border::CreateSolidSidedBorder(1, 0, 1, 0, |
| 309 data.GetBorderColor())); | 309 data.GetBorderColor())); |
| 310 } | 310 } |
| 311 | 311 |
| 312 virtual ~NotificationView() {} | 312 virtual ~NotificationView() {} |
| 313 | 313 |
| 314 views::Checkbox* checkbox() { | 314 views::Checkbox* checkbox() { |
| 315 return checkbox_; | 315 return checkbox_; |
| 316 } | 316 } |
| 317 | 317 |
| 318 // views::View implementation. | 318 // views::View implementation. |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 } // namespace | 459 } // namespace |
| 460 | 460 |
| 461 // AutofillDialogViews::AccountChooser ----------------------------------------- | 461 // AutofillDialogViews::AccountChooser ----------------------------------------- |
| 462 | 462 |
| 463 AutofillDialogViews::AccountChooser::AccountChooser( | 463 AutofillDialogViews::AccountChooser::AccountChooser( |
| 464 AutofillDialogViewDelegate* delegate) | 464 AutofillDialogViewDelegate* delegate) |
| 465 : image_(new views::ImageView()), | 465 : image_(new views::ImageView()), |
| 466 menu_button_(new views::MenuButton(NULL, base::string16(), this, true)), | 466 menu_button_(new views::MenuButton(NULL, base::string16(), this, true)), |
| 467 link_(new views::Link()), | 467 link_(new views::Link()), |
| 468 delegate_(delegate) { | 468 delegate_(delegate) { |
| 469 set_border(views::Border::CreateEmptyBorder(0, 0, 0, 10)); | 469 SetBorder(views::Border::CreateEmptyBorder(0, 0, 0, 10)); |
| 470 SetLayoutManager( | 470 SetLayoutManager( |
| 471 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, | 471 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, |
| 472 kAroundTextPadding)); | 472 kAroundTextPadding)); |
| 473 AddChildView(image_); | 473 AddChildView(image_); |
| 474 | 474 |
| 475 menu_button_->set_background(NULL); | 475 menu_button_->set_background(NULL); |
| 476 menu_button_->set_border(NULL); | 476 menu_button_->ClearBorder(); |
| 477 gfx::Insets insets = GetInsets(); | 477 gfx::Insets insets = GetInsets(); |
| 478 menu_button_->SetFocusPainter( | 478 menu_button_->SetFocusPainter( |
| 479 views::Painter::CreateDashedFocusPainterWithInsets(insets)); | 479 views::Painter::CreateDashedFocusPainterWithInsets(insets)); |
| 480 menu_button_->SetFocusable(true); | 480 menu_button_->SetFocusable(true); |
| 481 AddChildView(menu_button_); | 481 AddChildView(menu_button_); |
| 482 | 482 |
| 483 link_->set_listener(this); | 483 link_->set_listener(this); |
| 484 AddChildView(link_); | 484 AddChildView(link_); |
| 485 } | 485 } |
| 486 | 486 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 } | 584 } |
| 585 | 585 |
| 586 image_view_->SetImage(state.image.ToImageSkia()); | 586 image_view_->SetImage(state.image.ToImageSkia()); |
| 587 | 587 |
| 588 message_view_->SetVisible(!state.string.text.empty()); | 588 message_view_->SetVisible(!state.string.text.empty()); |
| 589 message_view_->SetText(state.string.text); | 589 message_view_->SetText(state.string.text); |
| 590 message_view_->SetFontList(gfx::FontList(state.string.font)); | 590 message_view_->SetFontList(gfx::FontList(state.string.font)); |
| 591 message_view_->SetEnabledColor(GetNativeTheme()->GetSystemColor( | 591 message_view_->SetEnabledColor(GetNativeTheme()->GetSystemColor( |
| 592 ui::NativeTheme::kColorId_TextfieldReadOnlyColor)); | 592 ui::NativeTheme::kColorId_TextfieldReadOnlyColor)); |
| 593 | 593 |
| 594 message_view_->set_border( | 594 message_view_->SetBorder( |
| 595 views::Border::CreateEmptyBorder(kOverlayMessageVerticalPadding, | 595 views::Border::CreateEmptyBorder(kOverlayMessageVerticalPadding, |
| 596 kDialogEdgePadding, | 596 kDialogEdgePadding, |
| 597 kOverlayMessageVerticalPadding, | 597 kOverlayMessageVerticalPadding, |
| 598 kDialogEdgePadding)); | 598 kDialogEdgePadding)); |
| 599 | 599 |
| 600 SetVisible(true); | 600 SetVisible(true); |
| 601 } | 601 } |
| 602 | 602 |
| 603 gfx::Insets AutofillDialogViews::OverlayView::GetInsets() const { | 603 gfx::Insets AutofillDialogViews::OverlayView::GetInsets() const { |
| 604 return gfx::Insets(12, 12, 12, 12); | 604 return gfx::Insets(12, 12, 12, 12); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 return bounds; | 703 return bounds; |
| 704 } | 704 } |
| 705 | 705 |
| 706 // AutofillDialogViews::NotificationArea --------------------------------------- | 706 // AutofillDialogViews::NotificationArea --------------------------------------- |
| 707 | 707 |
| 708 AutofillDialogViews::NotificationArea::NotificationArea( | 708 AutofillDialogViews::NotificationArea::NotificationArea( |
| 709 AutofillDialogViewDelegate* delegate) | 709 AutofillDialogViewDelegate* delegate) |
| 710 : delegate_(delegate) { | 710 : delegate_(delegate) { |
| 711 // Reserve vertical space for the arrow (regardless of whether one exists). | 711 // Reserve vertical space for the arrow (regardless of whether one exists). |
| 712 // The -1 accounts for the border. | 712 // The -1 accounts for the border. |
| 713 set_border(views::Border::CreateEmptyBorder(kArrowHeight - 1, 0, 0, 0)); | 713 SetBorder(views::Border::CreateEmptyBorder(kArrowHeight - 1, 0, 0, 0)); |
| 714 | 714 |
| 715 views::BoxLayout* box_layout = | 715 views::BoxLayout* box_layout = |
| 716 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0); | 716 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0); |
| 717 SetLayoutManager(box_layout); | 717 SetLayoutManager(box_layout); |
| 718 } | 718 } |
| 719 | 719 |
| 720 AutofillDialogViews::NotificationArea::~NotificationArea() {} | 720 AutofillDialogViews::NotificationArea::~NotificationArea() {} |
| 721 | 721 |
| 722 void AutofillDialogViews::NotificationArea::SetNotifications( | 722 void AutofillDialogViews::NotificationArea::SetNotifications( |
| 723 const std::vector<DialogNotification>& notifications) { | 723 const std::vector<DialogNotification>& notifications) { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 790 // AutofillDialogViews::SectionContainer --------------------------------------- | 790 // AutofillDialogViews::SectionContainer --------------------------------------- |
| 791 | 791 |
| 792 AutofillDialogViews::SectionContainer::SectionContainer( | 792 AutofillDialogViews::SectionContainer::SectionContainer( |
| 793 const base::string16& label, | 793 const base::string16& label, |
| 794 views::View* controls, | 794 views::View* controls, |
| 795 views::Button* proxy_button) | 795 views::Button* proxy_button) |
| 796 : proxy_button_(proxy_button), | 796 : proxy_button_(proxy_button), |
| 797 forward_mouse_events_(false) { | 797 forward_mouse_events_(false) { |
| 798 set_notify_enter_exit_on_child(true); | 798 set_notify_enter_exit_on_child(true); |
| 799 | 799 |
| 800 set_border(views::Border::CreateEmptyBorder(kDetailSectionVerticalPadding, | 800 SetBorder(views::Border::CreateEmptyBorder(kDetailSectionVerticalPadding, |
| 801 kDialogEdgePadding, | 801 kDialogEdgePadding, |
| 802 kDetailSectionVerticalPadding, | 802 kDetailSectionVerticalPadding, |
| 803 kDialogEdgePadding)); | 803 kDialogEdgePadding)); |
| 804 | 804 |
| 805 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 805 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 806 views::Label* label_view = new views::Label( | 806 views::Label* label_view = new views::Label( |
| 807 label, rb.GetFontList(ui::ResourceBundle::BoldFont)); | 807 label, rb.GetFontList(ui::ResourceBundle::BoldFont)); |
| 808 label_view->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 808 label_view->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 809 | 809 |
| 810 views::View* label_bar = new views::View(); | 810 views::View* label_bar = new views::View(); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 // Always forward events on the label bar. | 946 // Always forward events on the label bar. |
| 947 return forward_mouse_events_ || event.y() <= child_at(0)->bounds().bottom(); | 947 return forward_mouse_events_ || event.y() <= child_at(0)->bounds().bottom(); |
| 948 } | 948 } |
| 949 | 949 |
| 950 // AutofillDialogViews::SuggestedButton ---------------------------------------- | 950 // AutofillDialogViews::SuggestedButton ---------------------------------------- |
| 951 | 951 |
| 952 AutofillDialogViews::SuggestedButton::SuggestedButton( | 952 AutofillDialogViews::SuggestedButton::SuggestedButton( |
| 953 views::MenuButtonListener* listener) | 953 views::MenuButtonListener* listener) |
| 954 : views::MenuButton(NULL, base::string16(), listener, false) { | 954 : views::MenuButton(NULL, base::string16(), listener, false) { |
| 955 const int kFocusBorderWidth = 1; | 955 const int kFocusBorderWidth = 1; |
| 956 set_border(views::Border::CreateEmptyBorder(kMenuButtonTopInset, | 956 SetBorder(views::Border::CreateEmptyBorder(kMenuButtonTopInset, |
| 957 kDialogEdgePadding, | 957 kDialogEdgePadding, |
| 958 kMenuButtonBottomInset, | 958 kMenuButtonBottomInset, |
| 959 kFocusBorderWidth)); | 959 kFocusBorderWidth)); |
| 960 gfx::Insets insets = GetInsets(); | 960 gfx::Insets insets = GetInsets(); |
| 961 insets += gfx::Insets(-kFocusBorderWidth, -kFocusBorderWidth, | 961 insets += gfx::Insets(-kFocusBorderWidth, -kFocusBorderWidth, |
| 962 -kFocusBorderWidth, -kFocusBorderWidth); | 962 -kFocusBorderWidth, -kFocusBorderWidth); |
| 963 SetFocusPainter( | 963 SetFocusPainter( |
| 964 views::Painter::CreateDashedFocusPainterWithInsets(insets)); | 964 views::Painter::CreateDashedFocusPainterWithInsets(insets)); |
| 965 SetFocusable(true); | 965 SetFocusable(true); |
| 966 } | 966 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 AutofillDialogViews::SuggestionView::SuggestionView( | 1025 AutofillDialogViews::SuggestionView::SuggestionView( |
| 1026 AutofillDialogViews* autofill_dialog) | 1026 AutofillDialogViews* autofill_dialog) |
| 1027 : label_(new views::Label()), | 1027 : label_(new views::Label()), |
| 1028 label_line_2_(new views::Label()), | 1028 label_line_2_(new views::Label()), |
| 1029 icon_(new views::ImageView()), | 1029 icon_(new views::ImageView()), |
| 1030 decorated_( | 1030 decorated_( |
| 1031 new DecoratedTextfield(base::string16(), | 1031 new DecoratedTextfield(base::string16(), |
| 1032 base::string16(), | 1032 base::string16(), |
| 1033 autofill_dialog)) { | 1033 autofill_dialog)) { |
| 1034 // TODO(estade): Make this the correct color. | 1034 // TODO(estade): Make this the correct color. |
| 1035 set_border( | 1035 SetBorder( |
| 1036 views::Border::CreateSolidSidedBorder(1, 0, 0, 0, SK_ColorLTGRAY)); | 1036 views::Border::CreateSolidSidedBorder(1, 0, 0, 0, SK_ColorLTGRAY)); |
| 1037 | 1037 |
| 1038 SectionRowView* label_container = new SectionRowView(); | 1038 SectionRowView* label_container = new SectionRowView(); |
| 1039 AddChildView(label_container); | 1039 AddChildView(label_container); |
| 1040 | 1040 |
| 1041 // Label and icon. | 1041 // Label and icon. |
| 1042 label_container->AddChildView(icon_); | 1042 label_container->AddChildView(icon_); |
| 1043 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 1043 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 1044 label_container->AddChildView(label_); | 1044 label_container->AddChildView(label_); |
| 1045 | 1045 |
| (...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1661 return account_chooser_; | 1661 return account_chooser_; |
| 1662 } | 1662 } |
| 1663 | 1663 |
| 1664 views::View* AutofillDialogViews::CreateFootnoteView() { | 1664 views::View* AutofillDialogViews::CreateFootnoteView() { |
| 1665 footnote_view_ = new LayoutPropagationView(); | 1665 footnote_view_ = new LayoutPropagationView(); |
| 1666 footnote_view_->SetLayoutManager( | 1666 footnote_view_->SetLayoutManager( |
| 1667 new views::BoxLayout(views::BoxLayout::kVertical, | 1667 new views::BoxLayout(views::BoxLayout::kVertical, |
| 1668 kDialogEdgePadding, | 1668 kDialogEdgePadding, |
| 1669 kDialogEdgePadding, | 1669 kDialogEdgePadding, |
| 1670 0)); | 1670 0)); |
| 1671 footnote_view_->set_border( | 1671 footnote_view_->SetBorder( |
| 1672 views::Border::CreateSolidSidedBorder(1, 0, 0, 0, kSubtleBorderColor)); | 1672 views::Border::CreateSolidSidedBorder(1, 0, 0, 0, kSubtleBorderColor)); |
| 1673 footnote_view_->set_background( | 1673 footnote_view_->set_background( |
| 1674 views::Background::CreateSolidBackground(kShadingColor)); | 1674 views::Background::CreateSolidBackground(kShadingColor)); |
| 1675 | 1675 |
| 1676 legal_document_view_ = new views::StyledLabel(base::string16(), this); | 1676 legal_document_view_ = new views::StyledLabel(base::string16(), this); |
| 1677 OnNativeThemeChanged(GetNativeTheme()); | 1677 OnNativeThemeChanged(GetNativeTheme()); |
| 1678 | 1678 |
| 1679 footnote_view_->AddChildView(legal_document_view_); | 1679 footnote_view_->AddChildView(legal_document_view_); |
| 1680 footnote_view_->SetVisible(false); | 1680 footnote_view_->SetVisible(false); |
| 1681 | 1681 |
| (...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2516 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) | 2516 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) |
| 2517 : section(section), | 2517 : section(section), |
| 2518 container(NULL), | 2518 container(NULL), |
| 2519 manual_input(NULL), | 2519 manual_input(NULL), |
| 2520 suggested_info(NULL), | 2520 suggested_info(NULL), |
| 2521 suggested_button(NULL) {} | 2521 suggested_button(NULL) {} |
| 2522 | 2522 |
| 2523 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} | 2523 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} |
| 2524 | 2524 |
| 2525 } // namespace autofill | 2525 } // namespace autofill |
| OLD | NEW |