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

Side by Side Diff: ios/chrome/browser/ui/payments/region_data_loader.mm

Issue 2950843002: [Payment Request] Populates region field if region code/name is valid. (Closed)
Patch Set: Addressed comment Created 3 years, 6 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 #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 <string>
8 #include <utility>
9
7 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
8 #include "components/autofill/core/browser/region_data_loader.h" 11 #include "components/autofill/core/browser/region_data_loader.h"
9 #include "ui/base/models/combobox_model.h" 12 #include "ui/base/models/combobox_model.h"
10 13
11 #if !defined(__has_feature) || !__has_feature(objc_arc) 14 #if !defined(__has_feature) || !__has_feature(objc_arc)
12 #error "This file requires ARC support." 15 #error "This file requires ARC support."
13 #endif 16 #endif
14 17
15 namespace { 18 namespace {
16 const int64_t kTimeoutInMilliseconds = 5000; 19 const int64_t kTimeoutInMilliseconds = 5000;
(...skipping 14 matching lines...) Expand all
31 region_model_.LoadRegionData(country_code, autofill_region_data_loader, 34 region_model_.LoadRegionData(country_code, autofill_region_data_loader,
32 kTimeoutInMilliseconds); 35 kTimeoutInMilliseconds);
33 } 36 }
34 37
35 void RegionDataLoader::OnComboboxModelChanged(ui::ComboboxModel* model) { 38 void RegionDataLoader::OnComboboxModelChanged(ui::ComboboxModel* model) {
36 autofill::RegionComboboxModel* region_model = 39 autofill::RegionComboboxModel* region_model =
37 static_cast<autofill::RegionComboboxModel*>(model); 40 static_cast<autofill::RegionComboboxModel*>(model);
38 if (region_model->IsPendingRegionDataLoad()) 41 if (region_model->IsPendingRegionDataLoad())
39 return; 42 return;
40 43
41 NSMutableArray<NSString*>* regions = [[NSMutableArray alloc] init]; 44 NSMutableDictionary<NSString*, NSString*>* regions =
45 [[NSMutableDictionary alloc] init];
42 if (!region_model->failed_to_load_data()) { 46 if (!region_model->failed_to_load_data()) {
43 for (int i = 0; i < region_model->GetItemCount(); ++i) { 47 for (int i = 0; i < region_model->GetItemCount(); ++i) {
44 if (!region_model->IsItemSeparatorAt(i)) 48 if (!region_model->IsItemSeparatorAt(i)) {
45 [regions 49 const std::pair<std::string, std::string>& region =
46 addObject:base::SysUTF16ToNSString(region_model->GetItemAt(i))]; 50 region_model->GetRegions()[i];
51 [regions setObject:base::SysUTF8ToNSString(region.second)
52 forKey:base::SysUTF8ToNSString(region.first)];
53 }
47 } 54 }
48 } 55 }
49 [consumer_ regionDataLoaderDidSucceedWithRegions:regions]; 56 [consumer_ regionDataLoaderDidSucceedWithRegions:regions];
50 } 57 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/payments/region_data_loader.h ('k') | ios/chrome/browser/ui/payments/region_data_loader_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698