Chromium Code Reviews| 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 #import "ios/chrome/browser/ui/payments/region_data_loader.h" | 5 #import "ios/chrome/browser/ui/payments/region_data_loader.h" |
| 6 | 6 |
| 7 #include "base/strings/sys_string_conversions.h" | 7 #include "base/strings/sys_string_conversions.h" |
| 8 #include "components/autofill/core/browser/region_data_loader.h" | 8 #include "components/autofill/core/browser/region_data_loader.h" |
| 9 #include "ui/base/models/combobox_model.h" | 9 #include "ui/base/models/combobox_model.h" |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 region_model_.LoadRegionData(country_code, autofill_region_data_loader, | 31 region_model_.LoadRegionData(country_code, autofill_region_data_loader, |
| 32 kTimeoutInMilliseconds); | 32 kTimeoutInMilliseconds); |
| 33 } | 33 } |
| 34 | 34 |
| 35 void RegionDataLoader::OnComboboxModelChanged(ui::ComboboxModel* model) { | 35 void RegionDataLoader::OnComboboxModelChanged(ui::ComboboxModel* model) { |
| 36 autofill::RegionComboboxModel* region_model = | 36 autofill::RegionComboboxModel* region_model = |
| 37 static_cast<autofill::RegionComboboxModel*>(model); | 37 static_cast<autofill::RegionComboboxModel*>(model); |
| 38 if (region_model->IsPendingRegionDataLoad()) | 38 if (region_model->IsPendingRegionDataLoad()) |
| 39 return; | 39 return; |
| 40 | 40 |
| 41 NSMutableArray<NSString*>* regions = [[NSMutableArray alloc] init]; | 41 NSMutableDictionary<NSString*, NSString*>* regions = |
| 42 [[NSMutableDictionary alloc] init]; | |
| 42 if (!region_model->failed_to_load_data()) { | 43 if (!region_model->failed_to_load_data()) { |
| 43 for (int i = 0; i < region_model->GetItemCount(); ++i) { | 44 for (int i = 0; i < region_model->GetItemCount(); ++i) { |
| 44 if (!region_model->IsItemSeparatorAt(i)) | 45 if (!region_model->IsItemSeparatorAt(i)) { |
| 45 [regions | 46 [regions setObject:base::SysUTF8ToNSString( |
| 46 addObject:base::SysUTF16ToNSString(region_model->GetItemAt(i))]; | 47 region_model->GetRegions()[i].second) |
|
macourteau
2017/06/20 16:25:00
nit: extract |region_model->GetRegions()[i]| (or e
Moe
2017/06/20 18:28:34
Done.
| |
| 48 forKey:base::SysUTF8ToNSString( | |
| 49 region_model->GetRegions()[i].first)]; | |
| 50 } | |
| 47 } | 51 } |
| 48 } | 52 } |
| 49 [consumer_ regionDataLoaderDidSucceedWithRegions:regions]; | 53 [consumer_ regionDataLoaderDidSucceedWithRegions:regions]; |
| 50 } | 54 } |
| OLD | NEW |