| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/payments/profile_list_view_controller.h" | 5 #include "chrome/browser/ui/views/payments/profile_list_view_controller.h" |
| 6 | 6 |
| 7 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h" | 7 #include "chrome/browser/ui/views/payments/payment_request_dialog_view.h" |
| 8 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" | 8 #include "chrome/browser/ui/views/payments/payment_request_dialog_view_ids.h" |
| 9 #include "chrome/browser/ui/views/payments/payment_request_row_view.h" | 9 #include "chrome/browser/ui/views/payments/payment_request_row_view.h" |
| 10 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" | 10 #include "chrome/browser/ui/views/payments/payment_request_views_util.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 } | 114 } |
| 115 | 115 |
| 116 autofill::AutofillProfile* GetSelectedProfile() override { | 116 autofill::AutofillProfile* GetSelectedProfile() override { |
| 117 return state()->selected_shipping_profile(); | 117 return state()->selected_shipping_profile(); |
| 118 } | 118 } |
| 119 | 119 |
| 120 std::vector<autofill::AutofillProfile*> GetProfiles() override { | 120 std::vector<autofill::AutofillProfile*> GetProfiles() override { |
| 121 return state()->shipping_profiles(); | 121 return state()->shipping_profiles(); |
| 122 } | 122 } |
| 123 | 123 |
| 124 DialogViewID GetDialogViewId() override { |
| 125 return DialogViewID::SHIPPING_ADDRESS_SHEET_LIST_VIEW; |
| 126 } |
| 127 |
| 124 base::string16 GetSheetTitle() override { | 128 base::string16 GetSheetTitle() override { |
| 125 return GetShippingAddressSectionString(spec()->shipping_type()); | 129 return GetShippingAddressSectionString(spec()->shipping_type()); |
| 126 } | 130 } |
| 127 | 131 |
| 128 int GetSecondaryButtonTextId() override { | 132 int GetSecondaryButtonTextId() override { |
| 129 return IDS_AUTOFILL_ADD_ADDRESS_CAPTION; | 133 return IDS_AUTOFILL_ADD_ADDRESS_CAPTION; |
| 130 } | 134 } |
| 131 | 135 |
| 132 int GetSecondaryButtonTag() override { | 136 int GetSecondaryButtonTag() override { |
| 133 return static_cast<int>( | 137 return static_cast<int>( |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 } | 174 } |
| 171 | 175 |
| 172 autofill::AutofillProfile* GetSelectedProfile() override { | 176 autofill::AutofillProfile* GetSelectedProfile() override { |
| 173 return state()->selected_contact_profile(); | 177 return state()->selected_contact_profile(); |
| 174 } | 178 } |
| 175 | 179 |
| 176 std::vector<autofill::AutofillProfile*> GetProfiles() override { | 180 std::vector<autofill::AutofillProfile*> GetProfiles() override { |
| 177 return state()->contact_profiles(); | 181 return state()->contact_profiles(); |
| 178 } | 182 } |
| 179 | 183 |
| 184 DialogViewID GetDialogViewId() override { |
| 185 return DialogViewID::CONTACT_INFO_SHEET_LIST_VIEW; |
| 186 } |
| 187 |
| 180 base::string16 GetSheetTitle() override { | 188 base::string16 GetSheetTitle() override { |
| 181 return l10n_util::GetStringUTF16( | 189 return l10n_util::GetStringUTF16( |
| 182 IDS_PAYMENT_REQUEST_CONTACT_INFO_SECTION_NAME); | 190 IDS_PAYMENT_REQUEST_CONTACT_INFO_SECTION_NAME); |
| 183 } | 191 } |
| 184 | 192 |
| 185 int GetSecondaryButtonTextId() override { | 193 int GetSecondaryButtonTextId() override { |
| 186 return IDS_AUTOFILL_ADD_CONTACT_CAPTION; | 194 return IDS_AUTOFILL_ADD_CONTACT_CAPTION; |
| 187 } | 195 } |
| 188 | 196 |
| 189 int GetSecondaryButtonTag() override { | 197 int GetSecondaryButtonTag() override { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 // the subclass method GetProfiles can't be called in the ctor. | 246 // the subclass method GetProfiles can't be called in the ctor. |
| 239 for (auto* profile : GetProfiles()) { | 247 for (auto* profile : GetProfiles()) { |
| 240 list_.AddItem(base::MakeUnique<ProfileItem>(profile, spec(), state(), | 248 list_.AddItem(base::MakeUnique<ProfileItem>(profile, spec(), state(), |
| 241 &list_, this, dialog(), | 249 &list_, this, dialog(), |
| 242 profile == selected_profile)); | 250 profile == selected_profile)); |
| 243 } | 251 } |
| 244 } | 252 } |
| 245 | 253 |
| 246 void ProfileListViewController::FillContentView(views::View* content_view) { | 254 void ProfileListViewController::FillContentView(views::View* content_view) { |
| 247 content_view->SetLayoutManager(new views::FillLayout); | 255 content_view->SetLayoutManager(new views::FillLayout); |
| 248 content_view->AddChildView(list_.CreateListView().release()); | 256 std::unique_ptr<views::View> list_view = list_.CreateListView(); |
| 257 list_view->set_id(static_cast<int>(GetDialogViewId())); |
| 258 content_view->AddChildView(list_view.release()); |
| 249 } | 259 } |
| 250 | 260 |
| 251 std::unique_ptr<views::View> | 261 std::unique_ptr<views::View> |
| 252 ProfileListViewController::CreateExtraFooterView() { | 262 ProfileListViewController::CreateExtraFooterView() { |
| 253 std::unique_ptr<views::View> extra_view = base::MakeUnique<views::View>(); | 263 std::unique_ptr<views::View> extra_view = base::MakeUnique<views::View>(); |
| 254 | 264 |
| 255 extra_view->SetLayoutManager(new views::BoxLayout( | 265 extra_view->SetLayoutManager(new views::BoxLayout( |
| 256 views::BoxLayout::kHorizontal, 0, 0, kPaymentRequestButtonSpacing)); | 266 views::BoxLayout::kHorizontal, 0, 0, kPaymentRequestButtonSpacing)); |
| 257 | 267 |
| 258 views::LabelButton* button = views::MdTextButton::CreateSecondaryUiButton( | 268 views::LabelButton* button = views::MdTextButton::CreateSecondaryUiButton( |
| 259 this, l10n_util::GetStringUTF16(GetSecondaryButtonTextId())); | 269 this, l10n_util::GetStringUTF16(GetSecondaryButtonTextId())); |
| 260 button->set_tag(GetSecondaryButtonTag()); | 270 button->set_tag(GetSecondaryButtonTag()); |
| 261 button->set_id(GetSecondaryButtonViewId()); | 271 button->set_id(GetSecondaryButtonViewId()); |
| 262 extra_view->AddChildView(button); | 272 extra_view->AddChildView(button); |
| 263 | 273 |
| 264 return extra_view; | 274 return extra_view; |
| 265 } | 275 } |
| 266 | 276 |
| 267 void ProfileListViewController::ButtonPressed(views::Button* sender, | 277 void ProfileListViewController::ButtonPressed(views::Button* sender, |
| 268 const ui::Event& event) { | 278 const ui::Event& event) { |
| 269 if (sender->tag() == GetSecondaryButtonTag()) | 279 if (sender->tag() == GetSecondaryButtonTag()) |
| 270 OnSecondaryButtonPressed(); | 280 OnSecondaryButtonPressed(); |
| 271 else | 281 else |
| 272 PaymentRequestSheetController::ButtonPressed(sender, event); | 282 PaymentRequestSheetController::ButtonPressed(sender, event); |
| 273 } | 283 } |
| 274 | 284 |
| 275 } // namespace payments | 285 } // namespace payments |
| OLD | NEW |