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