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

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

Issue 2768133002: [Web Payments] Refactor sheet display to allow updating view content (Closed)
Patch Set: Add comments. Created 3 years, 9 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/credit_card_editor_view_controller.h" 5 #include "chrome/browser/ui/views/payments/credit_card_editor_view_controller.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 base::UTF8ToUTF16(supported_network)); 135 base::UTF8ToUTF16(supported_network));
136 card_icon_view->SetImageSize(kCardIconSize); 136 card_icon_view->SetImageSize(kCardIconSize);
137 137
138 icons_row->AddChildView(card_icon_view.release()); 138 icons_row->AddChildView(card_icon_view.release());
139 } 139 }
140 view->AddChildView(icons_row.release()); 140 view->AddChildView(icons_row.release());
141 141
142 return view; 142 return view;
143 } 143 }
144 144
145 int CreditCardEditorViewController::GetViewHeaderTitleId() const {
146 return IDS_PAYMENT_REQUEST_CREDIT_CARD_EDITOR_ADD_TITLE;
147 }
148
149 std::vector<EditorField> CreditCardEditorViewController::GetFieldDefinitions() { 145 std::vector<EditorField> CreditCardEditorViewController::GetFieldDefinitions() {
150 return std::vector<EditorField>{ 146 return std::vector<EditorField>{
151 {autofill::CREDIT_CARD_NUMBER, 147 {autofill::CREDIT_CARD_NUMBER,
152 l10n_util::GetStringUTF16(IDS_AUTOFILL_FIELD_LABEL_CREDIT_CARD_NUMBER), 148 l10n_util::GetStringUTF16(IDS_AUTOFILL_FIELD_LABEL_CREDIT_CARD_NUMBER),
153 EditorField::LengthHint::HINT_LONG, /* required= */ true}, 149 EditorField::LengthHint::HINT_LONG, /* required= */ true},
154 {autofill::CREDIT_CARD_NAME_FULL, 150 {autofill::CREDIT_CARD_NAME_FULL,
155 l10n_util::GetStringUTF16(IDS_AUTOFILL_FIELD_LABEL_NAME_ON_CARD), 151 l10n_util::GetStringUTF16(IDS_AUTOFILL_FIELD_LABEL_NAME_ON_CARD),
156 EditorField::LengthHint::HINT_LONG, /* required= */ true}, 152 EditorField::LengthHint::HINT_LONG, /* required= */ true},
157 {autofill::CREDIT_CARD_EXP_MONTH, 153 {autofill::CREDIT_CARD_EXP_MONTH,
158 l10n_util::GetStringUTF16(IDS_AUTOFILL_FIELD_LABEL_EXPIRATION_MONTH), 154 l10n_util::GetStringUTF16(IDS_AUTOFILL_FIELD_LABEL_EXPIRATION_MONTH),
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 case autofill::CREDIT_CARD_EXP_4_DIGIT_YEAR: 221 case autofill::CREDIT_CARD_EXP_4_DIGIT_YEAR:
226 return std::unique_ptr<ui::ComboboxModel>( 222 return std::unique_ptr<ui::ComboboxModel>(
227 new ui::SimpleComboboxModel(GetExpirationYearItems())); 223 new ui::SimpleComboboxModel(GetExpirationYearItems()));
228 default: 224 default:
229 NOTREACHED(); 225 NOTREACHED();
230 break; 226 break;
231 } 227 }
232 return std::unique_ptr<ui::ComboboxModel>(); 228 return std::unique_ptr<ui::ComboboxModel>();
233 } 229 }
234 230
231 base::string16 CreditCardEditorViewController::GetSheetTitle() {
232 return l10n_util::GetStringUTF16(
233 IDS_PAYMENT_REQUEST_CREDIT_CARD_EDITOR_ADD_TITLE);
234 }
235
235 CreditCardEditorViewController::CreditCardValidationDelegate:: 236 CreditCardEditorViewController::CreditCardValidationDelegate::
236 CreditCardValidationDelegate( 237 CreditCardValidationDelegate(
237 const EditorField& field, 238 const EditorField& field,
238 EditorViewController* controller, 239 EditorViewController* controller,
239 const std::vector<std::string>& supported_card_networks) 240 const std::vector<std::string>& supported_card_networks)
240 : field_(field), 241 : field_(field),
241 controller_(controller), 242 controller_(controller),
242 supported_card_networks_(supported_card_networks.begin(), 243 supported_card_networks_(supported_card_networks.begin(),
243 supported_card_networks.end()) {} 244 supported_card_networks.end()) {}
244 CreditCardEditorViewController::CreditCardValidationDelegate:: 245 CreditCardEditorViewController::CreditCardValidationDelegate::
(...skipping 25 matching lines...) Expand all
270 bool is_required_valid = !field_.required; 271 bool is_required_valid = !field_.required;
271 const base::string16 displayed_message = 272 const base::string16 displayed_message =
272 is_required_valid ? base::ASCIIToUTF16("") 273 is_required_valid ? base::ASCIIToUTF16("")
273 : l10n_util::GetStringUTF16( 274 : l10n_util::GetStringUTF16(
274 IDS_PAYMENTS_FIELD_REQUIRED_VALIDATION_MESSAGE); 275 IDS_PAYMENTS_FIELD_REQUIRED_VALIDATION_MESSAGE);
275 controller_->DisplayErrorMessageForField(field_, displayed_message); 276 controller_->DisplayErrorMessageForField(field_, displayed_message);
276 return is_required_valid; 277 return is_required_valid;
277 } 278 }
278 279
279 } // namespace payments 280 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698