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

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

Issue 2805263003: [Payments] Selecting incomplete items will open editors (Closed)
Patch Set: fix ios test for realz 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/editor_view_controller.h" 5 #include "chrome/browser/ui/views/payments/editor_view_controller.h"
6 6
7 #include <map> 7 #include <map>
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 // A very long label will wrap. Value picked so that left + right label 197 // A very long label will wrap. Value picked so that left + right label
198 // padding bring the label to half-way in the dialog (~225). 198 // padding bring the label to half-way in the dialog (~225).
199 constexpr int kMaximumLabelWidth = 192; 199 constexpr int kMaximumLabelWidth = 192;
200 label->SetMultiLine(true); 200 label->SetMultiLine(true);
201 label->SetMaximumWidth(kMaximumLabelWidth); 201 label->SetMaximumWidth(kMaximumLabelWidth);
202 layout->AddView(label.release()); 202 layout->AddView(label.release());
203 203
204 if (field.control_type == EditorField::ControlType::TEXTFIELD) { 204 if (field.control_type == EditorField::ControlType::TEXTFIELD) {
205 ValidatingTextfield* text_field = 205 ValidatingTextfield* text_field =
206 new ValidatingTextfield(CreateValidationDelegate(field)); 206 new ValidatingTextfield(CreateValidationDelegate(field));
207 text_field->SetText(GetInitialValueForType(field.type));
207 text_field->set_controller(this); 208 text_field->set_controller(this);
208 // Using autofill field type as a view ID (for testing). 209 // Using autofill field type as a view ID (for testing).
209 text_field->set_id(static_cast<int>(field.type)); 210 text_field->set_id(static_cast<int>(field.type));
210 text_field->set_default_width_in_chars( 211 text_field->set_default_width_in_chars(
211 field.length_hint == EditorField::LengthHint::HINT_SHORT 212 field.length_hint == EditorField::LengthHint::HINT_SHORT
212 ? kNumCharactersInShortField 213 ? kNumCharactersInShortField
213 : kNumCharactersInLongField); 214 : kNumCharactersInLongField);
214 215
215 text_fields_.insert(std::make_pair(text_field, field)); 216 text_fields_.insert(std::make_pair(text_field, field));
216 // |text_field| will now be owned by |row|. 217 // |text_field| will now be owned by |row|.
217 layout->AddView(text_field); 218 layout->AddView(text_field);
218 } else if (field.control_type == EditorField::ControlType::COMBOBOX) { 219 } else if (field.control_type == EditorField::ControlType::COMBOBOX) {
219 ValidatingCombobox* combobox = new ValidatingCombobox( 220 ValidatingCombobox* combobox = new ValidatingCombobox(
220 GetComboboxModelForType(field.type), CreateValidationDelegate(field)); 221 GetComboboxModelForType(field.type), CreateValidationDelegate(field));
222 combobox->SelectValue(GetInitialValueForType(field.type));
221 // Using autofill field type as a view ID (for testing). 223 // Using autofill field type as a view ID (for testing).
222 combobox->set_id(static_cast<int>(field.type)); 224 combobox->set_id(static_cast<int>(field.type));
223 combobox->set_listener(this); 225 combobox->set_listener(this);
224 comboboxes_.insert(std::make_pair(combobox, field)); 226 comboboxes_.insert(std::make_pair(combobox, field));
225 // |combobox| will now be owned by |row|. 227 // |combobox| will now be owned by |row|.
226 layout->AddView(combobox); 228 layout->AddView(combobox);
227 } else { 229 } else {
228 NOTREACHED(); 230 NOTREACHED();
229 } 231 }
230 232
231 // This is the vertical space between the input field and its error label. 233 // This is the vertical space between the input field and its error label.
232 constexpr int kInputErrorLabelPadding = 6; 234 constexpr int kInputErrorLabelPadding = 6;
233 layout->StartRowWithPadding(0, 0, 0, kInputErrorLabelPadding); 235 layout->StartRowWithPadding(0, 0, 0, kInputErrorLabelPadding);
234 layout->SkipColumns(1); 236 layout->SkipColumns(1);
235 // Error label is initially empty. 237 // Error label is initially empty.
236 std::unique_ptr<views::Label> error_label = 238 std::unique_ptr<views::Label> error_label =
237 base::MakeUnique<views::Label>(base::ASCIIToUTF16("")); 239 base::MakeUnique<views::Label>(base::ASCIIToUTF16(""));
238 error_label->set_id(static_cast<int>(DialogViewID::ERROR_LABEL_OFFSET) + 240 error_label->set_id(static_cast<int>(DialogViewID::ERROR_LABEL_OFFSET) +
239 field.type); 241 field.type);
240 error_label->SetFontList( 242 error_label->SetFontList(
241 error_label->GetDefaultFontList().DeriveWithSizeDelta(-1)); 243 error_label->GetDefaultFontList().DeriveWithSizeDelta(-1));
242 error_label->SetEnabledColor(error_label->GetNativeTheme()->GetSystemColor( 244 error_label->SetEnabledColor(error_label->GetNativeTheme()->GetSystemColor(
243 ui::NativeTheme::kColorId_AlertSeverityHigh)); 245 ui::NativeTheme::kColorId_AlertSeverityHigh));
244 error_labels_[field] = error_label.get(); 246 error_labels_[field] = error_label.get();
245 247
246 layout->AddView(error_label.release()); 248 layout->AddView(error_label.release());
247 } 249 }
248 250
249 } // namespace payments 251 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698