| 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/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1108 window_(NULL), | 1108 window_(NULL), |
| 1109 notification_area_(NULL), | 1109 notification_area_(NULL), |
| 1110 account_chooser_(NULL), | 1110 account_chooser_(NULL), |
| 1111 sign_in_webview_(NULL), | 1111 sign_in_webview_(NULL), |
| 1112 scrollable_area_(NULL), | 1112 scrollable_area_(NULL), |
| 1113 details_container_(NULL), | 1113 details_container_(NULL), |
| 1114 loading_shield_(NULL), | 1114 loading_shield_(NULL), |
| 1115 overlay_view_(NULL), | 1115 overlay_view_(NULL), |
| 1116 button_strip_extra_view_(NULL), | 1116 button_strip_extra_view_(NULL), |
| 1117 save_in_chrome_checkbox_(NULL), | 1117 save_in_chrome_checkbox_(NULL), |
| 1118 button_strip_image_(NULL), |
| 1118 autocheckout_steps_area_(NULL), | 1119 autocheckout_steps_area_(NULL), |
| 1119 autocheckout_progress_bar_view_(NULL), | 1120 autocheckout_progress_bar_view_(NULL), |
| 1120 autocheckout_progress_bar_(NULL), | 1121 autocheckout_progress_bar_(NULL), |
| 1121 footnote_view_(NULL), | 1122 footnote_view_(NULL), |
| 1122 legal_document_view_(NULL), | 1123 legal_document_view_(NULL), |
| 1123 focus_manager_(NULL), | 1124 focus_manager_(NULL), |
| 1124 observer_(this) { | 1125 observer_(this) { |
| 1125 DCHECK(controller); | 1126 DCHECK(controller); |
| 1126 detail_groups_.insert(std::make_pair(SECTION_EMAIL, | 1127 detail_groups_.insert(std::make_pair(SECTION_EMAIL, |
| 1127 DetailsGroup(SECTION_EMAIL))); | 1128 DetailsGroup(SECTION_EMAIL))); |
| 1128 detail_groups_.insert(std::make_pair(SECTION_CC, | 1129 detail_groups_.insert(std::make_pair(SECTION_CC, |
| 1129 DetailsGroup(SECTION_CC))); | 1130 DetailsGroup(SECTION_CC))); |
| 1130 detail_groups_.insert(std::make_pair(SECTION_BILLING, | 1131 detail_groups_.insert(std::make_pair(SECTION_BILLING, |
| 1131 DetailsGroup(SECTION_BILLING))); | 1132 DetailsGroup(SECTION_BILLING))); |
| 1132 detail_groups_.insert(std::make_pair(SECTION_CC_BILLING, | 1133 detail_groups_.insert(std::make_pair(SECTION_CC_BILLING, |
| 1133 DetailsGroup(SECTION_CC_BILLING))); | 1134 DetailsGroup(SECTION_CC_BILLING))); |
| 1134 detail_groups_.insert(std::make_pair(SECTION_SHIPPING, | 1135 detail_groups_.insert(std::make_pair(SECTION_SHIPPING, |
| 1135 DetailsGroup(SECTION_SHIPPING))); | 1136 DetailsGroup(SECTION_SHIPPING))); |
| 1136 } | 1137 } |
| 1137 | 1138 |
| 1138 AutofillDialogViews::~AutofillDialogViews() { | 1139 AutofillDialogViews::~AutofillDialogViews() { |
| 1139 DCHECK(!window_); | 1140 DCHECK(!window_); |
| 1140 } | 1141 } |
| 1141 | 1142 |
| 1142 void AutofillDialogViews::Show() { | 1143 void AutofillDialogViews::Show() { |
| 1143 InitChildViews(); | 1144 InitChildViews(); |
| 1144 UpdateAccountChooser(); | 1145 UpdateAccountChooser(); |
| 1145 UpdateNotificationArea(); | 1146 UpdateNotificationArea(); |
| 1146 UpdateSaveInChromeCheckbox(); | 1147 UpdateButtonStripExtraView(); |
| 1147 | 1148 |
| 1148 // Ownership of |contents_| is handed off by this call. The widget will take | 1149 // Ownership of |contents_| is handed off by this call. The widget will take |
| 1149 // care of deleting itself after calling DeleteDelegate(). | 1150 // care of deleting itself after calling DeleteDelegate(). |
| 1150 WebContentsModalDialogManager* web_contents_modal_dialog_manager = | 1151 WebContentsModalDialogManager* web_contents_modal_dialog_manager = |
| 1151 WebContentsModalDialogManager::FromWebContents( | 1152 WebContentsModalDialogManager::FromWebContents( |
| 1152 controller_->web_contents()); | 1153 controller_->web_contents()); |
| 1153 window_ = CreateWebContentsModalDialogViews( | 1154 window_ = CreateWebContentsModalDialogViews( |
| 1154 this, | 1155 this, |
| 1155 controller_->web_contents()->GetView()->GetNativeView(), | 1156 controller_->web_contents()->GetView()->GetNativeView(), |
| 1156 web_contents_modal_dialog_manager->delegate()-> | 1157 web_contents_modal_dialog_manager->delegate()-> |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1212 } | 1213 } |
| 1213 | 1214 |
| 1214 void AutofillDialogViews::UpdateAutocheckoutStepsArea() { | 1215 void AutofillDialogViews::UpdateAutocheckoutStepsArea() { |
| 1215 autocheckout_steps_area_->SetSteps(controller_->CurrentAutocheckoutSteps()); | 1216 autocheckout_steps_area_->SetSteps(controller_->CurrentAutocheckoutSteps()); |
| 1216 ContentsPreferredSizeChanged(); | 1217 ContentsPreferredSizeChanged(); |
| 1217 } | 1218 } |
| 1218 | 1219 |
| 1219 void AutofillDialogViews::UpdateButtonStrip() { | 1220 void AutofillDialogViews::UpdateButtonStrip() { |
| 1220 button_strip_extra_view_->SetVisible( | 1221 button_strip_extra_view_->SetVisible( |
| 1221 GetDialogButtons() != ui::DIALOG_BUTTON_NONE); | 1222 GetDialogButtons() != ui::DIALOG_BUTTON_NONE); |
| 1222 UpdateSaveInChromeCheckbox(); | 1223 UpdateButtonStripExtraView(); |
| 1223 autocheckout_progress_bar_view_->SetVisible( | |
| 1224 controller_->ShouldShowProgressBar()); | |
| 1225 GetDialogClientView()->UpdateDialogButtons(); | 1224 GetDialogClientView()->UpdateDialogButtons(); |
| 1226 | 1225 |
| 1227 overlay_view_->SetState(controller_->GetDialogOverlay(), this); | 1226 overlay_view_->SetState(controller_->GetDialogOverlay(), this); |
| 1228 | 1227 |
| 1229 ContentsPreferredSizeChanged(); | 1228 ContentsPreferredSizeChanged(); |
| 1230 } | 1229 } |
| 1231 | 1230 |
| 1232 void AutofillDialogViews::UpdateDetailArea() { | 1231 void AutofillDialogViews::UpdateDetailArea() { |
| 1233 scrollable_area_->SetVisible(controller_->ShouldShowDetailArea()); | 1232 scrollable_area_->SetVisible(controller_->ShouldShowDetailArea()); |
| 1234 ContentsPreferredSizeChanged(); | 1233 ContentsPreferredSizeChanged(); |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1697 void AutofillDialogViews::InitChildViews() { | 1696 void AutofillDialogViews::InitChildViews() { |
| 1698 button_strip_extra_view_ = new LayoutPropagationView(); | 1697 button_strip_extra_view_ = new LayoutPropagationView(); |
| 1699 button_strip_extra_view_->SetLayoutManager( | 1698 button_strip_extra_view_->SetLayoutManager( |
| 1700 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); | 1699 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); |
| 1701 | 1700 |
| 1702 save_in_chrome_checkbox_ = | 1701 save_in_chrome_checkbox_ = |
| 1703 new views::Checkbox(controller_->SaveLocallyText()); | 1702 new views::Checkbox(controller_->SaveLocallyText()); |
| 1704 save_in_chrome_checkbox_->SetChecked(true); | 1703 save_in_chrome_checkbox_->SetChecked(true); |
| 1705 button_strip_extra_view_->AddChildView(save_in_chrome_checkbox_); | 1704 button_strip_extra_view_->AddChildView(save_in_chrome_checkbox_); |
| 1706 | 1705 |
| 1706 button_strip_image_ = new views::ImageView(); |
| 1707 button_strip_extra_view_->AddChildView(button_strip_image_); |
| 1708 |
| 1707 autocheckout_progress_bar_view_ = new views::View(); | 1709 autocheckout_progress_bar_view_ = new views::View(); |
| 1708 views::GridLayout* progress_bar_layout = | 1710 views::GridLayout* progress_bar_layout = |
| 1709 new views::GridLayout(autocheckout_progress_bar_view_); | 1711 new views::GridLayout(autocheckout_progress_bar_view_); |
| 1710 autocheckout_progress_bar_view_->SetLayoutManager(progress_bar_layout); | 1712 autocheckout_progress_bar_view_->SetLayoutManager(progress_bar_layout); |
| 1711 const int kColumnSetId = 0; | 1713 const int kColumnSetId = 0; |
| 1712 views::ColumnSet* columns = progress_bar_layout->AddColumnSet(kColumnSetId); | 1714 views::ColumnSet* columns = progress_bar_layout->AddColumnSet(kColumnSetId); |
| 1713 columns->AddColumn(views::GridLayout::LEADING, | 1715 columns->AddColumn(views::GridLayout::LEADING, |
| 1714 views::GridLayout::CENTER, | 1716 views::GridLayout::CENTER, |
| 1715 0, | 1717 0, |
| 1716 views::GridLayout::USE_PREF, | 1718 views::GridLayout::USE_PREF, |
| 1717 0, | 1719 0, |
| 1718 0); | 1720 0); |
| 1719 progress_bar_layout->StartRow(1.0, kColumnSetId); | 1721 progress_bar_layout->StartRow(1.0, kColumnSetId); |
| 1720 | 1722 |
| 1721 autocheckout_progress_bar_ = new AutocheckoutProgressBar(); | 1723 autocheckout_progress_bar_ = new AutocheckoutProgressBar(); |
| 1722 progress_bar_layout->AddView(autocheckout_progress_bar_); | 1724 progress_bar_layout->AddView(autocheckout_progress_bar_); |
| 1723 | |
| 1724 button_strip_extra_view_->AddChildView(autocheckout_progress_bar_view_); | 1725 button_strip_extra_view_->AddChildView(autocheckout_progress_bar_view_); |
| 1725 autocheckout_progress_bar_view_->SetVisible(false); | |
| 1726 | 1726 |
| 1727 account_chooser_ = new AccountChooser(controller_); | 1727 account_chooser_ = new AccountChooser(controller_); |
| 1728 notification_area_ = new NotificationArea(controller_); | 1728 notification_area_ = new NotificationArea(controller_); |
| 1729 notification_area_->set_arrow_centering_anchor(account_chooser_->AsWeakPtr()); | 1729 notification_area_->set_arrow_centering_anchor(account_chooser_->AsWeakPtr()); |
| 1730 AddChildView(notification_area_); | 1730 AddChildView(notification_area_); |
| 1731 | 1731 |
| 1732 scrollable_area_ = new views::ScrollView(); | 1732 scrollable_area_ = new views::ScrollView(); |
| 1733 scrollable_area_->set_hide_horizontal_scrollbar(true); | 1733 scrollable_area_->set_hide_horizontal_scrollbar(true); |
| 1734 scrollable_area_->SetContents(CreateDetailsContainer()); | 1734 scrollable_area_->SetContents(CreateDetailsContainer()); |
| 1735 AddChildView(scrollable_area_); | 1735 AddChildView(scrollable_area_); |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1960 group.suggested_info->SetSuggestionIcon(suggestion_state.icon); | 1960 group.suggested_info->SetSuggestionIcon(suggestion_state.icon); |
| 1961 | 1961 |
| 1962 if (!suggestion_state.extra_text.empty()) { | 1962 if (!suggestion_state.extra_text.empty()) { |
| 1963 group.suggested_info->ShowTextfield( | 1963 group.suggested_info->ShowTextfield( |
| 1964 suggestion_state.extra_text, | 1964 suggestion_state.extra_text, |
| 1965 suggestion_state.extra_icon); | 1965 suggestion_state.extra_icon); |
| 1966 } | 1966 } |
| 1967 | 1967 |
| 1968 group.manual_input->SetVisible(!show_suggestions); | 1968 group.manual_input->SetVisible(!show_suggestions); |
| 1969 | 1969 |
| 1970 // Show or hide the "Save in chrome" checkbox. If nothing is in editing mode, | 1970 UpdateButtonStripExtraView(); |
| 1971 // hide. If the controller tells us not to show it, likewise hide. | |
| 1972 UpdateSaveInChromeCheckbox(); | |
| 1973 | 1971 |
| 1974 const bool has_menu = !!controller_->MenuModelForSection(group.section); | 1972 const bool has_menu = !!controller_->MenuModelForSection(group.section); |
| 1975 | 1973 |
| 1976 if (group.suggested_button) | 1974 if (group.suggested_button) |
| 1977 group.suggested_button->SetVisible(has_menu); | 1975 group.suggested_button->SetVisible(has_menu); |
| 1978 | 1976 |
| 1979 if (group.container) { | 1977 if (group.container) { |
| 1980 group.container->SetForwardMouseEvents(has_menu && show_suggestions); | 1978 group.container->SetForwardMouseEvents(has_menu && show_suggestions); |
| 1981 group.container->SetVisible(controller_->SectionIsActive(group.section)); | 1979 group.container->SetVisible(controller_->SectionIsActive(group.section)); |
| 1982 if (group.container->visible()) | 1980 if (group.container->visible()) |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2183 // If the field transitioned from invalid to valid, re-validate the group, | 2181 // If the field transitioned from invalid to valid, re-validate the group, |
| 2184 // since inter-field checks become meaningful with valid fields. | 2182 // since inter-field checks become meaningful with valid fields. |
| 2185 if (!decorated->invalid()) | 2183 if (!decorated->invalid()) |
| 2186 ValidateGroup(*group, VALIDATE_EDIT); | 2184 ValidateGroup(*group, VALIDATE_EDIT); |
| 2187 } | 2185 } |
| 2188 | 2186 |
| 2189 gfx::Image icon = controller_->IconForField(type, textfield->text()); | 2187 gfx::Image icon = controller_->IconForField(type, textfield->text()); |
| 2190 decorated->SetIcon(icon); | 2188 decorated->SetIcon(icon); |
| 2191 } | 2189 } |
| 2192 | 2190 |
| 2193 void AutofillDialogViews::UpdateSaveInChromeCheckbox() { | 2191 void AutofillDialogViews::UpdateButtonStripExtraView() { |
| 2194 save_in_chrome_checkbox_->SetVisible( | 2192 save_in_chrome_checkbox_->SetVisible( |
| 2195 controller_->ShouldOfferToSaveInChrome()); | 2193 controller_->ShouldOfferToSaveInChrome()); |
| 2194 |
| 2195 gfx::Image image = controller_->ButtonStripImage(); |
| 2196 button_strip_image_->SetVisible(!image.IsEmpty()); |
| 2197 button_strip_image_->SetImage(image.AsImageSkia()); |
| 2198 |
| 2199 autocheckout_progress_bar_view_->SetVisible( |
| 2200 controller_->ShouldShowProgressBar()); |
| 2196 } | 2201 } |
| 2197 | 2202 |
| 2198 void AutofillDialogViews::ContentsPreferredSizeChanged() { | 2203 void AutofillDialogViews::ContentsPreferredSizeChanged() { |
| 2199 if (GetWidget()) { | 2204 if (GetWidget()) { |
| 2200 GetWidget()->SetSize(GetWidget()->non_client_view()->GetPreferredSize()); | 2205 GetWidget()->SetSize(GetWidget()->non_client_view()->GetPreferredSize()); |
| 2201 // If the above line does not cause the dialog's size to change, |contents_| | 2206 // If the above line does not cause the dialog's size to change, |contents_| |
| 2202 // may not be laid out. This will trigger a layout only if it's needed. | 2207 // may not be laid out. This will trigger a layout only if it's needed. |
| 2203 SetBoundsRect(bounds()); | 2208 SetBoundsRect(bounds()); |
| 2204 } | 2209 } |
| 2205 } | 2210 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2267 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) | 2272 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) |
| 2268 : section(section), | 2273 : section(section), |
| 2269 container(NULL), | 2274 container(NULL), |
| 2270 manual_input(NULL), | 2275 manual_input(NULL), |
| 2271 suggested_info(NULL), | 2276 suggested_info(NULL), |
| 2272 suggested_button(NULL) {} | 2277 suggested_button(NULL) {} |
| 2273 | 2278 |
| 2274 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} | 2279 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} |
| 2275 | 2280 |
| 2276 } // namespace autofill | 2281 } // namespace autofill |
| OLD | NEW |