Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(478)

Side by Side Diff: chrome/browser/ui/views/payments/profile_list_view_controller.cc

Issue 2841643002: When a new Payments address is created from the editor, use it as the chosen address (Closed)
Patch Set: Self CR Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 74 }
75 } 75 }
76 76
77 bool CanBeSelected() const override { 77 bool CanBeSelected() const override {
78 // TODO(crbug.com/709454): Check for profile completeness. Currently a giant 78 // TODO(crbug.com/709454): Check for profile completeness. Currently a giant
79 // hack to test the UI. 79 // hack to test the UI.
80 return !profile_->GetRawInfo(autofill::ADDRESS_HOME_ZIP).empty(); 80 return !profile_->GetRawInfo(autofill::ADDRESS_HOME_ZIP).empty();
81 } 81 }
82 82
83 void PerformSelectionFallback() override { 83 void PerformSelectionFallback() override {
84 dialog_->ShowShippingAddressEditor(profile_); 84 dialog_->ShowShippingAddressEditor(
85 /*on_edited=*/base::BindOnce(
86 &PaymentRequestState::SetSelectedShippingProfile,
87 base::Unretained(state()), profile_),
88 /*on_added=*/
89 base::OnceCallback<void(const autofill::AutofillProfile&)>(), profile_);
85 } 90 }
86 91
87 ProfileListViewController* parent_view_; 92 ProfileListViewController* parent_view_;
88 autofill::AutofillProfile* profile_; 93 autofill::AutofillProfile* profile_;
89 PaymentRequestDialogView* dialog_; 94 PaymentRequestDialogView* dialog_;
90 95
91 DISALLOW_COPY_AND_ASSIGN(ProfileItem); 96 DISALLOW_COPY_AND_ASSIGN(ProfileItem);
92 }; 97 };
93 98
94 // The ProfileListViewController subtype for the Shipping address list 99 // The ProfileListViewController subtype for the Shipping address list
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 int GetSecondaryButtonTag() override { 143 int GetSecondaryButtonTag() override {
139 return static_cast<int>( 144 return static_cast<int>(
140 PaymentMethodViewControllerTags::ADD_SHIPPING_ADDRESS_BUTTON); 145 PaymentMethodViewControllerTags::ADD_SHIPPING_ADDRESS_BUTTON);
141 } 146 }
142 147
143 int GetSecondaryButtonViewId() override { 148 int GetSecondaryButtonViewId() override {
144 return static_cast<int>(DialogViewID::PAYMENT_METHOD_ADD_SHIPPING_BUTTON); 149 return static_cast<int>(DialogViewID::PAYMENT_METHOD_ADD_SHIPPING_BUTTON);
145 } 150 }
146 151
147 void OnSecondaryButtonPressed() override { 152 void OnSecondaryButtonPressed() override {
148 dialog()->ShowShippingAddressEditor(); 153 dialog()->ShowShippingAddressEditor(
154 /*on_edited=*/base::OnceClosure(),
155 /*on_added=*/
156 base::BindOnce(&PaymentRequestState::AddAutofillShippingProfile,
157 base::Unretained(state()), /*selected=*/true),
158 /*profile=*/nullptr);
149 } 159 }
150 160
151 private: 161 private:
152 DISALLOW_COPY_AND_ASSIGN(ShippingProfileViewController); 162 DISALLOW_COPY_AND_ASSIGN(ShippingProfileViewController);
153 }; 163 };
154 164
155 class ContactProfileViewController : public ProfileListViewController { 165 class ContactProfileViewController : public ProfileListViewController {
156 public: 166 public:
157 ContactProfileViewController(PaymentRequestSpec* spec, 167 ContactProfileViewController(PaymentRequestSpec* spec,
158 PaymentRequestState* state, 168 PaymentRequestState* state,
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 288
279 void ProfileListViewController::ButtonPressed(views::Button* sender, 289 void ProfileListViewController::ButtonPressed(views::Button* sender,
280 const ui::Event& event) { 290 const ui::Event& event) {
281 if (sender->tag() == GetSecondaryButtonTag()) 291 if (sender->tag() == GetSecondaryButtonTag())
282 OnSecondaryButtonPressed(); 292 OnSecondaryButtonPressed();
283 else 293 else
284 PaymentRequestSheetController::ButtonPressed(sender, event); 294 PaymentRequestSheetController::ButtonPressed(sender, event);
285 } 295 }
286 296
287 } // namespace payments 297 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698