| 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/editor_view_controller.h" | 5 #include "chrome/browser/ui/views/payments/editor_view_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 return initial_focus_field_view_; | 200 return initial_focus_field_view_; |
| 201 return PaymentRequestSheetController::GetFirstFocusedView(); | 201 return PaymentRequestSheetController::GetFirstFocusedView(); |
| 202 } | 202 } |
| 203 | 203 |
| 204 std::unique_ptr<ValidatingCombobox> | 204 std::unique_ptr<ValidatingCombobox> |
| 205 EditorViewController::CreateComboboxForField(const EditorField& field) { | 205 EditorViewController::CreateComboboxForField(const EditorField& field) { |
| 206 std::unique_ptr<ValidatingCombobox> combobox = | 206 std::unique_ptr<ValidatingCombobox> combobox = |
| 207 base::MakeUnique<ValidatingCombobox>(GetComboboxModelForType(field.type), | 207 base::MakeUnique<ValidatingCombobox>(GetComboboxModelForType(field.type), |
| 208 CreateValidationDelegate(field)); | 208 CreateValidationDelegate(field)); |
| 209 base::string16 initial_value = GetInitialValueForType(field.type); | 209 base::string16 initial_value = GetInitialValueForType(field.type); |
| 210 combobox->SetAccessibleName(field.label); |
| 210 if (!initial_value.empty()) { | 211 if (!initial_value.empty()) { |
| 211 combobox->SelectValue(initial_value); | 212 combobox->SelectValue(initial_value); |
| 212 combobox->SetInvalid(!combobox->IsValid()); | 213 combobox->SetInvalid(!combobox->IsValid()); |
| 213 } | 214 } |
| 214 // Using autofill field type as a view ID. | 215 // Using autofill field type as a view ID. |
| 215 combobox->set_id(GetInputFieldViewId(field.type)); | 216 combobox->set_id(GetInputFieldViewId(field.type)); |
| 216 combobox->set_listener(this); | 217 combobox->set_listener(this); |
| 217 comboboxes_.insert(std::make_pair(combobox.get(), field)); | 218 comboboxes_.insert(std::make_pair(combobox.get(), field)); |
| 218 return combobox; | 219 return combobox; |
| 219 } | 220 } |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 constexpr int kInputFieldHeight = 28; | 368 constexpr int kInputFieldHeight = 28; |
| 368 | 369 |
| 369 switch (field.control_type) { | 370 switch (field.control_type) { |
| 370 case EditorField::ControlType::TEXTFIELD: | 371 case EditorField::ControlType::TEXTFIELD: |
| 371 case EditorField::ControlType::TEXTFIELD_NUMBER: { | 372 case EditorField::ControlType::TEXTFIELD_NUMBER: { |
| 372 ValidatingTextfield* text_field = | 373 ValidatingTextfield* text_field = |
| 373 new ValidatingTextfield(CreateValidationDelegate(field)); | 374 new ValidatingTextfield(CreateValidationDelegate(field)); |
| 374 // Set the initial value and validity state. | 375 // Set the initial value and validity state. |
| 375 base::string16 initial_value = GetInitialValueForType(field.type); | 376 base::string16 initial_value = GetInitialValueForType(field.type); |
| 376 text_field->SetText(initial_value); | 377 text_field->SetText(initial_value); |
| 378 text_field->SetAccessibleName(field.label); |
| 377 *valid = text_field->IsValid(); | 379 *valid = text_field->IsValid(); |
| 378 if (!initial_value.empty()) | 380 if (!initial_value.empty()) |
| 379 text_field->SetInvalid(!(*valid)); | 381 text_field->SetInvalid(!(*valid)); |
| 380 | 382 |
| 381 if (field.control_type == EditorField::ControlType::TEXTFIELD_NUMBER) | 383 if (field.control_type == EditorField::ControlType::TEXTFIELD_NUMBER) |
| 382 text_field->SetTextInputType(ui::TextInputType::TEXT_INPUT_TYPE_NUMBER); | 384 text_field->SetTextInputType(ui::TextInputType::TEXT_INPUT_TYPE_NUMBER); |
| 383 text_field->set_controller(this); | 385 text_field->set_controller(this); |
| 384 // Using autofill field type as a view ID (for testing). | 386 // Using autofill field type as a view ID (for testing). |
| 385 text_field->set_id(GetInputFieldViewId(field.type)); | 387 text_field->set_id(GetInputFieldViewId(field.type)); |
| 386 text_fields_.insert(std::make_pair(text_field, field)); | 388 text_fields_.insert(std::make_pair(text_field, field)); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 CreateExtraViewForField(field.type); | 458 CreateExtraViewForField(field.type); |
| 457 if (!extra_view) | 459 if (!extra_view) |
| 458 continue; | 460 continue; |
| 459 widest_column_width = | 461 widest_column_width = |
| 460 std::max(extra_view->GetPreferredSize().width(), widest_column_width); | 462 std::max(extra_view->GetPreferredSize().width(), widest_column_width); |
| 461 } | 463 } |
| 462 return widest_column_width; | 464 return widest_column_width; |
| 463 } | 465 } |
| 464 | 466 |
| 465 } // namespace payments | 467 } // namespace payments |
| OLD | NEW |